use thiserror::Error;
#[derive(Debug, Error)]
pub enum Error {
#[error("I/O error: {0}")]
Io(#[from] std::io::Error),
#[error("CBOR serialization error: {0}")]
CborSerialize(ciborium::ser::Error<std::io::Error>),
#[error("CBOR deserialization error: {0}")]
CborDeserialize(ciborium::de::Error<std::io::Error>),
#[error("Zstd compression error: {0}")]
ZstdCompression(std::io::Error),
#[error("Zstd decompression error: {0}")]
ZstdDecompression(std::io::Error),
#[error("Invalid magic number. Expected 'ZTEN1000', found {found:?}")]
InvalidMagicNumber { found: Vec<u8> },
#[error("Offset {offset} is not aligned to {alignment} bytes")]
InvalidAlignment { offset: u64, alignment: u64 },
#[error("Object not found: {0}")]
ObjectNotFound(String),
#[error("Unsupported dtype: {0}")]
UnsupportedDType(String),
#[error("Unsupported encoding: {0}")]
UnsupportedEncoding(String),
#[error("Invalid file structure: {0}")]
InvalidFileStructure(String),
#[error("Data conversion error: {0}")]
DataConversionError(String),
#[error("Checksum mismatch for '{object_name}/{component_name}'. Expected: {expected}, Got: {calculated}")]
ChecksumMismatch {
object_name: String,
component_name: String,
expected: String,
calculated: String,
},
#[error("Checksum format error: {0}")]
ChecksumFormatError(String),
#[error("Unexpected end of file")]
UnexpectedEof,
#[error("Expected {expected} bytes, found {found} bytes")]
InconsistentDataSize { expected: u64, found: u64 },
#[error("Type mismatch in {context}: expected '{expected}', found '{found}'")]
TypeMismatch {
expected: String,
found: String,
context: String,
},
#[error("Manifest size {size} exceeds 1GB limit")]
ManifestTooLarge { size: u64 },
#[error("Object size {size} exceeds limit of {limit} (32GB)")]
ObjectTooLarge { size: u64, limit: u64 },
#[error("{0}")]
Other(String),
}