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 assert2::assert;
33
34 use super::*;
35
36 #[test]
37 fn feature_disabled_display() {
38 let e = CompressionError::FeatureDisabled("snappy");
39 assert!(e.to_string() == "compression feature `snappy` not enabled at compile time");
40 }
41}