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("invalid data_unit_length {length} for data_unit_id {id:#04X}: {reason}")]
InvalidDataUnitLength {
length: u8,
id: u8,
reason: &'static str,
},
#[error("field {what} value {value} does not fit in {bits} bits")]
FieldTooWide {
what: &'static str,
value: u32,
bits: u32,
},
#[error("invalid field {what}: {reason}")]
InvalidField {
what: &'static str,
reason: &'static str,
},
}