@@ -5,15 +5,14 @@ use futures::future::BoxFuture;
5
5
use serde:: { Deserialize , Serialize } ;
6
6
use std:: collections:: HashMap ;
7
7
use std:: convert:: From ;
8
- use std:: error:: Error ;
9
8
use std:: fmt;
10
9
11
- pub type AdapterResult < T , AE > = Result < T , AdapterError < AE > > ;
10
+ pub type AdapterResult < T , AE > = Result < T , Error < AE > > ;
12
11
13
12
pub trait AdapterErrorKind : fmt:: Debug + fmt:: Display { }
14
13
15
14
#[ derive( Debug ) ]
16
- pub enum AdapterError < AE : AdapterErrorKind > {
15
+ pub enum Error < AE : AdapterErrorKind > {
17
16
Authentication ( String ) ,
18
17
Authorization ( String ) ,
19
18
Configuration ( String ) ,
@@ -27,33 +26,33 @@ pub enum AdapterError<AE: AdapterErrorKind> {
27
26
LockedWallet ,
28
27
}
29
28
30
- impl < AE : AdapterErrorKind > Error for AdapterError < AE > { }
29
+ impl < AE : AdapterErrorKind > std :: error :: Error for Error < AE > { }
31
30
32
- impl < AE : AdapterErrorKind > From < AE > for AdapterError < AE > {
31
+ impl < AE : AdapterErrorKind > From < AE > for Error < AE > {
33
32
fn from ( adapter_err : AE ) -> Self {
34
33
Self :: Adapter ( adapter_err)
35
34
}
36
35
}
37
36
38
- impl < AE : AdapterErrorKind > fmt:: Display for AdapterError < AE > {
37
+ impl < AE : AdapterErrorKind > fmt:: Display for Error < AE > {
39
38
fn fmt ( & self , f : & mut fmt:: Formatter < ' _ > ) -> fmt:: Result {
40
39
match self {
41
- AdapterError :: Authentication ( error) => write ! ( f, "Authentication error: {}" , error) ,
42
- AdapterError :: Authorization ( error) => write ! ( f, "Authorization error: {}" , error) ,
43
- AdapterError :: Configuration ( error) => write ! ( f, "Configuration error: {}" , error) ,
44
- AdapterError :: Signature ( error) => write ! ( f, "Signature error: {}" , error) ,
45
- AdapterError :: InvalidChannel ( error) => write ! ( f, "{}" , error) ,
46
- AdapterError :: Failed ( error) => write ! ( f, "error: {}" , error) ,
47
- AdapterError :: Adapter ( error) => write ! ( f, "Adapter specific error: {}" , error) ,
48
- AdapterError :: Domain ( error) => write ! ( f, "Domain error: {}" , error) ,
49
- AdapterError :: LockedWallet => write ! ( f, "You must `.unlock()` the wallet first" ) ,
40
+ Error :: Authentication ( error) => write ! ( f, "Authentication error: {}" , error) ,
41
+ Error :: Authorization ( error) => write ! ( f, "Authorization error: {}" , error) ,
42
+ Error :: Configuration ( error) => write ! ( f, "Configuration error: {}" , error) ,
43
+ Error :: Signature ( error) => write ! ( f, "Signature error: {}" , error) ,
44
+ Error :: InvalidChannel ( error) => write ! ( f, "{}" , error) ,
45
+ Error :: Failed ( error) => write ! ( f, "error: {}" , error) ,
46
+ Error :: Adapter ( error) => write ! ( f, "Adapter specific error: {}" , error) ,
47
+ Error :: Domain ( error) => write ! ( f, "Domain error: {}" , error) ,
48
+ Error :: LockedWallet => write ! ( f, "You must `.unlock()` the wallet first" ) ,
50
49
}
51
50
}
52
51
}
53
52
54
- impl < AE : AdapterErrorKind > From < DomainError > for AdapterError < AE > {
55
- fn from ( err : DomainError ) -> AdapterError < AE > {
56
- AdapterError :: Domain ( err)
53
+ impl < AE : AdapterErrorKind > From < DomainError > for Error < AE > {
54
+ fn from ( err : DomainError ) -> Error < AE > {
55
+ Error :: Domain ( err)
57
56
}
58
57
}
59
58
@@ -76,7 +75,7 @@ pub struct Session {
76
75
}
77
76
78
77
pub trait Adapter : ChannelValidator + Send + Sync + Clone + fmt:: Debug {
79
- type AdapterError : AdapterErrorKind ;
78
+ type AdapterError : AdapterErrorKind + ' static ;
80
79
81
80
/// Unlock adapter
82
81
fn unlock ( & mut self ) -> AdapterResult < ( ) , Self :: AdapterError > ;
0 commit comments