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