use core::fmt;
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
#[non_exhaustive]
pub enum InitError {
InvalidKeyLength(usize),
InvalidEffectiveKeyBits(usize),
InvalidSBoxLength(usize),
InvalidTweakLength(usize),
InvalidRounds(usize),
}
impl fmt::Display for InitError {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match self {
Self::InvalidKeyLength(bytes) => {
write!(f, "invalid cipher key length: {bytes} bytes")
}
Self::InvalidEffectiveKeyBits(bits) => {
write!(f, "invalid effective cipher key size: {bits} bits")
}
Self::InvalidSBoxLength(bytes) => {
write!(f, "invalid cipher s-box length: {bytes} bytes")
}
Self::InvalidTweakLength(bytes) => {
write!(f, "invalid cipher tweak length: {bytes} bytes")
}
Self::InvalidRounds(rounds) => {
write!(f, "invalid cipher round count: {rounds}")
}
}
}
}
impl core::error::Error for InitError {}