use core::fmt;
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
#[non_exhaustive]
pub enum BlockModeError<E> {
NotInitialised,
BufferTooShort,
Cipher(E),
}
impl<E: core::error::Error> fmt::Display for BlockModeError<E> {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match self {
Self::NotInitialised => f.write_str("block cipher mode not initialised"),
Self::BufferTooShort => {
f.write_str("input or output buffer too short for block cipher mode")
}
Self::Cipher(error) => write!(f, "underlying block cipher error: {error}"),
}
}
}
impl<E: core::error::Error> core::error::Error for BlockModeError<E> {}