use thiserror::Error;
pub type Result<T> = std::result::Result<T, CompressionError>;
#[derive(Error, Debug)]
pub enum CompressionError {
#[error("Codec not supported: {0}")]
CodecNotSupported(String),
#[error("Compression failed: {0}")]
CompressionFailed(String),
#[error("Decompression failed: {0}")]
DecompressionFailed(String),
#[error("Invalid compression level: {level}, expected range {min}..={max}")]
InvalidCompressionLevel {
level: i32,
min: i32,
max: i32,
},
#[error("Invalid buffer size: {0}")]
InvalidBufferSize(String),
#[error("Checksum mismatch: expected {expected:x}, got {actual:x}")]
ChecksumMismatch {
expected: u64,
actual: u64,
},
#[error("Integrity check failed: {0}")]
IntegrityCheckFailed(String),
#[error("Invalid metadata: {0}")]
InvalidMetadata(String),
#[error("I/O error: {0}")]
Io(#[from] std::io::Error),
#[error("Invalid parameter: {0}")]
InvalidParameter(String),
#[error("LZ4 error: {0}")]
Lz4Error(String),
#[error("Zstd error: {0}")]
ZstdError(String),
#[error("Brotli error: {0}")]
BrotliError(String),
#[error("Snappy codec error: {0}")]
SnappyError(String),
#[error("Deflate error: {0}")]
DeflateError(String),
#[error("Delta codec error: {0}")]
DeltaError(String),
#[error("RLE error: {0}")]
RleError(String),
#[error("Dictionary error: {0}")]
DictionaryError(String),
#[error("Floating-point compression error: {0}")]
FloatingPointError(String),
#[error("Auto-selection error: {0}")]
AutoSelectionError(String),
#[error("Parallel processing error: {0}")]
ParallelError(String),
#[error("Streaming error: {0}")]
StreamingError(String),
#[error("Unsupported data type: {0}")]
UnsupportedDataType(String),
#[error("Buffer too small: required {required}, available {available}")]
BufferTooSmall {
required: usize,
available: usize,
},
#[error("Configuration error: {0}")]
ConfigurationError(String),
}
impl From<oxiarc_snappy::SnappyError> for CompressionError {
fn from(err: oxiarc_snappy::SnappyError) -> Self {
CompressionError::SnappyError(err.to_string())
}
}