1
0
mirror of https://github.com/fafhrd91/actix-net synced 2024-11-23 21:51:06 +01:00

simple callback

This commit is contained in:
Nikolay Kim 2019-07-02 12:35:27 +06:00
parent 5a62175b6e
commit 922a919572

View File

@ -81,14 +81,9 @@ where
/// Second parameter indicates error occured during disconnect.
pub fn disconnect<F, Out>(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<F, Out>(mut self, disconnect: F) -> Self
pub fn disconnect<F>(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
}