1use core::fmt;
2
3#[derive(Debug, Clone, PartialEq, Eq)]
5pub enum Error {
6 InvalidLength {
8 expected: usize,
10 actual: usize,
12 },
13}
14
15pub type Result<T> = core::result::Result<T, Error>;
17
18impl fmt::Display for Error {
19 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
20 match self {
21 Self::InvalidLength { expected, actual } => {
22 write!(
23 f,
24 "buffer too small: expected at least {expected} bytes, got {actual}"
25 )
26 }
27 }
28 }
29}
30
31impl std::error::Error for Error {}