From 922a919572d349b6c574855a278dee5ac1b829f2 Mon Sep 17 00:00:00 2001 From: Nikolay Kim Date: Tue, 2 Jul 2019 12:35:27 +0600 Subject: [PATCH] simple callback --- actix-ioframe/src/service.rs | 20 +++++--------------- 1 file changed, 5 insertions(+), 15 deletions(-) diff --git a/actix-ioframe/src/service.rs b/actix-ioframe/src/service.rs index 0e32c4c3..543abfc9 100644 --- a/actix-ioframe/src/service.rs +++ b/actix-ioframe/src/service.rs @@ -81,14 +81,9 @@ where /// Second parameter indicates error occured during disconnect. pub fn disconnect(mut self, disconnect: F) -> Self where - F: Fn(&mut St, bool) -> Out + 'static, - Out: IntoFuture, - Out::Future: 'static, + F: Fn(&mut St, bool) + 'static, { - self.disconnect = Some(Rc::new(move |st, error| { - let fut = disconnect(st, error).into_future(); - tokio_current_thread::spawn(fut.map_err(|_| ()).map(|_| ())); - })); + self.disconnect = Some(Rc::new(disconnect)); self } @@ -136,16 +131,11 @@ where /// Callback to execute on disconnect /// /// Second parameter indicates error occured during disconnect. - pub fn disconnect(mut self, disconnect: F) -> Self + pub fn disconnect(mut self, disconnect: F) -> Self where - F: Fn(&mut St, bool) -> Out + 'static, - Out: IntoFuture, - Out::Future: 'static, + F: Fn(&mut St, bool) + 'static, { - self.disconnect = Some(Rc::new(move |st, error| { - let fut = disconnect(st, error).into_future(); - tokio_current_thread::spawn(fut.map_err(|_| ()).map(|_| ())); - })); + self.disconnect = Some(Rc::new(disconnect)); self }