Skip to content

Commit

Permalink
compression: derive Error for brotli::Error
Browse files Browse the repository at this point in the history
  • Loading branch information
simonwuelker committed Aug 11, 2024
1 parent e9e1875 commit c0e39e4
Showing 1 changed file with 19 additions and 7 deletions.
26 changes: 19 additions & 7 deletions crates/compression/src/brotli/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
pub mod dictionary;

use crate::huffman::{Bits, HuffmanBitTree, HuffmanTree};
use error_derive::Error;
use sl_std::bitreader::{self, BitReader};

use sl_std::ring_buffer::RingBuffer;
Expand Down Expand Up @@ -102,23 +103,34 @@ const LUT2: [u8; 256] = [
6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 7
];

#[derive(Clone, Copy, Debug)]
#[derive(Clone, Copy, Debug, Error)]
pub enum Error {
#[msg = "invalid format"]
InvalidFormat,

#[msg = "invalid symbol"]
InvalidSymbol,

#[msg = "mismatched checksum"]
MismatchedChecksum,

#[msg = "run length encoding exceeds expected size"]
RunlengthEncodingExceedsExpectedSize,

#[msg = "not enough code lengths"]
NotEnoughCodeLengths,

#[msg = "symbol not found"]
SymbolNotFound,

#[msg = "invalid dictionary reference length"]
InvalidDictionaryReferenceLength,

#[msg = "invalid transform id"]
InvalidTransformID,
BitReader(bitreader::Error),
}

impl From<bitreader::Error> for Error {
fn from(value: bitreader::Error) -> Self {
Self::BitReader(value)
}
#[msg = "failed to read bits"]
BitReader(bitreader::Error),
}

// https://www.rfc-editor.org/rfc/rfc7932#section-10
Expand Down

0 comments on commit c0e39e4

Please sign in to comment.