extern crate alloc;
#[derive(Debug)]
pub enum Error {
InvalidKeyLength,
InvalidDigestLength,
MaximumLengthExceeded,
InvalidChunkLength,
Unexpected,
}
impl alloc::fmt::Display for Error {
fn fmt(&self, f: &mut alloc::fmt::Formatter<'_>) -> alloc::fmt::Result {
let text = match self {
Error::InvalidKeyLength => "The used key length is invalid.",
Error::InvalidDigestLength => "The used digest length is invalid.",
Error::MaximumLengthExceeded => "The maximum input length is exceeded.",
Error::InvalidChunkLength => "The maximum chunk length is exceeded.",
Error::Unexpected => "An unexpected error has occurred.",
};
write!(f, "{text}")
}
}
#[cfg(not(feature = "std"))]
impl core::error::Error for Error {}
#[cfg(feature = "std")]
impl std::error::Error for Error {}