Skip to main content
This is unreleased documentation for the main (development) branch of crypto-glue.

scrypt/
errors.rs

1use core::fmt;
2
3/// `scrypt()` error
4#[derive(Debug, Copy, Clone, Eq, PartialEq)]
5pub struct InvalidOutputLen;
6
7/// `ScryptParams` error
8#[derive(Debug, Copy, Clone, Eq, PartialEq)]
9pub struct InvalidParams;
10
11impl fmt::Display for InvalidOutputLen {
12    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
13        f.write_str("invalid output buffer length")
14    }
15}
16
17impl core::error::Error for InvalidOutputLen {}
18
19#[cfg(feature = "kdf")]
20impl From<InvalidOutputLen> for kdf::Error {
21    fn from(_err: InvalidOutputLen) -> kdf::Error {
22        kdf::Error
23    }
24}
25
26impl fmt::Display for InvalidParams {
27    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
28        f.write_str("invalid scrypt parameters")
29    }
30}
31
32impl core::error::Error for InvalidParams {}