use thiserror::Error;
pub type Result<T> = std::result::Result<T, Error>;
#[derive(Debug, Error, Clone, PartialEq, Eq)]
pub enum Error {
#[error("input ended unexpectedly at byte {position}")]
TruncatedInput {
position: usize,
},
#[error("invalid opcode 0x{opcode:02x} at byte {position}")]
InvalidOpcode {
position: usize,
opcode: u8,
},
#[error(
"invalid match distance {distance}; only {available} bytes are available for back-references"
)]
InvalidMatchDistance {
distance: usize,
available: usize,
},
#[error("output buffer is too small after writing {written} bytes into a buffer of {capacity}")]
OutputTooSmall {
written: usize,
capacity: usize,
},
#[error("decoded {actual} bytes but expected {expected}")]
SizeMismatch {
expected: usize,
actual: usize,
},
#[error("input contains {remaining} trailing bytes after the end-of-stream marker")]
TrailingData {
remaining: usize,
},
#[error("unsupported Apple block magic 0x{magic:08x}")]
UnsupportedBlockMagic {
magic: u32,
},
#[error("invalid decmpfs magic 0x{magic:08x}")]
InvalidDecmpfsMagic {
magic: u32,
},
#[error("unsupported decmpfs compression type {compression_type}")]
UnsupportedDecmpfsCompressionType {
compression_type: u32,
},
#[error("decmpfs resource fork data is required for this compression type")]
MissingResourceFork,
#[error("invalid decmpfs resource fork: {reason}")]
InvalidResourceFork {
reason: &'static str,
},
#[error("{what} size {value} exceeds the format limit of {max}")]
SizeOverflow {
value: usize,
max: usize,
what: &'static str,
},
}