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