diff options
Diffstat (limited to 'src/update.rs')
-rw-r--r-- | src/update.rs | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/src/update.rs b/src/update.rs new file mode 100644 index 0000000..b2471da --- /dev/null +++ b/src/update.rs @@ -0,0 +1,18 @@ +use crate::client::Client; +use futures::future::BoxFuture; +use serde_json::value::Value; +use std::future::Future; + +pub trait Handler: Send + Sync + 'static { + fn handle_json(&self, _: Client, _: Value) -> BoxFuture<'static, ()>; +} + +impl<C, F> Handler for C +where + C: Send + Sync + 'static + Fn(Client, Value) -> F, + F: Future<Output = ()> + 'static + Send, +{ + fn handle_json(&self, client: Client, req: Value) -> BoxFuture<'static, ()> { + Box::pin((*self)(client, req)) + } +} |