#[non_exhaustive]
#[derive(Debug, thiserror::Error)]
pub enum ZiPatchError {
#[error("I/O error: {0}")]
Io(#[from] std::io::Error),
#[error("invalid magic bytes")]
InvalidMagic,
#[error("unknown chunk tag: {0:?}")]
UnknownChunkTag([u8; 4]),
#[error("unknown SQPK command: {0:#x}")]
UnknownSqpkCommand(u8),
#[error("CRC32 mismatch on chunk {tag:?}: expected {expected:#010x}, got {actual:#010x}")]
ChecksumMismatch {
tag: [u8; 4],
expected: u32,
actual: u32,
},
#[error("decompression error")]
Decompress(#[source] std::io::Error),
#[error("invalid field: {context}")]
InvalidField {
context: &'static str,
},
#[error("chunk size {0} exceeds maximum")]
OversizedChunk(usize),
#[error("unknown SqpkFile operation: {0:#02x}")]
UnknownFileOperation(u8),
#[error("UTF-8 decode error")]
Utf8Error(#[from] std::string::FromUtf8Error),
#[error("binrw parse error: {0}")]
BinrwError(#[from] binrw::Error),
#[error("negative file_offset in SqpkFile: {0}")]
NegativeFileOffset(i64),
#[error("patch file ended without EOF_ chunk (truncated download?)")]
TruncatedPatch,
}