1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
use std::fmt::Formatter;
#[derive(Debug)]
pub enum Error {
InvalidDerivedKeyLen,
InvalidBufferLength(String),
ImplementationError(String),
InvalidKeySize(String),
}
impl std::fmt::Display for Error {
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
match self {
Error::InvalidDerivedKeyLen => write!(f, "Derived key length is invalid"),
Error::InvalidBufferLength(e) => write!(f, "Invalid output buffer provided: {}", e),
Error::ImplementationError(e) => write!(f, "{}", e),
Error::InvalidKeySize(e) => write!(f, "Invalid key size provided: {}", e),
}
}
}
impl std::error::Error for Error {}