inout/
errors.rs

1use core::fmt;
2
3/// The error returned when slice can not be converted into array.
4#[derive(Copy, Clone, Debug)]
5pub struct IntoArrayError;
6
7impl fmt::Display for IntoArrayError {
8    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> Result<(), fmt::Error> {
9        f.write_str("Failed to convert into array.")
10    }
11}
12
13impl core::error::Error for IntoArrayError {}
14
15/// The error returned when input and output slices have different length
16/// and thus can not be converted to `InOutBuf`.
17#[derive(Copy, Clone, Debug)]
18pub struct NotEqualError;
19
20impl fmt::Display for NotEqualError {
21    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> Result<(), fmt::Error> {
22        f.write_str("Length of input slices is not equal to each other")
23    }
24}
25
26impl core::error::Error for NotEqualError {}
27
28/// Padding error. Usually emitted when size of output buffer is insufficient.
29#[cfg(feature = "block-padding")]
30#[derive(Clone, Copy, Debug)]
31pub struct PadError;
32
33#[cfg(feature = "block-padding")]
34impl fmt::Display for PadError {
35    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> Result<(), fmt::Error> {
36        f.write_str("Padding error")
37    }
38}
39
40#[cfg(feature = "block-padding")]
41impl core::error::Error for PadError {}
42
43/// Output buffer is smaller than input buffer.
44#[derive(Clone, Copy, Debug)]
45pub struct OutIsTooSmallError;
46
47impl fmt::Display for OutIsTooSmallError {
48    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> Result<(), fmt::Error> {
49        f.write_str("Output buffer is smaller than input")
50    }
51}
52
53impl core::error::Error for OutIsTooSmallError {}