mirror of
https://github.com/fafhrd91/actix-net
synced 2024-11-24 03:42:59 +01:00
Disconnect callback accepts owned state
This commit is contained in:
parent
8bb81c0768
commit
081205a02f
@ -1,6 +1,10 @@
|
||||
# Changes
|
||||
|
||||
## [0.4.0] - 2019-12-1
|
||||
## [0.4.1] - 2019-12-11
|
||||
|
||||
* Disconnect callback accepts owned state
|
||||
|
||||
## [0.4.0] - 2019-12-11
|
||||
|
||||
* Remove `E` param
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "actix-ioframe"
|
||||
version = "0.4.0"
|
||||
version = "0.4.1"
|
||||
authors = ["Nikolay Kim <fafhrd91@gmail.com>"]
|
||||
description = "Actix framed service"
|
||||
keywords = ["network", "framework", "async", "futures"]
|
||||
@ -19,7 +19,7 @@ path = "src/lib.rs"
|
||||
[dependencies]
|
||||
actix-service = "1.0.0"
|
||||
actix-codec = "0.2.0"
|
||||
actix-utils = "1.0.0"
|
||||
actix-utils = "1.0.1"
|
||||
actix-rt = "1.0.0"
|
||||
bytes = "0.5"
|
||||
either = "1.5.2"
|
||||
|
@ -43,7 +43,7 @@ where
|
||||
framed: Framed<T, U>,
|
||||
rx: mpsc::Receiver<Result<Message<<U as Encoder>::Item>, S::Error>>,
|
||||
tx: mpsc::Sender<Result<Message<<U as Encoder>::Item>, S::Error>>,
|
||||
disconnect: Option<Rc<dyn Fn(&mut St, bool)>>,
|
||||
disconnect: Option<Rc<dyn Fn(St, bool)>>,
|
||||
}
|
||||
|
||||
impl<St, S, T, U> Dispatcher<St, S, T, U>
|
||||
@ -63,7 +63,7 @@ where
|
||||
service: F,
|
||||
sink: Sink<<U as Encoder>::Item>,
|
||||
rx: mpsc::Receiver<Result<Message<<U as Encoder>::Item>, S::Error>>,
|
||||
disconnect: Option<Rc<dyn Fn(&mut St, bool)>>,
|
||||
disconnect: Option<Rc<dyn Fn(St, bool)>>,
|
||||
) -> Self {
|
||||
let tx = rx.sender();
|
||||
|
||||
@ -245,7 +245,7 @@ where
|
||||
}
|
||||
}
|
||||
if let Some(ref disconnect) = self.disconnect {
|
||||
(&*disconnect)(&mut self.state, true);
|
||||
(&*disconnect)(self.state.clone(), true);
|
||||
}
|
||||
Poll::Ready(Err(self.dispatch_state.take_error()))
|
||||
}
|
||||
@ -265,19 +265,19 @@ where
|
||||
let _ = tx.send(());
|
||||
}
|
||||
if let Some(ref disconnect) = self.disconnect {
|
||||
(&*disconnect)(&mut self.state, false);
|
||||
(&*disconnect)(self.state.clone(), false);
|
||||
}
|
||||
Poll::Ready(Ok(()))
|
||||
}
|
||||
FramedState::FramedError(_) => {
|
||||
if let Some(ref disconnect) = self.disconnect {
|
||||
(&*disconnect)(&mut self.state, true);
|
||||
(&*disconnect)(self.state.clone(), true);
|
||||
}
|
||||
Poll::Ready(Err(self.dispatch_state.take_framed_error()))
|
||||
}
|
||||
FramedState::Stopping => {
|
||||
if let Some(ref disconnect) = self.disconnect {
|
||||
(&*disconnect)(&mut self.state, false);
|
||||
(&*disconnect)(self.state.clone(), false);
|
||||
}
|
||||
Poll::Ready(Ok(()))
|
||||
}
|
||||
|
@ -75,7 +75,7 @@ impl<St: Clone, Codec> Builder<St, Codec> {
|
||||
|
||||
pub struct ServiceBuilder<St, C, Io, Codec> {
|
||||
connect: C,
|
||||
disconnect: Option<Rc<dyn Fn(&mut St, bool)>>,
|
||||
disconnect: Option<Rc<dyn Fn(St, bool)>>,
|
||||
_t: PhantomData<(St, Io, Codec)>,
|
||||
}
|
||||
|
||||
@ -93,7 +93,7 @@ where
|
||||
/// Second parameter indicates error occured during disconnect.
|
||||
pub fn disconnect<F, Out>(mut self, disconnect: F) -> Self
|
||||
where
|
||||
F: Fn(&mut St, bool) + 'static,
|
||||
F: Fn(St, bool) + 'static,
|
||||
{
|
||||
self.disconnect = Some(Rc::new(disconnect));
|
||||
self
|
||||
@ -122,7 +122,7 @@ where
|
||||
|
||||
pub struct NewServiceBuilder<St, C, Io, Codec> {
|
||||
connect: C,
|
||||
disconnect: Option<Rc<dyn Fn(&mut St, bool)>>,
|
||||
disconnect: Option<Rc<dyn Fn(St, bool)>>,
|
||||
_t: PhantomData<(St, Io, Codec)>,
|
||||
}
|
||||
|
||||
@ -146,7 +146,7 @@ where
|
||||
/// Second parameter indicates error occured during disconnect.
|
||||
pub fn disconnect<F>(mut self, disconnect: F) -> Self
|
||||
where
|
||||
F: Fn(&mut St, bool) + 'static,
|
||||
F: Fn(St, bool) + 'static,
|
||||
{
|
||||
self.disconnect = Some(Rc::new(disconnect));
|
||||
self
|
||||
@ -175,7 +175,7 @@ where
|
||||
pub struct FramedService<St, C, T, Io, Codec, Cfg> {
|
||||
connect: C,
|
||||
handler: Rc<T>,
|
||||
disconnect: Option<Rc<dyn Fn(&mut St, bool)>>,
|
||||
disconnect: Option<Rc<dyn Fn(St, bool)>>,
|
||||
_t: PhantomData<(St, Io, Codec, Cfg)>,
|
||||
}
|
||||
|
||||
@ -232,7 +232,7 @@ where
|
||||
pub struct FramedServiceImpl<St, C, T, Io, Codec> {
|
||||
connect: C,
|
||||
handler: Rc<T>,
|
||||
disconnect: Option<Rc<dyn Fn(&mut St, bool)>>,
|
||||
disconnect: Option<Rc<dyn Fn(St, bool)>>,
|
||||
_t: PhantomData<(St, Io, Codec)>,
|
||||
}
|
||||
|
||||
@ -359,13 +359,13 @@ where
|
||||
Connect(
|
||||
#[pin] C::Future,
|
||||
Rc<T>,
|
||||
Option<Rc<dyn Fn(&mut St, bool)>>,
|
||||
Option<Rc<dyn Fn(St, bool)>>,
|
||||
Option<mpsc::Receiver<ServiceResult<Codec, C::Error>>>,
|
||||
),
|
||||
Handler(
|
||||
#[pin] T::Future,
|
||||
Option<ConnectResult<Io, St, Codec>>,
|
||||
Option<Rc<dyn Fn(&mut St, bool)>>,
|
||||
Option<Rc<dyn Fn(St, bool)>>,
|
||||
Option<mpsc::Receiver<ServiceResult<Codec, C::Error>>>,
|
||||
),
|
||||
Dispatcher(Dispatcher<St, T::Service, Io, Codec>),
|
||||
|
Loading…
Reference in New Issue
Block a user