use thiserror::Error;
pub type Result<T> = core::result::Result<T, Error>;
#[derive(Debug, Error, PartialEq, Eq)]
#[non_exhaustive]
pub enum Error {
#[error("buffer too short: need {need} bytes, have {have} (while parsing {what})")]
BufferTooShort {
need: usize,
have: usize,
what: &'static str,
},
#[error("largesize indicated but buffer too short: need {need}, have {have}")]
LargesizeBufferTooShort {
need: usize,
have: usize,
},
#[error("uuid box indicated but buffer too short: need {need}, have {have}")]
UuidBufferTooShort {
need: usize,
have: usize,
},
#[error("box size {size} is smaller than header ({header_size} bytes)")]
BoxSizeUnderflow {
size: u64,
header_size: usize,
},
#[error("serialize: output buffer too small — need {need}, have {have}")]
OutputBufferTooSmall {
need: usize,
have: usize,
},
#[error("invalid {field}: {reason} (value: 0x{value:X})")]
InvalidValue {
field: &'static str,
value: u64,
reason: &'static str,
},
#[error("unexpected box: expected {expected}")]
UnexpectedBox {
expected: &'static str,
},
}