use core::fmt;
#[derive(Copy, Clone, Hash, Debug, PartialEq, Eq)]
pub enum Error {
InvalidDataSize,
InvalidOutputSize {
expected_len: usize,
},
IntegrityCheckFailed,
}
impl fmt::Display for Error {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match self {
Error::InvalidDataSize => f.write_str("data must be a multiple of 64 bits for AES-KW and less than 2^32 bytes for AES-KWP"),
Error::InvalidOutputSize { expected_len: expected } => {
write!(f, "invalid output buffer size: expected {}", expected)
}
Error::IntegrityCheckFailed => f.write_str("integrity check failed"),
}
}
}
impl core::error::Error for Error {}
#[derive(Clone, Copy, Debug)]
pub struct IntegrityCheckFailed;
impl fmt::Display for IntegrityCheckFailed {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
f.write_str("integrity check failed")
}
}
impl core::error::Error for IntegrityCheckFailed {}