block_modes/
errors.rs

1use core::fmt;
2#[cfg(feature = "std")]
3use std::error;
4
5/// Block mode error.
6#[derive(Clone, Copy, Debug)]
7pub struct BlockModeError;
8
9/// Invalid key or IV length error.
10#[derive(Clone, Copy, Debug)]
11pub struct InvalidKeyIvLength;
12
13impl fmt::Display for BlockModeError {
14    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> Result<(), fmt::Error> {
15        f.write_str("BlockModeError")
16    }
17}
18
19#[cfg(feature = "std")]
20impl error::Error for BlockModeError {
21    fn description(&self) -> &str {
22        "block mode error"
23    }
24}
25
26impl fmt::Display for InvalidKeyIvLength {
27    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> Result<(), fmt::Error> {
28        f.write_str("InvalidKeyIvLength")
29    }
30}
31
32#[cfg(feature = "std")]
33impl error::Error for InvalidKeyIvLength {}