#[derive(Debug, Clone, PartialEq, Eq, thiserror::Error)]
#[non_exhaustive]
pub enum Error {
#[error("{what} truncated: needed {needed} bytes, {available} available")]
Truncated {
what: &'static str,
needed: u64,
available: u64,
},
#[error("{what} is format version {version}, which this build does not read")]
UnsupportedVersion {
what: &'static str,
version: u8,
},
#[error("{what} of {size} bytes exceeds the limit of {limit} bytes")]
TooLarge {
what: &'static str,
size: u64,
limit: u64,
},
#[error("{what} is malformed: {reason}")]
Malformed {
what: &'static str,
reason: &'static str,
},
#[error("{what} failed authentication: wrong key, or the bytes were changed")]
Unauthenticated {
what: &'static str,
},
}
pub type Result<T> = std::result::Result<T, Error>;