blob: 7f5e28da8569b6b94565e5d8f0a5a67e5d5f0356 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
|
use std::future::Future;
use futures::future::BoxFuture;
use crate::client::Client;
use pert_types::types::Update;
pub trait Handler: Send + Sync + 'static {
fn handle(&self, _: Client, _: Update) -> BoxFuture<'static, ()>;
}
impl<C, F> Handler for C
where C: Send + Sync + 'static + Fn(Client, Update) -> F,
F: Future<Output = ()> + 'static + Send {
fn handle(&self, client: Client, req: Update) -> BoxFuture<'static, ()> {
Box::pin((*self)(client, req))
}
}
|