crabka_compression/
error.rs1use thiserror::Error;
4
5#[derive(Debug, Error)]
7#[non_exhaustive]
8pub enum CompressionError {
9 #[error("compression feature `{0}` not enabled at compile time")]
12 FeatureDisabled(&'static str),
13
14 #[error("invalid compressed data: {0}")]
17 InvalidData(String),
18
19 #[error("decompressed output exceeds limit of {limit} bytes")]
23 TooLarge { limit: usize },
24
25 #[error("I/O error: {0}")]
27 Io(#[from] std::io::Error),
28}
29
30#[cfg(test)]
31mod tests {
32 use super::*;
33 use assert2::assert;
34
35 #[test]
36 fn feature_disabled_display() {
37 let e = CompressionError::FeatureDisabled("snappy");
38 assert!(e.to_string() == "compression feature `snappy` not enabled at compile time");
39 }
40}