1- #![ deny( clippy:: all) ]
2- #![ deny( rust_2018_idioms) ]
3-
41use primitives:: adapter:: { Adapter , AdapterError , AdapterOptions , AdapterResult , Session } ;
52use primitives:: channel_validator:: ChannelValidator ;
63use primitives:: config:: Config ;
@@ -23,9 +20,17 @@ impl Adapter for DummyAdapter {
2320 type Output = DummyAdapter ;
2421
2522 fn init ( opts : AdapterOptions , config : & Config ) -> AdapterResult < DummyAdapter > {
26- let identity = opts. dummy_identity . expect ( "dummyIdentity required" ) ;
27- let tokens_for_auth = opts. dummy_auth . expect ( "dummy auth required" ) ;
28- let tokens_verified = opts. dummy_auth_tokens . expect ( "dummy auth tokens required" ) ;
23+ let ( identity, tokens_for_auth, tokens_verified) =
24+ match ( opts. dummy_identity , opts. dummy_auth , opts. dummy_auth_tokens ) {
25+ ( Some ( identity) , Some ( tokens_for_auth) , Some ( tokens_verified) ) => {
26+ ( identity, tokens_for_auth, tokens_verified)
27+ }
28+ ( _, _, _) => {
29+ return Err ( AdapterError :: Configuration (
30+ "dummy_identity, dummy_auth, dummy_auth_tokens required" . to_string ( ) ,
31+ ) )
32+ }
33+ } ;
2934
3035 Ok ( Self {
3136 identity,
@@ -66,7 +71,7 @@ impl Adapter for DummyAdapter {
6671 fn validate_channel ( & self , channel : & Channel ) -> AdapterResult < bool > {
6772 match DummyAdapter :: is_channel_valid ( & self . config , channel) {
6873 Ok ( _) => Ok ( true ) ,
69- Err ( e) => Err ( AdapterError :: InvalidChannel ( format ! ( "{}" , e ) ) ) ,
74+ Err ( e) => Err ( AdapterError :: InvalidChannel ( e . to_string ( ) ) ) ,
7075 }
7176 }
7277
0 commit comments