From 7e41b162fb1a41d026814c7e4586aa6f6a627fbb Mon Sep 17 00:00:00 2001 From: syn Date: Fri, 8 Jan 2021 01:21:48 +0300 Subject: Initial commit --- src/update.rs | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 src/update.rs (limited to 'src/update.rs') 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 Handler for C +where + C: Send + Sync + 'static + Fn(Client, Value) -> F, + F: Future + 'static + Send, +{ + fn handle_json(&self, client: Client, req: Value) -> BoxFuture<'static, ()> { + Box::pin((*self)(client, req)) + } +} -- cgit v1.2.1-18-gbd029