@@ -3,6 +3,7 @@ use primitives::channel_validator::ChannelValidator;
3
3
use primitives:: config:: Config ;
4
4
use primitives:: { Channel , ValidatorId } ;
5
5
use std:: collections:: HashMap ;
6
+ use futures:: future:: BoxFuture ;
6
7
7
8
#[ derive( Debug , Clone ) ]
8
9
pub struct DummyAdapter {
@@ -63,29 +64,38 @@ impl Adapter for DummyAdapter {
63
64
Ok ( is_same)
64
65
}
65
66
66
- fn validate_channel ( & self , channel : & Channel ) -> AdapterResult < bool > {
67
- match DummyAdapter :: is_channel_valid ( & self . config , self . whoami ( ) , channel) {
68
- Ok ( _) => Ok ( true ) ,
69
- Err ( e) => Err ( AdapterError :: InvalidChannel ( e. to_string ( ) ) ) ,
70
- }
67
+ fn validate_channel < ' a > ( & ' a self , channel : & ' a Channel ) -> BoxFuture < ' a , AdapterResult < bool > > {
68
+ Box :: pin (
69
+ async move {
70
+ match DummyAdapter :: is_channel_valid ( & self . config , self . whoami ( ) , channel) {
71
+ Ok ( _) => Ok ( true ) ,
72
+ Err ( e) => Err ( AdapterError :: InvalidChannel ( e. to_string ( ) ) ) ,
73
+ }
74
+ }
75
+ )
76
+
71
77
}
72
78
73
- fn session_from_token ( & self , token : & str ) -> AdapterResult < Session > {
74
- let identity = self
75
- . authorization_tokens
76
- . iter ( )
77
- . find ( |( _, id) | * id == token) ;
78
-
79
- match identity {
80
- Some ( ( id, _) ) => Ok ( Session {
81
- uid : self . session_tokens [ id] . clone ( ) ,
82
- era : 0 ,
83
- } ) ,
84
- None => Err ( AdapterError :: Authentication ( format ! (
85
- "no session token for this auth: {}" ,
86
- token
87
- ) ) ) ,
88
- }
79
+ fn session_from_token < ' a > ( & ' a self , token : & ' a str ) -> BoxFuture < ' a , AdapterResult < Session > > {
80
+ Box :: pin (
81
+ async move {
82
+ let identity = self
83
+ . authorization_tokens
84
+ . iter ( )
85
+ . find ( |( _, id) | * id == token) ;
86
+
87
+ match identity {
88
+ Some ( ( id, _) ) => Ok ( Session {
89
+ uid : self . session_tokens [ id] . clone ( ) ,
90
+ era : 0 ,
91
+ } ) ,
92
+ None => Err ( AdapterError :: Authentication ( format ! (
93
+ "no session token for this auth: {}" ,
94
+ token
95
+ ) ) ) ,
96
+ }
97
+ }
98
+ )
89
99
}
90
100
91
101
fn get_auth ( & self , _validator : & ValidatorId ) -> AdapterResult < String > {
0 commit comments