use thiserror::Error;
pub type Result<T> = std::result::Result<T, Error>;
#[derive(Debug, Error)]
#[non_exhaustive]
pub enum Error {
#[error("invalid metadata signature: expected 0x424A5342, got 0x{0:08X}")]
InvalidSignature(u32),
#[error("unexpected end of data at offset {offset}, needed {needed} bytes")]
UnexpectedEof {
offset: usize,
needed: usize,
},
#[error("invalid stream name at offset {0}")]
InvalidStreamName(usize),
#[error("stream not found: {0}")]
StreamNotFound(String),
#[error("invalid UTF-8 string at offset {0}")]
InvalidString(usize),
#[error("invalid UTF-16 string at offset {0}")]
InvalidUserString(usize),
#[error("invalid table ID: {0}")]
InvalidTableId(u8),
#[error("invalid coded index for {kind}: {value}")]
InvalidCodedIndex {
kind: &'static str,
value: u32,
},
#[error("invalid compressed integer at offset {0}")]
InvalidCompressedInt(usize),
#[error("invalid GUID index: {0}")]
InvalidGuidIndex(u32),
#[error("invalid blob at offset {0}")]
InvalidBlob(usize),
#[error("table {table} row index {index} out of bounds (max {max})")]
RowIndexOutOfBounds {
table: &'static str,
index: u32,
max: u32,
},
#[error("validation error: {0}")]
ValidationError(String),
}