@@ -2,8 +2,6 @@ use std::error;
2
2
use std:: fmt;
3
3
use std:: io;
4
4
5
- use crate :: lib_bcrypt:: { MAX_COST , MIN_COST } ;
6
-
7
5
/// Library generic result type.
8
6
pub type BcryptResult < T > = Result < T , BcryptError > ;
9
7
@@ -12,13 +10,10 @@ pub type BcryptResult<T> = Result<T, BcryptError>;
12
10
/// passwords
13
11
pub enum BcryptError {
14
12
Io ( io:: Error ) ,
15
- CostNotAllowed ( u32 ) ,
16
- InvalidPassword ,
17
13
InvalidVersion ( String ) ,
18
14
InvalidCost ( String ) ,
19
15
InvalidPrefix ( String ) ,
20
16
InvalidHash ( String ) ,
21
- DecodeError ( char , String ) ,
22
17
Rand ( rand:: Error ) ,
23
18
}
24
19
@@ -40,18 +35,9 @@ impl fmt::Display for BcryptError {
40
35
match * self {
41
36
BcryptError :: Io ( ref err) => write ! ( f, "IO error: {}" , err) ,
42
37
BcryptError :: InvalidCost ( ref cost) => write ! ( f, "Invalid Cost: {}" , cost) ,
43
- BcryptError :: CostNotAllowed ( ref cost) => write ! (
44
- f,
45
- "Cost needs to be between {} and {}, got {}" ,
46
- MIN_COST , MAX_COST , cost
47
- ) ,
48
- BcryptError :: InvalidPassword => write ! ( f, "Invalid password: contains NULL byte" ) ,
49
38
BcryptError :: InvalidVersion ( ref v) => write ! ( f, "Invalid version: {}" , v) ,
50
39
BcryptError :: InvalidPrefix ( ref prefix) => write ! ( f, "Invalid Prefix: {}" , prefix) ,
51
40
BcryptError :: InvalidHash ( ref hash) => write ! ( f, "Invalid hash: {}" , hash) ,
52
- BcryptError :: DecodeError ( ref c, ref s) => {
53
- write ! ( f, "Invalid base64 error in {}, char {}" , c, s)
54
- }
55
41
BcryptError :: Rand ( ref err) => write ! ( f, "Rand error: {}" , err) ,
56
42
}
57
43
}
@@ -62,11 +48,8 @@ impl error::Error for BcryptError {
62
48
match * self {
63
49
BcryptError :: Io ( ref err) => Some ( err) ,
64
50
BcryptError :: InvalidCost ( _)
65
- | BcryptError :: CostNotAllowed ( _)
66
- | BcryptError :: InvalidPassword
67
51
| BcryptError :: InvalidVersion ( _)
68
52
| BcryptError :: InvalidPrefix ( _)
69
- | BcryptError :: DecodeError ( _, _)
70
53
| BcryptError :: InvalidHash ( _) => None ,
71
54
BcryptError :: Rand ( ref err) => Some ( err) ,
72
55
}
0 commit comments