use thiserror::Error;
pub type Result<T> = std::result::Result<T, ParxError>;
#[derive(Error, Debug)]
pub enum ParxError {
#[error("invalid magic: expected PARX, got {0:?}")]
InvalidMagic([u8; 4]),
#[error("unsupported version: {major}.{minor}")]
UnsupportedVersion { major: u8, minor: u8 },
#[error("file too small: {size} bytes, minimum is {minimum}")]
FileTooSmall { size: usize, minimum: usize },
#[error("manifest CRC32C mismatch: expected {expected:#010x}, got {actual:#010x}")]
ManifestChecksumMismatch { expected: u32, actual: u32 },
#[error("footer checksum mismatch")]
FooterChecksumMismatch,
#[error("page index checksum mismatch")]
PageIndexChecksumMismatch,
#[error("failed to decode manifest: {0}")]
ManifestDecode(#[from] prost::DecodeError),
#[error("invalid payload bounds: offset {offset}, length {length}, file size {file_size}")]
InvalidPayloadBounds {
offset: u64,
length: u64,
file_size: u64,
},
#[error("invalid format: {0}")]
InvalidFormat(String),
#[error("compression error: {0}")]
CompressionError(String),
#[error("invalid bundle magic: expected PRXB, got {0:?}")]
InvalidBundleMagic([u8; 4]),
#[error("invalid Parquet magic bytes (expected PAR1, got {0:?})")]
InvalidParquetMagic([u8; 4]),
#[error("Parquet footer length {footer_len} exceeds file size {file_size}")]
InvalidParquetFooterLength { footer_len: u64, file_size: u64 },
#[error("I/O error: {0}")]
Io(#[from] std::io::Error),
}