use std::path::PathBuf;
#[derive(Debug, thiserror::Error)]
#[allow(dead_code)]
pub enum Error {
#[error("I/O error: {0}")]
Io(#[from] std::io::Error),
#[error("ZIP error: {0}")]
Zip(String),
#[error("7-Zip error: {0}")]
SevenZip(String),
#[error("LZMA error: {0}")]
Lzma(#[from] lzma_rs::error::Error),
#[error("LZ4 decompression error: {0}")]
Lz4(String),
#[error("LHA error: {0}")]
Lha(String),
#[error("XAR archive error: {0}")]
Xar(String),
#[error("XZ decompression error: {0}")]
Xz(String),
#[error("Unsupported archive format: {0}")]
UnsupportedFormat(String),
#[error("Invalid archive: {0}")]
InvalidArchive(String),
#[error("File too large: {size} bytes exceeds limit of {limit} bytes")]
FileTooLarge {
size: u64,
limit: u64,
},
#[error("Total extraction size exceeds limit of {limit} bytes")]
TotalSizeLimitExceeded {
limit: u64,
},
#[error("Path traversal detected in archive entry: {0}")]
PathTraversal(String),
#[error("File not found: {}", .0.display())]
FileNotFound(PathBuf),
#[error("Invalid gzip header: {0}")]
InvalidGzipHeader(String),
#[error("Invalid StuffIt archive: {0}")]
InvalidStuffIt(String),
#[error("Invalid Compact Pro archive: {0}")]
InvalidCompactPro(String),
#[error("Checksum mismatch: expected {expected}, got {actual}")]
ChecksumMismatch {
expected: String,
actual: String,
},
#[error("Encrypted archive entries are not supported")]
EncryptedNotSupported,
#[error("Invalid size specification: {0}")]
InvalidSize(String),
#[error("Extraction error: {0}")]
ExarchExtraction(String),
#[error(
"Max files limit exceeded: {count} files \
exceeds limit of {limit}"
)]
MaxFilesExceeded {
count: usize,
limit: usize,
},
#[error(
"Compression ratio {ratio:.1} exceeds \
limit of {limit}"
)]
CompressionRatioExceeded {
ratio: f64,
limit: u64,
},
}
pub type Result<T> = std::result::Result<T, Error>;