1use crate::{Error, Result, SessionList};
2use async_trait::async_trait;
3use futures::Future;
4
5#[async_trait]
6pub trait Global<State: Clone, CState: Clone>: Send + Sync + 'static {
7 async fn call(&self, state: State, session_list: SessionList<CState>) -> Result<()>;
8}
9
10#[async_trait]
11impl<State, CState, F, Fut> Global<State, CState> for F
12where
13 State: Clone + Send + Sync + 'static,
14 CState: Clone + Send + Sync + 'static,
15 F: Send + Sync + 'static + Fn(State, SessionList<CState>) -> Fut,
16 Fut: Future<Output = std::result::Result<(), Error>> + Send + 'static,
17{
18 async fn call(&self, state: State, session_list: SessionList<CState>) -> Result<()> {
19 let fut = (self)(state.clone(), session_list.clone());
20
21 fut.await
22 }
23}