use thiserror::Error;
#[derive(Debug, Error)]
#[non_exhaustive]
pub enum CompressionError {
#[error("compression feature `{0}` not enabled at compile time")]
FeatureDisabled(&'static str),
#[error("invalid compressed data: {0}")]
InvalidData(String),
#[error("decompressed output exceeds limit of {limit} bytes")]
TooLarge { limit: usize },
#[error("I/O error: {0}")]
Io(#[from] std::io::Error),
}
#[cfg(test)]
mod tests {
use super::*;
use assert2::assert;
#[test]
fn feature_disabled_display() {
let e = CompressionError::FeatureDisabled("snappy");
assert!(e.to_string() == "compression feature `snappy` not enabled at compile time");
}
}