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)) } }