Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- use futures::future::BoxFuture;
- pub trait Handler: Send {
- fn dispatch(&mut self, req: bson::Document) -> BoxFuture<'static, Result<bson::Document, KRPCError>>;
- }
- // Convenience implementation to use Arc<Mutex<H>> as handlers.
- impl<H> Handler for Arc<Mutex<H>>
- where
- H: Handler + Send,
- {
- fn dispatch(&mut self, req: bson::Document) -> BoxFuture<'static, Result<bson::Document, KRPCError>> {
- async move {
- let lock = await!(self.lock());
- await!(lock.dispatch(req))
- }
- .boxed()
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement