use thiserror::Error;
#[derive(Debug, Error, Eq, PartialEq)]
#[non_exhaustive]
pub enum ArchiveError {
#[error(
"truncated tar archive: need {need} bytes at offset {offset} (have {have}). Fix: pass the full archive slice."
)]
Truncated {
offset: usize,
need: usize,
have: usize,
},
#[error(
"invalid tar header at offset {offset}: {message}. Fix: verify the input is a valid ustar tar stream."
)]
InvalidHeader {
offset: usize,
message: String,
},
#[error(
"tar entry size {size} exceeds maximum ({max}). Fix: raise MAX_ENTRY_BYTES only if you accept that memory risk, or preprocess the archive."
)]
EntryTooLarge {
size: u64,
max: usize,
},
#[error(
"tar entry name '{name}' contains path traversal pattern ('..' or absolute path). Fix: sanitize archive entries before processing."
)]
PathTraversal {
name: String,
},
#[error(
"tar archive contains too many entries ({count} exceeds maximum {max}). Fix: raise MAX_ENTRIES only if you accept that resource risk, or split the archive."
)]
TooManyEntries {
count: usize,
max: usize,
},
}