Skip to content

Commit

Permalink
compression: derive Error for gzip::Error
Browse files Browse the repository at this point in the history
  • Loading branch information
simonwuelker committed Aug 10, 2024
1 parent 9c00bf0 commit e177e10
Showing 1 changed file with 13 additions and 7 deletions.
20 changes: 13 additions & 7 deletions crates/compression/src/gzip.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
use std::io::{self, Seek};

use error_derive::Error;
use sl_std::{bytestream::ByteStream, read::ReadExt};

use crate::deflate;
Expand All @@ -22,13 +23,24 @@ mod flags {
pub const FCOMMENT: u8 = 1 << 4;
}

#[derive(Clone, Copy, Debug)]
#[derive(Clone, Copy, Debug, Error)]
pub enum Error {
#[msg = "gzip magic bytes do not match"]
NotGzip,

#[msg = "unknown compression method"]
UnknownCompressionMethod,

#[msg = "unexpected end of file"]
UnexpectedEOF,

#[msg = "unexpected length"]
UnexpectedLength,

#[msg = "mismatched checksum"]
ChecksumError,

#[msg = "deflate error"]
Deflate(deflate::Error),
}

Expand Down Expand Up @@ -127,9 +139,3 @@ impl From<io::Error> for Error {
Self::UnexpectedEOF
}
}

impl From<deflate::Error> for Error {
fn from(value: deflate::Error) -> Self {
Self::Deflate(value)
}
}

0 comments on commit e177e10

Please sign in to comment.