diff --git a/actix-ioframe/CHANGES.md b/actix-ioframe/CHANGES.md index 03d710b7..17b79828 100644 --- a/actix-ioframe/CHANGES.md +++ b/actix-ioframe/CHANGES.md @@ -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 diff --git a/actix-ioframe/Cargo.toml b/actix-ioframe/Cargo.toml index 1fb4438d..4bfde348 100644 --- a/actix-ioframe/Cargo.toml +++ b/actix-ioframe/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "actix-ioframe" -version = "0.4.0" +version = "0.4.1" authors = ["Nikolay Kim "] 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" diff --git a/actix-ioframe/src/dispatcher.rs b/actix-ioframe/src/dispatcher.rs index 965215f7..8cb22c3a 100644 --- a/actix-ioframe/src/dispatcher.rs +++ b/actix-ioframe/src/dispatcher.rs @@ -43,7 +43,7 @@ where framed: Framed, rx: mpsc::Receiver::Item>, S::Error>>, tx: mpsc::Sender::Item>, S::Error>>, - disconnect: Option>, + disconnect: Option>, } impl Dispatcher @@ -63,7 +63,7 @@ where service: F, sink: Sink<::Item>, rx: mpsc::Receiver::Item>, S::Error>>, - disconnect: Option>, + disconnect: Option>, ) -> 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(())) } diff --git a/actix-ioframe/src/service.rs b/actix-ioframe/src/service.rs index ee781970..a6863a30 100644 --- a/actix-ioframe/src/service.rs +++ b/actix-ioframe/src/service.rs @@ -75,7 +75,7 @@ impl Builder { pub struct ServiceBuilder { connect: C, - disconnect: Option>, + disconnect: Option>, _t: PhantomData<(St, Io, Codec)>, } @@ -93,7 +93,7 @@ where /// Second parameter indicates error occured during disconnect. pub fn disconnect(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 { connect: C, - disconnect: Option>, + disconnect: Option>, _t: PhantomData<(St, Io, Codec)>, } @@ -146,7 +146,7 @@ where /// Second parameter indicates error occured during disconnect. pub fn disconnect(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 { connect: C, handler: Rc, - disconnect: Option>, + disconnect: Option>, _t: PhantomData<(St, Io, Codec, Cfg)>, } @@ -232,7 +232,7 @@ where pub struct FramedServiceImpl { connect: C, handler: Rc, - disconnect: Option>, + disconnect: Option>, _t: PhantomData<(St, Io, Codec)>, } @@ -359,13 +359,13 @@ where Connect( #[pin] C::Future, Rc, - Option>, + Option>, Option>>, ), Handler( #[pin] T::Future, Option>, - Option>, + Option>, Option>>, ), Dispatcher(Dispatcher),