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("ACK CIF length {len} does not match Full (28), Small (16), or Light (4)")]
InvalidAckLength {
len: usize,
},
#[error("invalid NAK loss list: {reason}")]
InvalidLossList {
reason: &'static str,
},
#[error("handshake extension length {declared} * 4 bytes overruns {remaining} remaining")]
ExtensionOverrun {
declared: u16,
remaining: usize,
},
#[error("invalid Stream ID extension UTF-8")]
InvalidStreamIdUtf8,
#[error("invalid key material {field}: {reason}")]
InvalidKeyMaterial {
field: &'static str,
reason: &'static str,
},
#[error("wrong packet kind: expected {expected}")]
WrongPacketKind {
expected: &'static str,
},
#[error("reserved field {what} must be zero, found {value:#x}")]
ReservedFieldNotZero {
what: &'static str,
value: u64,
},
#[error("invalid {what}: {reason}")]
InvalidField {
what: &'static str,
reason: &'static str,
},
#[error("{what} has {extra} unexpected trailing byte(s)")]
UnexpectedTrailingBytes {
what: &'static str,
extra: usize,
},
}