1use std::sync::Arc;
2
3use async_trait::async_trait;
4use shield::{Method, MethodAction, ShieldError, Storage, User, erased_method};
5
6use crate::{actions::DummySignInAction, provider::DummyProvider};
7
8pub const DUMMY_METHOD_ID: &str = "dummy";
9
10pub struct DummyMethod<U: User> {
11 storage: Arc<dyn Storage<U>>,
12}
13
14impl<U: User> DummyMethod<U> {
15 pub fn new<S: Storage<U> + 'static>(storage: S) -> Self {
16 Self {
17 storage: Arc::new(storage),
18 }
19 }
20}
21
22#[async_trait]
23impl<U: User + 'static> Method for DummyMethod<U> {
24 type Provider = DummyProvider;
25 type Session = ();
26
27 fn id(&self) -> String {
28 DUMMY_METHOD_ID.to_owned()
29 }
30
31 fn actions(&self) -> Vec<Box<dyn MethodAction<Self::Provider, Self::Session>>> {
32 vec![Box::new(DummySignInAction::new(self.storage.clone()))]
33 }
34
35 async fn providers(&self) -> Result<Vec<Self::Provider>, ShieldError> {
36 Ok(vec![DummyProvider])
37 }
38}
39
40erased_method!(DummyMethod, <U: User>);