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("field {what} value {value} does not fit in {bits} bits")]
FieldTooWide {
what: &'static str,
value: u64,
bits: u32,
},
#[error("invalid field {what}: {reason}")]
InvalidField {
what: &'static str,
reason: &'static str,
},
#[error("invalid header extension: {reason}")]
InvalidExtension {
reason: &'static str,
},
#[error("inconsistent length {length}: {reason}")]
InconsistentLength {
length: u8,
reason: &'static str,
},
}