|
| 1 | +use futures::future::BoxFuture; |
1 | 2 | use primitives::adapter::{Adapter, AdapterError, AdapterResult, DummyAdapterOptions, Session};
|
2 | 3 | use primitives::channel_validator::ChannelValidator;
|
3 | 4 | use primitives::config::Config;
|
@@ -63,29 +64,33 @@ 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(async move { |
| 69 | + match DummyAdapter::is_channel_valid(&self.config, self.whoami(), channel) { |
| 70 | + Ok(_) => Ok(true), |
| 71 | + Err(e) => Err(AdapterError::InvalidChannel(e.to_string())), |
| 72 | + } |
| 73 | + }) |
71 | 74 | }
|
72 | 75 |
|
73 |
| - fn session_from_token(&self, token: &str) -> AdapterResult<Session> { |
74 |
| - let identity = self |
75 |
| - .authorization_tokens |
76 |
| - .iter() |
77 |
| - .find(|(_, id)| *id == token); |
| 76 | + fn session_from_token<'a>(&'a self, token: &'a str) -> BoxFuture<'a, AdapterResult<Session>> { |
| 77 | + Box::pin(async move { |
| 78 | + let identity = self |
| 79 | + .authorization_tokens |
| 80 | + .iter() |
| 81 | + .find(|(_, id)| *id == token); |
78 | 82 |
|
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 |
| - } |
| 83 | + match identity { |
| 84 | + Some((id, _)) => Ok(Session { |
| 85 | + uid: self.session_tokens[id].clone(), |
| 86 | + era: 0, |
| 87 | + }), |
| 88 | + None => Err(AdapterError::Authentication(format!( |
| 89 | + "no session token for this auth: {}", |
| 90 | + token |
| 91 | + ))), |
| 92 | + } |
| 93 | + }) |
89 | 94 | }
|
90 | 95 |
|
91 | 96 | fn get_auth(&self, _validator: &ValidatorId) -> AdapterResult<String> {
|
|
0 commit comments