pub type Result<T> = core::result::Result<T, Error>;
#[derive(Debug, Clone, PartialEq, Eq, thiserror::Error)]
#[non_exhaustive]
pub enum Error {
#[error("buffer too short: need {need}, have {have} ({what})")]
BufferTooShort {
need: usize,
have: usize,
what: &'static str,
},
#[error("output buffer too small: need {need}, have {have}")]
OutputBufferTooSmall {
need: usize,
have: usize,
},
#[error("not an emsg box: type {found:?}")]
NotEmsg {
found: [u8; 4],
},
#[error("invalid emsg box size {size}: {reason}")]
InvalidSize {
size: u32,
reason: &'static str,
},
#[error("unsupported emsg version {version} (expected 0 or 1)")]
UnsupportedVersion {
version: u8,
},
#[error("invalid {field} string: {reason}")]
InvalidString {
field: &'static str,
reason: &'static str,
},
#[error("field {what} value {value} does not fit in {bits} bits")]
FieldTooWide {
what: &'static str,
value: u64,
bits: u32,
},
}