bcrypt_pbkdf/
errors.rs

1use core::fmt;
2
3/// `bcrypt_pbkdf` error
4#[derive(Clone, Copy, Debug, PartialEq, Eq)]
5pub enum Error {
6    /// An input parameter has an invalid length.
7    InvalidParamLen,
8    /// An invalid number of rounds was specified.
9    InvalidRounds,
10    /// The output parameter has an invalid length.
11    InvalidOutputLen,
12    /// The manually provided memory was not long enough.
13    InvalidMemoryLen,
14}
15
16impl fmt::Display for Error {
17    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
18        match self {
19            Error::InvalidParamLen => write!(f, "Invalid parameter length"),
20            Error::InvalidRounds => write!(f, "Invalid number of rounds"),
21            Error::InvalidOutputLen => write!(f, "Invalid output length"),
22            Error::InvalidMemoryLen => write!(f, "Invalid memory length"),
23        }
24    }
25}
26
27#[cfg(feature = "std")]
28impl std::error::Error for Error {}