From 9f575418c1a7926ac1b74206ffa4261958e1f752 Mon Sep 17 00:00:00 2001 From: Nikolay Kim Date: Mon, 2 Dec 2019 22:30:09 +0600 Subject: [PATCH] clippy warnings --- actix-codec/CHANGES.md | 5 ++ actix-codec/Cargo.toml | 6 +-- actix-codec/src/framed.rs | 22 +++++--- actix-codec/src/lib.rs | 2 + actix-connect/CHANGES.md | 7 +++ actix-connect/Cargo.toml | 14 ++--- actix-connect/src/connect.rs | 6 +-- actix-connect/src/connector.rs | 4 +- actix-connect/src/lib.rs | 9 ++-- actix-connect/src/resolver.rs | 4 +- actix-connect/src/service.rs | 12 ++--- actix-connect/src/ssl/openssl.rs | 12 ++--- actix-ioframe/CHANGES.md | 4 ++ actix-ioframe/Cargo.toml | 16 +++--- actix-ioframe/src/cell.rs | 2 +- actix-ioframe/src/connect.rs | 4 +- actix-ioframe/src/dispatcher.rs | 8 +-- actix-ioframe/src/error.rs | 4 +- actix-ioframe/src/item.rs | 2 +- actix-ioframe/src/lib.rs | 3 ++ actix-ioframe/src/service.rs | 12 +++-- actix-ioframe/src/sink.rs | 2 +- actix-rt/CHANGES.md | 4 +- actix-rt/src/arbiter.rs | 2 +- actix-rt/src/lib.rs | 2 + actix-rt/src/runtime.rs | 2 +- actix-server/CHANGES.md | 4 +- actix-server/Cargo.toml | 8 +-- actix-server/src/config.rs | 8 +-- actix-server/src/counter.rs | 81 ---------------------------- actix-server/src/lib.rs | 3 +- actix-server/src/server.rs | 2 +- actix-server/src/service.rs | 2 +- actix-server/src/signals.rs | 6 +-- actix-server/src/worker.rs | 14 ++--- actix-service/CHANGES.md | 4 +- actix-service/Cargo.toml | 4 +- actix-service/src/and_then.rs | 50 ++++++++--------- actix-service/src/apply.rs | 25 ++++----- actix-service/src/apply_cfg.rs | 35 ++++++------ actix-service/src/cell.rs | 2 +- actix-service/src/lib.rs | 6 +++ actix-service/src/map.rs | 40 +++++++------- actix-service/src/map_err.rs | 40 +++++++------- actix-service/src/map_init_err.rs | 19 +++---- actix-service/src/then.rs | 57 ++++++++++---------- actix-service/src/transform.rs | 25 ++++----- actix-testing/CHANGES.md | 2 +- actix-testing/Cargo.toml | 9 ++-- actix-testing/src/lib.rs | 6 ++- actix-tls/CHANGES.md | 89 +------------------------------ actix-tls/Cargo.toml | 12 ++--- actix-tls/src/lib.rs | 3 ++ actix-utils/CHANGES.md | 4 ++ actix-utils/Cargo.toml | 10 ++-- actix-utils/src/cell.rs | 2 +- actix-utils/src/counter.rs | 4 +- actix-utils/src/either.rs | 4 +- actix-utils/src/framed.rs | 12 ++--- actix-utils/src/inflight.rs | 6 +-- actix-utils/src/keepalive.rs | 2 +- actix-utils/src/lib.rs | 2 + actix-utils/src/mpsc.rs | 12 ++--- actix-utils/src/oneshot.rs | 2 +- actix-utils/src/order.rs | 10 ++-- actix-utils/src/stream.rs | 4 +- actix-utils/src/task.rs | 1 + actix-utils/src/timeout.rs | 6 +-- 68 files changed, 355 insertions(+), 452 deletions(-) delete mode 100644 actix-server/src/counter.rs diff --git a/actix-codec/CHANGES.md b/actix-codec/CHANGES.md index 116b68a7..7c96b4ca 100644 --- a/actix-codec/CHANGES.md +++ b/actix-codec/CHANGES.md @@ -1,5 +1,10 @@ # Changes +## [0.2.0-alpha.2] + +* Migrated to `std::future` + + ## [0.1.2] - 2019-03-27 * Added `Framed::map_io()` method. diff --git a/actix-codec/Cargo.toml b/actix-codec/Cargo.toml index c9970269..3084aee8 100644 --- a/actix-codec/Cargo.toml +++ b/actix-codec/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "actix-codec" -version = "0.2.0-alpha.1" +version = "0.2.0-alpha.2" authors = ["Nikolay Kim "] description = "Utilities for encoding and decoding frames" keywords = ["network", "framework", "async", "futures"] @@ -21,6 +21,6 @@ path = "src/lib.rs" bytes = "0.4.12" futures = "0.3.1" pin-project = "0.4.5" -tokio-io = "0.2.0-alpha.6" -tokio-codec = "0.2.0-alpha.6" +tokio-io = "=0.2.0-alpha.6" +tokio-codec = "=0.2.0-alpha.6" log = "0.4" \ No newline at end of file diff --git a/actix-codec/src/framed.rs b/actix-codec/src/framed.rs index a8c388cd..e458352c 100644 --- a/actix-codec/src/framed.rs +++ b/actix-codec/src/framed.rs @@ -253,7 +253,7 @@ impl Framed { len < self.write_hw } - pub fn next_item(&mut self, cx: &mut Context) -> Poll>> + pub fn next_item(&mut self, cx: &mut Context<'_>) -> Poll>> where T: AsyncRead, U: Decoder, @@ -311,7 +311,7 @@ impl Framed { } } - pub fn flush(&mut self, cx: &mut Context) -> Poll> + pub fn flush(&mut self, cx: &mut Context<'_>) -> Poll> where T: AsyncWrite, U: Encoder, @@ -346,7 +346,7 @@ impl Framed { Poll::Ready(Ok(())) } - pub fn close(&mut self, cx: &mut Context) -> Poll> + pub fn close(&mut self, cx: &mut Context<'_>) -> Poll> where T: AsyncWrite, U: Encoder, @@ -365,7 +365,7 @@ where { type Item = Result; - fn poll_next(mut self: Pin<&mut Self>, cx: &mut Context) -> Poll> { + fn poll_next(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll> { self.next_item(cx) } } @@ -378,7 +378,7 @@ where { type Error = U::Error; - fn poll_ready(self: Pin<&mut Self>, _: &mut Context) -> Poll> { + fn poll_ready(self: Pin<&mut Self>, _: &mut Context<'_>) -> Poll> { if self.is_ready() { Poll::Ready(Ok(())) } else { @@ -393,11 +393,17 @@ where self.write(item) } - fn poll_flush(mut self: Pin<&mut Self>, cx: &mut Context) -> Poll> { + fn poll_flush( + mut self: Pin<&mut Self>, + cx: &mut Context<'_>, + ) -> Poll> { self.flush(cx) } - fn poll_close(mut self: Pin<&mut Self>, cx: &mut Context) -> Poll> { + fn poll_close( + mut self: Pin<&mut Self>, + cx: &mut Context<'_>, + ) -> Poll> { self.close(cx) } } @@ -407,7 +413,7 @@ where T: fmt::Debug, U: fmt::Debug, { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { f.debug_struct("Framed") .field("io", &self.io) .field("codec", &self.codec) diff --git a/actix-codec/src/lib.rs b/actix-codec/src/lib.rs index 4ea33aef..233fa0dc 100644 --- a/actix-codec/src/lib.rs +++ b/actix-codec/src/lib.rs @@ -9,6 +9,8 @@ //! [`Sink`]: # //! [`Stream`]: # //! [transports]: # +#![deny(rust_2018_idioms, warnings)] +#![allow(clippy::type_complexity)] mod bcodec; mod framed; diff --git a/actix-connect/CHANGES.md b/actix-connect/CHANGES.md index baea3d30..190c11a2 100644 --- a/actix-connect/CHANGES.md +++ b/actix-connect/CHANGES.md @@ -1,5 +1,12 @@ # Changes +## [1.0.0-alpha.2] - 2019-12-02 + +### Changed + +* Migrated to `std::future` + + ## [0.3.0] - 2019-10-03 ### Changed diff --git a/actix-connect/Cargo.toml b/actix-connect/Cargo.toml index 987f65cf..1d019e25 100644 --- a/actix-connect/Cargo.toml +++ b/actix-connect/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "actix-connect" -version = "1.0.0-alpha.1" +version = "1.0.0-alpha.2" authors = ["Nikolay Kim "] description = "Actix connect - tcp connector service" keywords = ["network", "framework", "async", "futures"] @@ -33,11 +33,11 @@ openssl = ["open-ssl", "tokio-openssl"] uri = ["http"] [dependencies] -actix-service = "1.0.0-alpha.1" -actix-codec = "0.2.0-alpha.1" -actix-utils = "0.5.0-alpha.1" -actix-rt = "1.0.0-alpha.1" -derive_more = "0.99" +actix-service = "1.0.0-alpha.2" +actix-codec = "0.2.0-alpha.2" +actix-utils = "1.0.0-alpha.2" +actix-rt = "1.0.0-alpha.2" +derive_more = "0.99.2" either = "1.5.2" futures = "0.3.1" http = { version = "0.1.17", optional = true } @@ -56,4 +56,4 @@ webpki = { version = "0.21", optional = true } [dev-dependencies] bytes = "0.4" -actix-testing = { version="0.3.0-alpha.1" } +actix-testing = { version="1.0.0-alpha.2" } diff --git a/actix-connect/src/connect.rs b/actix-connect/src/connect.rs index 1b87f4fe..1a4c51c5 100644 --- a/actix-connect/src/connect.rs +++ b/actix-connect/src/connect.rs @@ -132,7 +132,7 @@ impl From for Connect { } impl fmt::Display for Connect { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { write!(f, "{}:{}", self.host(), self.port()) } } @@ -163,7 +163,7 @@ impl Iterator for ConnectAddrsIter<'_> { } impl fmt::Debug for ConnectAddrsIter<'_> { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { f.debug_list().entries(self.clone()).finish() } } @@ -275,7 +275,7 @@ impl std::ops::DerefMut for Connection { } impl fmt::Debug for Connection { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { write!(f, "Stream {{{:?}}}", self.io) } } diff --git a/actix-connect/src/connector.rs b/actix-connect/src/connector.rs index c0cf6ab8..e2ed8e2b 100644 --- a/actix-connect/src/connector.rs +++ b/actix-connect/src/connector.rs @@ -76,7 +76,7 @@ impl Service for TcpConnector { type Error = ConnectError; type Future = Either, Ready>>; - fn poll_ready(&mut self, _: &mut Context) -> Poll> { + fn poll_ready(&mut self, _: &mut Context<'_>) -> Poll> { Poll::Ready(Ok(())) } @@ -134,7 +134,7 @@ impl TcpConnectorResponse { impl Future for TcpConnectorResponse { type Output = Result, ConnectError>; - fn poll(self: Pin<&mut Self>, cx: &mut Context) -> Poll { + fn poll(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll { let this = self.get_mut(); // connect diff --git a/actix-connect/src/lib.rs b/actix-connect/src/lib.rs index 4f51670d..33e32fae 100644 --- a/actix-connect/src/lib.rs +++ b/actix-connect/src/lib.rs @@ -2,9 +2,10 @@ //! //! ## Package feature //! -//! * `ssl` - enables ssl support via `openssl` crate -//! * `rust-tls` - enables ssl support via `rustls` crate - +//! * `openssl` - enables ssl support via `openssl` crate +//! * `rustls` - enables ssl support via `rustls` crate +#![deny(rust_2018_idioms, warnings)] +#![allow(clippy::type_complexity)] #![recursion_limit = "128"] #[macro_use] @@ -43,7 +44,7 @@ struct DefaultResolver(AsyncResolver); pub(crate) fn get_default_resolver() -> AsyncResolver { if Arbiter::contains_item::() { - return Arbiter::get_item(|item: &DefaultResolver| item.0.clone()); + Arbiter::get_item(|item: &DefaultResolver| item.0.clone()) } else { let (cfg, opts) = match read_system_conf() { Ok((cfg, opts)) => (cfg, opts), diff --git a/actix-connect/src/resolver.rs b/actix-connect/src/resolver.rs index fbadcc94..31ee05d0 100644 --- a/actix-connect/src/resolver.rs +++ b/actix-connect/src/resolver.rs @@ -108,7 +108,7 @@ impl Service for Resolver { type Error = ConnectError; type Future = Either, Ready, Self::Error>>>; - fn poll_ready(&mut self, _: &mut Context) -> Poll> { + fn poll_ready(&mut self, _: &mut Context<'_>) -> Poll> { Poll::Ready(Ok(())) } @@ -153,7 +153,7 @@ impl ResolverFuture { impl Future for ResolverFuture { type Output = Result, ConnectError>; - fn poll(self: Pin<&mut Self>, cx: &mut Context) -> Poll { + fn poll(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll { let this = self.get_mut(); match Pin::new(&mut this.lookup).poll(cx) { diff --git a/actix-connect/src/service.rs b/actix-connect/src/service.rs index 4ea8dd88..be42a568 100644 --- a/actix-connect/src/service.rs +++ b/actix-connect/src/service.rs @@ -96,7 +96,7 @@ impl Service for ConnectService { type Error = ConnectError; type Future = ConnectServiceResponse; - fn poll_ready(&mut self, _: &mut Context) -> Poll> { + fn poll_ready(&mut self, _: &mut Context<'_>) -> Poll> { Poll::Ready(Ok(())) } @@ -116,7 +116,7 @@ enum ConnectState { impl ConnectState { fn poll( &mut self, - cx: &mut Context, + cx: &mut Context<'_>, ) -> Either, ConnectError>>, Connect> { match self { ConnectState::Resolve(ref mut fut) => match Pin::new(fut).poll(cx) { @@ -137,7 +137,7 @@ pub struct ConnectServiceResponse { impl Future for ConnectServiceResponse { type Output = Result, ConnectError>; - fn poll(mut self: Pin<&mut Self>, cx: &mut Context) -> Poll { + fn poll(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll { let res = match self.state.poll(cx) { Either::Right(res) => { self.state = ConnectState::Connect(self.tcp.call(res)); @@ -165,7 +165,7 @@ impl Service for TcpConnectService { type Error = ConnectError; type Future = TcpConnectServiceResponse; - fn poll_ready(&mut self, _: &mut Context) -> Poll> { + fn poll_ready(&mut self, _: &mut Context<'_>) -> Poll> { Poll::Ready(Ok(())) } @@ -185,7 +185,7 @@ enum TcpConnectState { impl TcpConnectState { fn poll( &mut self, - cx: &mut Context, + cx: &mut Context<'_>, ) -> Either>, Connect> { match self { TcpConnectState::Resolve(ref mut fut) => match Pin::new(fut).poll(cx) { @@ -214,7 +214,7 @@ pub struct TcpConnectServiceResponse { impl Future for TcpConnectServiceResponse { type Output = Result; - fn poll(mut self: Pin<&mut Self>, cx: &mut Context) -> Poll { + fn poll(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll { let res = match self.state.poll(cx) { Either::Right(res) => { self.state = TcpConnectState::Connect(self.tcp.call(res)); diff --git a/actix-connect/src/ssl/openssl.rs b/actix-connect/src/ssl/openssl.rs index 83a4a9b3..b7a8464d 100644 --- a/actix-connect/src/ssl/openssl.rs +++ b/actix-connect/src/ssl/openssl.rs @@ -38,7 +38,7 @@ where { pub fn service(connector: SslConnector) -> OpensslConnectorService { OpensslConnectorService { - connector: connector, + connector, _t: PhantomData, } } @@ -98,7 +98,7 @@ where type Error = io::Error; type Future = Either, Ready>>; - fn poll_ready(&mut self, _: &mut Context) -> Poll> { + fn poll_ready(&mut self, _: &mut Context<'_>) -> Poll> { Poll::Ready(Ok(())) } @@ -131,7 +131,7 @@ where { type Output = Result>, io::Error>; - fn poll(self: Pin<&mut Self>, cx: &mut Context) -> Poll { + fn poll(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll { let this = self.get_mut(); match Pin::new(&mut this.fut).poll(cx) { @@ -218,7 +218,7 @@ impl Service for OpensslConnectService { type Error = ConnectError; type Future = OpensslConnectServiceResponse; - fn poll_ready(&mut self, _: &mut Context) -> Poll> { + fn poll_ready(&mut self, _: &mut Context<'_>) -> Poll> { Poll::Ready(Ok(())) } @@ -240,14 +240,14 @@ pub struct OpensslConnectServiceResponse { impl Future for OpensslConnectServiceResponse { type Output = Result, ConnectError>; - fn poll(mut self: Pin<&mut Self>, cx: &mut Context) -> Poll { + fn poll(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll { if let Some(ref mut fut) = self.fut1 { match futures::ready!(Pin::new(fut).poll(cx)) { Ok(res) => { let _ = self.fut1.take(); self.fut2 = Some(self.openssl.call(res)); } - Err(e) => return Poll::Ready(Err(e.into())), + Err(e) => return Poll::Ready(Err(e)), } } diff --git a/actix-ioframe/CHANGES.md b/actix-ioframe/CHANGES.md index a7aa244f..204d799c 100644 --- a/actix-ioframe/CHANGES.md +++ b/actix-ioframe/CHANGES.md @@ -1,5 +1,9 @@ # Changes +## [0.3.0-alpha.2] - 2019-12-02 + +* Migrate to `std::future` + ## [0.1.1] - 2019-10-14 diff --git a/actix-ioframe/Cargo.toml b/actix-ioframe/Cargo.toml index c5650849..696a8d33 100644 --- a/actix-ioframe/Cargo.toml +++ b/actix-ioframe/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "actix-ioframe" -version = "0.3.0-alpha.1" +version = "0.3.0-alpha.2" authors = ["Nikolay Kim "] description = "Actix framed service" keywords = ["network", "framework", "async", "futures"] @@ -18,16 +18,16 @@ name = "actix_ioframe" path = "src/lib.rs" [dependencies] -actix-service = "1.0.0-alpha.1" -actix-codec = "0.2.0-alpha.1" -actix-utils = "0.5.0-alpha.1" -actix-rt = "1.0.0-alpha.1" +actix-service = "1.0.0-alpha.2" +actix-codec = "0.2.0-alpha.2" +actix-utils = "1.0.0-alpha.2" +actix-rt = "1.0.0-alpha.2" bytes = "0.4" either = "1.5.2" futures = "0.3.1" -pin-project = "0.4.5" +pin-project = "0.4.6" log = "0.4" [dev-dependencies] -actix-connect = "1.0.0-alpha.1" -actix-testing = "0.3.0-alpha.1" +actix-connect = "1.0.0-alpha.2" +actix-testing = "1.0.0-alpha.2" diff --git a/actix-ioframe/src/cell.rs b/actix-ioframe/src/cell.rs index 3e82aee4..c14ffefc 100644 --- a/actix-ioframe/src/cell.rs +++ b/actix-ioframe/src/cell.rs @@ -17,7 +17,7 @@ impl Clone for Cell { } impl fmt::Debug for Cell { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { self.inner.fmt(f) } } diff --git a/actix-ioframe/src/connect.rs b/actix-ioframe/src/connect.rs index 60dd1869..4755b86f 100644 --- a/actix-ioframe/src/connect.rs +++ b/actix-ioframe/src/connect.rs @@ -83,7 +83,7 @@ where { type Item = Result<::Item, ::Error>; - fn poll_next(self: Pin<&mut Self>, cx: &mut Context) -> Poll> { + fn poll_next(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll> { self.project().framed.next_item(cx) } } @@ -95,7 +95,7 @@ where { type Error = ::Error; - fn poll_ready(self: Pin<&mut Self>, _: &mut Context) -> Poll> { + fn poll_ready(self: Pin<&mut Self>, _: &mut Context<'_>) -> Poll> { if self.framed.is_ready() { Poll::Ready(Ok(())) } else { diff --git a/actix-ioframe/src/dispatcher.rs b/actix-ioframe/src/dispatcher.rs index ae8a3298..f01a7721 100644 --- a/actix-ioframe/src/dispatcher.rs +++ b/actix-ioframe/src/dispatcher.rs @@ -136,7 +136,7 @@ where { pub(crate) fn poll( &mut self, - cx: &mut Context, + cx: &mut Context<'_>, ) -> Poll>> { let this = self; unsafe { this.inner.get_ref().task.register(cx.waker()) }; @@ -156,7 +156,7 @@ where } fn poll( - cx: &mut Context, + cx: &mut Context<'_>, srv: &mut S, state: &mut St, sink: &mut Sink<::Item>, @@ -247,7 +247,7 @@ where } fn poll_read( - cx: &mut Context, + cx: &mut Context<'_>, srv: &mut S, state: &mut St, sink: &mut Sink<::Item>, @@ -310,7 +310,7 @@ where /// write to framed object fn poll_write( - cx: &mut Context, + cx: &mut Context<'_>, framed: &mut Framed, dispatch_state: &mut FramedState, rx: &mut Option::Item>>>, diff --git a/actix-ioframe/src/error.rs b/actix-ioframe/src/error.rs index e5d9b1b9..3eb0fed9 100644 --- a/actix-ioframe/src/error.rs +++ b/actix-ioframe/src/error.rs @@ -24,7 +24,7 @@ where ::Error: fmt::Debug, ::Error: fmt::Debug, { - fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result { match *self { ServiceError::Service(ref e) => write!(fmt, "ServiceError::Service({:?})", e), ServiceError::Encoder(ref e) => write!(fmt, "ServiceError::Encoder({:?})", e), @@ -39,7 +39,7 @@ where ::Error: fmt::Debug, ::Error: fmt::Debug, { - fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result { match *self { ServiceError::Service(ref e) => write!(fmt, "{}", e), ServiceError::Encoder(ref e) => write!(fmt, "{:?}", e), diff --git a/actix-ioframe/src/item.rs b/actix-ioframe/src/item.rs index ac78d5aa..b0f5c4d8 100644 --- a/actix-ioframe/src/item.rs +++ b/actix-ioframe/src/item.rs @@ -76,7 +76,7 @@ where Codec: Encoder + Decoder, ::Item: fmt::Debug, { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { f.debug_tuple("FramedItem").field(&self.item).finish() } } diff --git a/actix-ioframe/src/lib.rs b/actix-ioframe/src/lib.rs index fabfaa8d..b33f262c 100644 --- a/actix-ioframe/src/lib.rs +++ b/actix-ioframe/src/lib.rs @@ -1,3 +1,6 @@ +#![deny(rust_2018_idioms, warnings)] +#![allow(clippy::type_complexity, clippy::too_many_arguments)] + mod cell; mod connect; mod dispatcher; diff --git a/actix-ioframe/src/service.rs b/actix-ioframe/src/service.rs index b915d0bf..13913edc 100644 --- a/actix-ioframe/src/service.rs +++ b/actix-ioframe/src/service.rs @@ -22,6 +22,12 @@ type ResponseItem = Option<::Item>; /// for building instances for framed services. pub struct Builder(PhantomData<(St, Codec)>); +impl Default for Builder { + fn default() -> Builder { + Builder::new() + } +} + impl Builder { pub fn new() -> Builder { Builder(PhantomData) @@ -251,7 +257,7 @@ where type Error = ServiceError; type Future = FramedServiceImplResponse; - fn poll_ready(&mut self, cx: &mut Context) -> Poll> { + fn poll_ready(&mut self, cx: &mut Context<'_>) -> Poll> { self.connect.poll_ready(cx).map_err(|e| e.into()) } @@ -309,7 +315,7 @@ where { type Output = Result<(), ServiceError>; - fn poll(mut self: Pin<&mut Self>, cx: &mut Context) -> Poll { + fn poll(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll { let mut this = self.as_mut().project(); loop { @@ -373,7 +379,7 @@ where #[project] fn poll( self: Pin<&mut Self>, - cx: &mut Context, + cx: &mut Context<'_>, ) -> Either< FramedServiceImplResponseInner, Poll>>, diff --git a/actix-ioframe/src/sink.rs b/actix-ioframe/src/sink.rs index b3ecc968..43c0d574 100644 --- a/actix-ioframe/src/sink.rs +++ b/actix-ioframe/src/sink.rs @@ -38,7 +38,7 @@ impl Sink { } impl fmt::Debug for Sink { - fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result { fmt.debug_struct("Sink").finish() } } diff --git a/actix-rt/CHANGES.md b/actix-rt/CHANGES.md index 9a165528..8399fc8a 100644 --- a/actix-rt/CHANGES.md +++ b/actix-rt/CHANGES.md @@ -1,6 +1,6 @@ # Changes -## [1.0.0-alpha.2] - 2019-11-xx +## [1.0.0-alpha.2] - 2019-12-02 Added @@ -8,6 +8,8 @@ Added * Export `time` module (re-export of tokio-timer) +* Export `net` module (re-export of tokio-net) + ## [1.0.0-alpha.1] - 2019-11-22 diff --git a/actix-rt/src/arbiter.rs b/actix-rt/src/arbiter.rs index 0b0ae659..600128c0 100644 --- a/actix-rt/src/arbiter.rs +++ b/actix-rt/src/arbiter.rs @@ -32,7 +32,7 @@ pub(crate) enum ArbiterCommand { } impl fmt::Debug for ArbiterCommand { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { match self { ArbiterCommand::Stop => write!(f, "ArbiterCommand::Stop"), ArbiterCommand::Execute(_) => write!(f, "ArbiterCommand::Execute"), diff --git a/actix-rt/src/lib.rs b/actix-rt/src/lib.rs index 7a75f95a..c56fe73c 100644 --- a/actix-rt/src/lib.rs +++ b/actix-rt/src/lib.rs @@ -1,4 +1,6 @@ //! A runtime implementation that runs everything on the current thread. +#![deny(rust_2018_idioms, warnings)] +#![allow(clippy::type_complexity)] #[cfg(not(test))] // Work around for rust-lang/rust#62127 pub use actix_macros::{main, test}; diff --git a/actix-rt/src/runtime.rs b/actix-rt/src/runtime.rs index 8e3c6f7b..79d6477d 100644 --- a/actix-rt/src/runtime.rs +++ b/actix-rt/src/runtime.rs @@ -32,7 +32,7 @@ pub struct RunError { } impl fmt::Display for RunError { - fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result { write!(fmt, "{}", self.inner) } } diff --git a/actix-server/CHANGES.md b/actix-server/CHANGES.md index 6e64e99d..d94217ce 100644 --- a/actix-server/CHANGES.md +++ b/actix-server/CHANGES.md @@ -1,9 +1,11 @@ # Changes -## [0.8.0-alpha.2] - 2019-11-xx +## [1.0.0-alpha.2] - 2019-12-02 ### Changed +* Simplify server service (remove actix-server-config) + * Allow to wait on `Server` until server stops diff --git a/actix-server/Cargo.toml b/actix-server/Cargo.toml index 5ff60e13..e61eb8e1 100644 --- a/actix-server/Cargo.toml +++ b/actix-server/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "actix-server" -version = "0.8.0-alpha.2" +version = "1.0.0-alpha.2" authors = ["Nikolay Kim "] description = "Actix server - General purpose tcp server" keywords = ["network", "framework", "async", "futures"] @@ -21,9 +21,10 @@ path = "src/lib.rs" default = [] [dependencies] -actix-service = "1.0.0-alpha.1" +actix-service = "1.0.0-alpha.2" actix-rt = "1.0.0-alpha.2" -actix-codec = "0.2.0-alpha.1" +actix-codec = "0.2.0-alpha.2" +actix-utils = "1.0.0-alpha.2" log = "0.4" num_cpus = "1.0" @@ -40,5 +41,4 @@ mio-uds = { version = "0.6.7" } [dev-dependencies] bytes = "0.4" -actix-codec = "0.2.0-alpha.1" env_logger = "0.6" diff --git a/actix-server/src/config.rs b/actix-server/src/config.rs index 999a712d..eb633ac2 100644 --- a/actix-server/src/config.rs +++ b/actix-server/src/config.rs @@ -3,6 +3,7 @@ use std::{fmt, io, net}; use actix_rt::net::TcpStream; use actix_service as actix; +use actix_utils::counter::CounterGuard; use futures::future::{Future, FutureExt, LocalBoxFuture}; use log::error; @@ -11,7 +12,6 @@ use super::service::{ BoxedServerService, InternalServiceFactory, ServerMessage, StreamService, }; use super::Token; -use crate::counter::CounterGuard; pub struct ServiceConfig { pub(crate) services: Vec<(String, net::TcpListener)>, @@ -126,9 +126,9 @@ impl InternalServiceFactory for ConfiguredService { Ok(serv) => { res.push((token, serv)); } - Err(e) => { - error!("Can not construct service {:?}", e); - return Err(e); + Err(_) => { + error!("Can not construct service"); + return Err(()); } }; } diff --git a/actix-server/src/counter.rs b/actix-server/src/counter.rs deleted file mode 100644 index 74f716da..00000000 --- a/actix-server/src/counter.rs +++ /dev/null @@ -1,81 +0,0 @@ -use std::cell::Cell; -use std::rc::Rc; - -use futures::task::AtomicWaker; -use std::task; - -#[derive(Clone)] -/// Simple counter with ability to notify task on reaching specific number -/// -/// Counter could be cloned, total ncount is shared across all clones. -pub struct Counter(Rc); - -#[derive(Debug)] -struct CounterInner { - count: Cell, - capacity: usize, - task: AtomicWaker, -} - -impl Counter { - /// Create `Counter` instance and set max value. - pub fn new(capacity: usize) -> Self { - Counter(Rc::new(CounterInner { - capacity, - count: Cell::new(0), - task: AtomicWaker::new(), - })) - } - - pub fn get(&self) -> CounterGuard { - CounterGuard::new(self.0.clone()) - } - - /// Check if counter is not at capacity - pub fn available(&self, cx: &mut task::Context) -> bool { - self.0.available(cx) - } - - /// Get total number of acquired counts - pub fn total(&self) -> usize { - self.0.count.get() - } -} - -#[derive(Debug)] -pub struct CounterGuard(Rc); - -impl CounterGuard { - fn new(inner: Rc) -> Self { - inner.inc(); - CounterGuard(inner) - } -} - -impl Drop for CounterGuard { - fn drop(&mut self) { - self.0.dec(); - } -} - -impl CounterInner { - fn inc(&self) { - self.count.set(self.count.get() + 1); - } - - fn dec(&self) { - let num = self.count.get(); - self.count.set(num - 1); - if num == self.capacity { - self.task.wake(); - } - } - - fn available(&self, cx: &mut task::Context) -> bool { - let avail = self.count.get() < self.capacity; - if !avail { - self.task.register(cx.waker()); - } - avail - } -} diff --git a/actix-server/src/lib.rs b/actix-server/src/lib.rs index 4e9b5f71..50df1142 100644 --- a/actix-server/src/lib.rs +++ b/actix-server/src/lib.rs @@ -1,9 +1,10 @@ //! General purpose tcp server +#![deny(rust_2018_idioms, warnings)] +#![allow(clippy::type_complexity)] mod accept; mod builder; mod config; -mod counter; mod server; mod service; mod signals; diff --git a/actix-server/src/server.rs b/actix-server/src/server.rs index 8c7202f6..6ba2547f 100644 --- a/actix-server/src/server.rs +++ b/actix-server/src/server.rs @@ -88,7 +88,7 @@ impl Clone for Server { impl Future for Server { type Output = io::Result<()>; - fn poll(self: Pin<&mut Self>, cx: &mut Context) -> Poll { + fn poll(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll { let this = self.get_mut(); if this.1.is_none() { diff --git a/actix-server/src/service.rs b/actix-server/src/service.rs index 3729689d..ecdbde3a 100644 --- a/actix-server/src/service.rs +++ b/actix-server/src/service.rs @@ -5,12 +5,12 @@ use std::time::Duration; use actix_rt::spawn; use actix_service::{self as actix, Service, ServiceFactory as ActixServiceFactory}; +use actix_utils::counter::CounterGuard; use futures::future::{err, ok, LocalBoxFuture, Ready}; use futures::{FutureExt, TryFutureExt}; use log::error; use super::Token; -use crate::counter::CounterGuard; use crate::socket::{FromStream, StdStream}; /// Server message diff --git a/actix-server/src/signals.rs b/actix-server/src/signals.rs index 55f23b8f..6703d813 100644 --- a/actix-server/src/signals.rs +++ b/actix-server/src/signals.rs @@ -50,10 +50,8 @@ impl Signals { (unix::SignalKind::quit(), Signal::Quit), ]; - for (kind, sig) in sig_map.into_iter() { - let sig = sig.clone(); - let fut = unix::signal(*kind)?; - streams.push((sig, fut)); + for (kind, sig) in sig_map.iter() { + streams.push((*sig, unix::signal(*kind)?)); } Signals { srv, streams } diff --git a/actix-server/src/worker.rs b/actix-server/src/worker.rs index 03a63a05..b8bb67f6 100644 --- a/actix-server/src/worker.rs +++ b/actix-server/src/worker.rs @@ -6,6 +6,7 @@ use std::{mem, time}; use actix_rt::time::{delay, Delay}; use actix_rt::{spawn, Arbiter}; +use actix_utils::counter::Counter; use futures::channel::mpsc::{UnboundedReceiver, UnboundedSender}; use futures::channel::oneshot; use futures::future::{join_all, LocalBoxFuture, MapOk}; @@ -13,7 +14,6 @@ use futures::{Future, FutureExt, Stream, TryFutureExt}; use log::{error, info, trace}; use crate::accept::AcceptNotify; -use crate::counter::Counter; use crate::service::{BoxedServerService, InternalServiceFactory, ServerMessage}; use crate::socket::{SocketAddr, StdStream}; use crate::Token; @@ -332,11 +332,11 @@ impl Future for Worker { } } self.availability.set(true); - return self.poll(cx); + self.poll(cx) } Ok(false) => { self.state = WorkerState::Unavailable(conns); - return Poll::Pending; + Poll::Pending } Err((token, idx)) => { trace!( @@ -345,7 +345,7 @@ impl Future for Worker { ); self.state = WorkerState::Restarting(idx, token, self.factories[idx].create()); - return self.poll(cx); + self.poll(cx) } } } @@ -372,7 +372,7 @@ impl Future for Worker { return Poll::Pending; } } - return self.poll(cx); + self.poll(cx) } WorkerState::Shutdown(mut t1, mut t2, tx) => { let num = num_connections(); @@ -402,7 +402,7 @@ impl Future for Worker { } } self.state = WorkerState::Shutdown(t1, t2, tx); - return Poll::Pending; + Poll::Pending } WorkerState::Available => { loop { @@ -448,6 +448,6 @@ impl Future for Worker { } } WorkerState::None => panic!(), - }; + } } } diff --git a/actix-service/CHANGES.md b/actix-service/CHANGES.md index b3a7d488..c33abe36 100644 --- a/actix-service/CHANGES.md +++ b/actix-service/CHANGES.md @@ -1,6 +1,8 @@ # Changes -## [1.0.0-alpha.2] - 2019-11-xx +## [1.0.0-alpha.2] - 2019-12-02 + +### Use owned config value for service factory ### Renamed BoxedNewService/BoxedService to BoxServiceFactory/BoxService diff --git a/actix-service/Cargo.toml b/actix-service/Cargo.toml index d8b50ce3..5f0a2b1b 100644 --- a/actix-service/Cargo.toml +++ b/actix-service/Cargo.toml @@ -24,7 +24,7 @@ path = "src/lib.rs" [dependencies] futures = "0.3.1" -pin-project = "0.4.6" +pin-project-lite = "0.1.1" [dev-dependencies] -actix-rt = "1.0.0-alpha.1" +actix-rt = "1.0.0-alpha.2" diff --git a/actix-service/src/and_then.rs b/actix-service/src/and_then.rs index a22acde3..6f631b96 100644 --- a/actix-service/src/and_then.rs +++ b/actix-service/src/and_then.rs @@ -61,17 +61,18 @@ where } } -#[pin_project::pin_project] -pub struct AndThenServiceResponse -where - A: Service, - B: Service, -{ - b: Cell, - #[pin] - fut_b: Option, - #[pin] - fut_a: Option, +pin_project! { + pub struct AndThenServiceResponse + where + A: Service, + B: Service, + { + b: Cell, + #[pin] + fut_b: Option, + #[pin] + fut_a: Option, + } } impl AndThenServiceResponse @@ -189,19 +190,20 @@ where } } -#[pin_project::pin_project] -pub struct AndThenServiceFactoryResponse -where - A: ServiceFactory, - B: ServiceFactory, -{ - #[pin] - fut_b: B::Future, - #[pin] - fut_a: A::Future, +pin_project! { + pub struct AndThenServiceFactoryResponse + where + A: ServiceFactory, + B: ServiceFactory, + { + #[pin] + fut_b: B::Future, + #[pin] + fut_a: A::Future, - a: Option, - b: Option, + a: Option, + b: Option, + } } impl AndThenServiceFactoryResponse @@ -287,7 +289,7 @@ mod tests { type Error = (); type Future = Ready>; - fn poll_ready(&mut self, _: &mut Context) -> Poll> { + fn poll_ready(&mut self, _: &mut Context<'_>) -> Poll> { self.0.set(self.0.get() + 1); Poll::Ready(Ok(())) } diff --git a/actix-service/src/apply.rs b/actix-service/src/apply.rs index 9d87cb55..5b9a0a02 100644 --- a/actix-service/src/apply.rs +++ b/actix-service/src/apply.rs @@ -122,17 +122,18 @@ where } } -#[pin_project::pin_project] -pub struct ApplyServiceFactoryResponse -where - T: ServiceFactory, - F: FnMut(In, &mut T::Service) -> R + Clone, - R: Future>, -{ - #[pin] - fut: T::Future, - f: Option, - r: PhantomData<(In, Out)>, +pin_project! { + pub struct ApplyServiceFactoryResponse + where + T: ServiceFactory, + F: FnMut(In, &mut T::Service) -> R, + R: Future>, + { + #[pin] + fut: T::Future, + f: Option, + r: PhantomData<(In, Out)>, + } } impl ApplyServiceFactoryResponse @@ -187,7 +188,7 @@ mod tests { type Error = (); type Future = Ready>; - fn poll_ready(&mut self, _: &mut Context) -> Poll> { + fn poll_ready(&mut self, _: &mut Context<'_>) -> Poll> { Poll::Ready(Ok(())) } diff --git a/actix-service/src/apply_cfg.rs b/actix-service/src/apply_cfg.rs index a0567761..5a9a615d 100644 --- a/actix-service/src/apply_cfg.rs +++ b/actix-service/src/apply_cfg.rs @@ -149,23 +149,24 @@ where } } -#[pin_project::pin_project] -pub struct ApplyConfigServiceFactoryResponse -where - F: FnMut(C, &mut T::Service) -> R, - T: ServiceFactory, - T::InitError: From, - R: Future>, - S: Service, -{ - cfg: Option, - f: Cell, - srv: Option, - #[pin] - srv_fut: Option, - #[pin] - fut: Option, - _t: PhantomData<(S,)>, +pin_project! { + pub struct ApplyConfigServiceFactoryResponse + where + F: FnMut(C, &mut T::Service) -> R, + T: ServiceFactory, + T::InitError: From, + R: Future>, + S: Service, + { + cfg: Option, + f: Cell, + srv: Option, + #[pin] + srv_fut: Option, + #[pin] + fut: Option, + _t: PhantomData<(S,)>, + } } impl Future for ApplyConfigServiceFactoryResponse diff --git a/actix-service/src/cell.rs b/actix-service/src/cell.rs index 20be519f..76afce4e 100644 --- a/actix-service/src/cell.rs +++ b/actix-service/src/cell.rs @@ -14,7 +14,7 @@ impl Clone for Cell { } impl fmt::Debug for Cell { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { self.inner.fmt(f) } } diff --git a/actix-service/src/lib.rs b/actix-service/src/lib.rs index 619c78ee..d3138d62 100644 --- a/actix-service/src/lib.rs +++ b/actix-service/src/lib.rs @@ -1,3 +1,9 @@ +#![deny(rust_2018_idioms, warnings)] +#![allow(clippy::type_complexity)] + +#[macro_use] +extern crate pin_project_lite; + use std::cell::RefCell; use std::future::Future; use std::rc::Rc; diff --git a/actix-service/src/map.rs b/actix-service/src/map.rs index f7275e94..e4dfc102 100644 --- a/actix-service/src/map.rs +++ b/actix-service/src/map.rs @@ -62,15 +62,16 @@ where } } -#[pin_project::pin_project] -pub struct MapFuture -where - A: Service, - F: FnMut(A::Response) -> Response, -{ - f: F, - #[pin] - fut: A::Future, +pin_project! { + pub struct MapFuture + where + A: Service, + F: FnMut(A::Response) -> Response, + { + f: F, + #[pin] + fut: A::Future, + } } impl MapFuture @@ -156,15 +157,16 @@ where } } -#[pin_project::pin_project] -pub struct MapServiceFuture -where - A: ServiceFactory, - F: FnMut(A::Response) -> Res, -{ - #[pin] - fut: A::Future, - f: Option, +pin_project! { + pub struct MapServiceFuture + where + A: ServiceFactory, + F: FnMut(A::Response) -> Res, + { + #[pin] + fut: A::Future, + f: Option, + } } impl MapServiceFuture @@ -210,7 +212,7 @@ mod tests { type Error = (); type Future = Ready>; - fn poll_ready(&mut self, _: &mut Context) -> Poll> { + fn poll_ready(&mut self, _: &mut Context<'_>) -> Poll> { Poll::Ready(Ok(())) } diff --git a/actix-service/src/map_err.rs b/actix-service/src/map_err.rs index b7696704..86013867 100644 --- a/actix-service/src/map_err.rs +++ b/actix-service/src/map_err.rs @@ -63,15 +63,16 @@ where } } -#[pin_project::pin_project] -pub struct MapErrFuture -where - A: Service, - F: Fn(A::Error) -> E, -{ - f: F, - #[pin] - fut: A::Future, +pin_project! { + pub struct MapErrFuture + where + A: Service, + F: Fn(A::Error) -> E, + { + f: F, + #[pin] + fut: A::Future, + } } impl MapErrFuture @@ -159,15 +160,16 @@ where } } -#[pin_project::pin_project] -pub struct MapErrServiceFuture -where - A: ServiceFactory, - F: Fn(A::Error) -> E, -{ - #[pin] - fut: A::Future, - f: F, +pin_project! { + pub struct MapErrServiceFuture + where + A: ServiceFactory, + F: Fn(A::Error) -> E, + { + #[pin] + fut: A::Future, + f: F, + } } impl MapErrServiceFuture @@ -212,7 +214,7 @@ mod tests { type Error = (); type Future = Ready>; - fn poll_ready(&mut self, _: &mut Context) -> Poll> { + fn poll_ready(&mut self, _: &mut Context<'_>) -> Poll> { Poll::Ready(Err(())) } diff --git a/actix-service/src/map_init_err.rs b/actix-service/src/map_init_err.rs index b1eec072..e13e6453 100644 --- a/actix-service/src/map_init_err.rs +++ b/actix-service/src/map_init_err.rs @@ -60,15 +60,16 @@ where } } -#[pin_project::pin_project] -pub struct MapInitErrFuture -where - A: ServiceFactory, - F: Fn(A::InitError) -> E, -{ - f: F, - #[pin] - fut: A::Future, +pin_project! { + pub struct MapInitErrFuture + where + A: ServiceFactory, + F: Fn(A::InitError) -> E, + { + f: F, + #[pin] + fut: A::Future, + } } impl MapInitErrFuture diff --git a/actix-service/src/then.rs b/actix-service/src/then.rs index 85293f58..7b661d80 100644 --- a/actix-service/src/then.rs +++ b/actix-service/src/then.rs @@ -61,17 +61,18 @@ where } } -#[pin_project::pin_project] -pub struct ThenServiceResponse -where - A: Service, - B: Service>, -{ - b: Cell, - #[pin] - fut_b: Option, - #[pin] - fut_a: Option, +pin_project! { + pub struct ThenServiceResponse + where + A: Service, + B: Service>, + { + b: Cell, + #[pin] + fut_b: Option, + #[pin] + fut_a: Option, + } } impl ThenServiceResponse @@ -184,23 +185,23 @@ where } } -#[pin_project::pin_project] -pub struct ThenServiceFactoryResponse -where - A: ServiceFactory, - B: ServiceFactory< - Config = A::Config, - Request = Result, - Error = A::Error, - InitError = A::InitError, - >, -{ - #[pin] - fut_b: B::Future, - #[pin] - fut_a: A::Future, - a: Option, - b: Option, +pin_project! { + pub struct ThenServiceFactoryResponse + where + A: ServiceFactory, + B: ServiceFactory< + Config = A::Config, + Request = Result, + Error = A::Error, + InitError = A::InitError> + { + #[pin] + fut_b: B::Future, + #[pin] + fut_a: A::Future, + a: Option, + b: Option, + } } impl ThenServiceFactoryResponse diff --git a/actix-service/src/transform.rs b/actix-service/src/transform.rs index e431faf7..f1e4ee41 100644 --- a/actix-service/src/transform.rs +++ b/actix-service/src/transform.rs @@ -134,17 +134,18 @@ where } } -#[pin_project::pin_project] -pub struct ApplyTransformFuture -where - S: ServiceFactory, - T: Transform, -{ - #[pin] - fut_a: S::Future, - #[pin] - fut_t: Option, - t_cell: Rc, +pin_project! { + pub struct ApplyTransformFuture + where + S: ServiceFactory, + T: Transform, + { + #[pin] + fut_a: S::Future, + #[pin] + fut_t: Option, + t_cell: Rc, + } } impl Future for ApplyTransformFuture @@ -167,7 +168,7 @@ where this.fut_t.set(Some(fut)); this.fut_t.as_pin_mut().unwrap().poll(cx) } else { - return Poll::Pending; + Poll::Pending } } } diff --git a/actix-testing/CHANGES.md b/actix-testing/CHANGES.md index 098fc581..4c14e8be 100644 --- a/actix-testing/CHANGES.md +++ b/actix-testing/CHANGES.md @@ -1,6 +1,6 @@ # Changes -## [0.3.0-alpha.2] - 2019-11-xx +## [1.0.0-alpha.2] - 2019-12-02 * Re-export `test` attribute macros diff --git a/actix-testing/Cargo.toml b/actix-testing/Cargo.toml index 46230e15..e597b933 100644 --- a/actix-testing/Cargo.toml +++ b/actix-testing/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "actix-testing" -version = "0.3.0-alpha.2" +version = "1.0.0-alpha.2" authors = ["Nikolay Kim "] description = "Actix testing utils" keywords = ["network", "framework", "async", "futures"] @@ -17,11 +17,10 @@ name = "actix_testing" path = "src/lib.rs" [dependencies] -actix-rt = "1.0.0-alpha.1" +actix-rt = "1.0.0-alpha.2" actix-macros = "0.1.0-alpha.1" -actix-server = "0.8.0-alpha.1" -actix-server-config = "0.3.0-alpha.1" -actix-service = "1.0.0-alpha.1" +actix-server = "1.0.0-alpha.2" +actix-service = "1.0.0-alpha.2" log = "0.4" net2 = "0.2" diff --git a/actix-testing/src/lib.rs b/actix-testing/src/lib.rs index 410e42f0..f1e82e67 100644 --- a/actix-testing/src/lib.rs +++ b/actix-testing/src/lib.rs @@ -1,10 +1,12 @@ //! Various helpers for Actix applications to use during testing. +#![deny(rust_2018_idioms, warnings)] +#![allow(clippy::type_complexity)] + use std::sync::mpsc; use std::{net, thread}; use actix_rt::{net::TcpStream, System}; use actix_server::{Server, ServerBuilder, ServiceFactory}; -pub use actix_server_config::{Io, ServerConfig}; use net2::TcpBuilder; use tokio_net::driver::Handle; @@ -46,7 +48,7 @@ pub struct TestServerRuntime { impl TestServer { /// Start new server with server builder - pub fn new(mut factory: F) -> TestServerRuntime + pub fn start(mut factory: F) -> TestServerRuntime where F: FnMut(ServerBuilder) -> ServerBuilder + Send + 'static, { diff --git a/actix-tls/CHANGES.md b/actix-tls/CHANGES.md index baea3d30..11cf6cf7 100644 --- a/actix-tls/CHANGES.md +++ b/actix-tls/CHANGES.md @@ -1,90 +1,5 @@ # Changes -## [0.3.0] - 2019-10-03 +## [1.0.0-alpha.1] - 2019-12-02 -### Changed - -* Update `rustls` to 0.16 -* Minimum required Rust version upped to 1.37.0 - -## [0.2.5] - 2019-09-05 - -* Add `TcpConnectService` - -## [0.2.4] - 2019-09-02 - -* Use arbiter's storage for default async resolver - -## [0.2.3] - 2019-08-05 - -* Add `ConnectService` and `OpensslConnectService` - -## [0.2.2] - 2019-07-24 - -* Add `rustls` support - -## [0.2.1] - 2019-07-17 - -### Added - -* Expose Connect addrs #30 - -### Changed - -* Update `derive_more` to 0.15 - - -## [0.2.0] - 2019-05-12 - -### Changed - -* Upgrade to actix-service 0.4 - - -## [0.1.5] - 2019-04-19 - -### Added - -* `Connect::set_addr()` - -### Changed - -* Use trust-dns-resolver 0.11.0 - - -## [0.1.4] - 2019-04-12 - -### Changed - -* Do not start default resolver immediately for default connector. - - -## [0.1.3] - 2019-04-11 - -### Changed - -* Start trust-dns default resolver on first use - -## [0.1.2] - 2019-04-04 - -### Added - -* Log error if dns system config could not be loaded. - -### Changed - -* Rename connect Connector to TcpConnector #10 - - -## [0.1.1] - 2019-03-15 - -### Fixed - -* Fix error handling for single address - - -## [0.1.0] - 2019-03-14 - -* Refactor resolver and connector services - -* Rename crate +* Split openssl accetor from actix-server package diff --git a/actix-tls/Cargo.toml b/actix-tls/Cargo.toml index 4700ab08..b4243648 100644 --- a/actix-tls/Cargo.toml +++ b/actix-tls/Cargo.toml @@ -29,11 +29,11 @@ openssl = ["open-ssl", "tokio-openssl"] rustls = ["rust-tls", "webpki"] [dependencies] -actix-service = "1.0.0-alpha.1" -actix-codec = "0.2.0-alpha.1" -actix-utils = "0.5.0-alpha.1" -actix-rt = "1.0.0-alpha.1" -derive_more = "0.99" +actix-service = "1.0.0-alpha.2" +actix-codec = "0.2.0-alpha.2" +actix-utils = "1.0.0-alpha.2" +actix-rt = "1.0.0-alpha.2" +derive_more = "0.99.2" either = "1.5.2" futures = "0.3.1" log = "0.4" @@ -51,4 +51,4 @@ webpki-roots = { version = "0.17", optional = true } [dev-dependencies] bytes = "0.4" -actix-testing = { version="0.3.0-alpha.1" } +actix-testing = { version="1.0.0-alpha.2" } diff --git a/actix-tls/src/lib.rs b/actix-tls/src/lib.rs index 12b7172b..54b840eb 100644 --- a/actix-tls/src/lib.rs +++ b/actix-tls/src/lib.rs @@ -1,4 +1,7 @@ //! SSL Services +#![deny(rust_2018_idioms, warnings)] +#![allow(clippy::type_complexity)] + use std::sync::atomic::{AtomicUsize, Ordering}; use actix_utils::counter::Counter; diff --git a/actix-utils/CHANGES.md b/actix-utils/CHANGES.md index 4e4ac8d7..3aa5deab 100644 --- a/actix-utils/CHANGES.md +++ b/actix-utils/CHANGES.md @@ -1,5 +1,9 @@ # Changes +## [1.0.0-alpha.2] - 2019-12-02 + +* Migrate to `std::future` + ## [0.4.7] - 2019-10-14 * Re-register task on every framed transport poll. diff --git a/actix-utils/Cargo.toml b/actix-utils/Cargo.toml index 01728d46..7740a83b 100644 --- a/actix-utils/Cargo.toml +++ b/actix-utils/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "actix-utils" -version = "0.5.0-alpha1" +version = "1.0.0-alpha.2" authors = ["Nikolay Kim "] description = "Actix utils - various actix net related services" keywords = ["network", "framework", "async", "futures"] @@ -18,11 +18,11 @@ name = "actix_utils" path = "src/lib.rs" [dependencies] -actix-service = "1.0.0-alpha.1" -actix-rt = "1.0.0-alpha.1" -actix-codec = "0.2.0-alpha.1" +actix-service = "1.0.0-alpha.2" +actix-rt = "1.0.0-alpha.2" +actix-codec = "0.2.0-alpha.2" bytes = "0.4" either = "1.5.2" futures = "0.3.1" -pin-project = "0.4.5" +pin-project = "0.4.6" log = "0.4" diff --git a/actix-utils/src/cell.rs b/actix-utils/src/cell.rs index 419709ce..ffc28eb2 100644 --- a/actix-utils/src/cell.rs +++ b/actix-utils/src/cell.rs @@ -17,7 +17,7 @@ impl Clone for Cell { } impl fmt::Debug for Cell { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { self.inner.fmt(f) } } diff --git a/actix-utils/src/counter.rs b/actix-utils/src/counter.rs index cffa9541..ceaa727c 100644 --- a/actix-utils/src/counter.rs +++ b/actix-utils/src/counter.rs @@ -33,7 +33,7 @@ impl Counter { /// Check if counter is not at capacity. If counter at capacity /// it registers notification for current task. - pub fn available(&self, cx: &mut task::Context) -> bool { + pub fn available(&self, cx: &mut task::Context<'_>) -> bool { self.0.available(cx) } @@ -73,7 +73,7 @@ impl CounterInner { } } - fn available(&self, cx: &mut task::Context) -> bool { + fn available(&self, cx: &mut task::Context<'_>) -> bool { if self.count.get() < self.capacity { true } else { diff --git a/actix-utils/src/either.rs b/actix-utils/src/either.rs index 2f1b2ec5..0aeecf89 100644 --- a/actix-utils/src/either.rs +++ b/actix-utils/src/either.rs @@ -34,7 +34,7 @@ where type Error = A::Error; type Future = future::Either; - fn poll_ready(&mut self, cx: &mut Context) -> Poll> { + fn poll_ready(&mut self, cx: &mut Context<'_>) -> Poll> { let left = self.left.poll_ready(cx)?; let right = self.right.poll_ready(cx)?; @@ -131,7 +131,7 @@ where { type Output = Result, A::InitError>; - fn poll(self: Pin<&mut Self>, cx: &mut Context) -> Poll { + fn poll(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll { let this = self.project(); if this.left.is_none() { diff --git a/actix-utils/src/framed.rs b/actix-utils/src/framed.rs index a986f33e..ce2ac148 100644 --- a/actix-utils/src/framed.rs +++ b/actix-utils/src/framed.rs @@ -37,7 +37,7 @@ where ::Error: fmt::Debug, ::Error: fmt::Debug, { - fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result { match *self { FramedTransportError::Service(ref e) => { write!(fmt, "FramedTransportError::Service({:?})", e) @@ -58,7 +58,7 @@ where ::Error: fmt::Debug, ::Error: fmt::Debug, { - fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result { match *self { FramedTransportError::Service(ref e) => write!(fmt, "{}", e), FramedTransportError::Encoder(ref e) => write!(fmt, "{:?}", e), @@ -177,7 +177,7 @@ where { type Output = Result<(), FramedTransportError>; - fn poll(self: Pin<&mut Self>, cx: &mut Context) -> Poll { + fn poll(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll { self.inner.get_ref().task.register(cx.waker()); let this = self.project(); @@ -193,7 +193,7 @@ where } fn poll( - cx: &mut Context, + cx: &mut Context<'_>, srv: &mut S, state: &mut TransportState, framed: &mut Framed, @@ -248,7 +248,7 @@ where } fn poll_read( - cx: &mut Context, + cx: &mut Context<'_>, srv: &mut S, state: &mut TransportState, framed: &mut Framed, @@ -300,7 +300,7 @@ where /// write to framed object fn poll_write( - cx: &mut Context, + cx: &mut Context<'_>, state: &mut TransportState, framed: &mut Framed, rx: &mut Rx, diff --git a/actix-utils/src/inflight.rs b/actix-utils/src/inflight.rs index c4d6f222..c64c7b56 100644 --- a/actix-utils/src/inflight.rs +++ b/actix-utils/src/inflight.rs @@ -73,7 +73,7 @@ where type Error = T::Error; type Future = InFlightServiceResponse; - fn poll_ready(&mut self, cx: &mut Context) -> Poll> { + fn poll_ready(&mut self, cx: &mut Context<'_>) -> Poll> { if let Poll::Pending = self.service.poll_ready(cx)? { Poll::Pending } else if !self.count.available(cx) { @@ -103,7 +103,7 @@ pub struct InFlightServiceResponse { impl Future for InFlightServiceResponse { type Output = Result; - fn poll(self: Pin<&mut Self>, cx: &mut Context) -> Poll { + fn poll(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll { self.project().fut.poll(cx) } } @@ -126,7 +126,7 @@ mod tests { type Error = (); type Future = LocalBoxFuture<'static, Result<(), ()>>; - fn poll_ready(&mut self, _: &mut Context) -> Poll> { + fn poll_ready(&mut self, _: &mut Context<'_>) -> Poll> { Poll::Ready(Ok(())) } diff --git a/actix-utils/src/keepalive.rs b/actix-utils/src/keepalive.rs index 675efa73..ebfcfe7a 100644 --- a/actix-utils/src/keepalive.rs +++ b/actix-utils/src/keepalive.rs @@ -102,7 +102,7 @@ where type Error = E; type Future = Ready>; - fn poll_ready(&mut self, cx: &mut Context) -> Poll> { + fn poll_ready(&mut self, cx: &mut Context<'_>) -> Poll> { match Pin::new(&mut self.delay).poll(cx) { Poll::Ready(_) => { let now = self.time.now(); diff --git a/actix-utils/src/lib.rs b/actix-utils/src/lib.rs index 4bc755d4..78467e9c 100644 --- a/actix-utils/src/lib.rs +++ b/actix-utils/src/lib.rs @@ -1,4 +1,6 @@ //! Actix utils - various helper services +#![deny(rust_2018_idioms, warnings)] +#![allow(clippy::type_complexity)] mod cell; pub mod counter; diff --git a/actix-utils/src/mpsc.rs b/actix-utils/src/mpsc.rs index 9ada3e7e..d6e41135 100644 --- a/actix-utils/src/mpsc.rs +++ b/actix-utils/src/mpsc.rs @@ -72,7 +72,7 @@ impl Clone for Sender { impl Sink for Sender { type Error = SendError; - fn poll_ready(self: Pin<&mut Self>, _: &mut Context) -> Poll> { + fn poll_ready(self: Pin<&mut Self>, _: &mut Context<'_>) -> Poll> { Poll::Ready(Ok(())) } @@ -80,11 +80,11 @@ impl Sink for Sender { self.send(item) } - fn poll_flush(self: Pin<&mut Self>, _: &mut Context) -> Poll>> { + fn poll_flush(self: Pin<&mut Self>, _: &mut Context<'_>) -> Poll>> { Poll::Ready(Ok(())) } - fn poll_close(self: Pin<&mut Self>, _: &mut Context) -> Poll> { + fn poll_close(self: Pin<&mut Self>, _: &mut Context<'_>) -> Poll> { Poll::Ready(Ok(())) } } @@ -144,7 +144,7 @@ impl Receiver { impl Stream for Receiver { type Item = T; - fn poll_next(mut self: Pin<&mut Self>, cx: &mut Context) -> Poll> { + fn poll_next(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll> { let me = match self.state { State::Open(ref mut me) => me, State::Closed(ref mut items) => return Poll::Ready(items.pop_front()), @@ -177,13 +177,13 @@ impl Drop for Receiver { pub struct SendError(T); impl fmt::Debug for SendError { - fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result { fmt.debug_tuple("SendError").field(&"...").finish() } } impl fmt::Display for SendError { - fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result { write!(fmt, "send failed because receiver is gone") } } diff --git a/actix-utils/src/oneshot.rs b/actix-utils/src/oneshot.rs index f411d8c5..7acfca42 100644 --- a/actix-utils/src/oneshot.rs +++ b/actix-utils/src/oneshot.rs @@ -111,7 +111,7 @@ impl Sender { /// able to receive a message if sent. The current task, however, is /// scheduled to receive a notification if the corresponding `Receiver` goes /// away. - pub fn poll_canceled(&mut self, cx: &mut Context) -> Poll<()> { + pub fn poll_canceled(&mut self, cx: &mut Context<'_>) -> Poll<()> { match self.inner.upgrade() { Some(inner) => { inner.borrow_mut().tx_task.register(cx.waker()); diff --git a/actix-utils/src/order.rs b/actix-utils/src/order.rs index 6eb31df1..a82cf2c7 100644 --- a/actix-utils/src/order.rs +++ b/actix-utils/src/order.rs @@ -33,7 +33,7 @@ impl From for InOrderError { } impl fmt::Debug for InOrderError { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { match self { InOrderError::Service(e) => write!(f, "InOrderError::Service({:?})", e), InOrderError::Disconnected => write!(f, "InOrderError::Disconnected"), @@ -42,7 +42,7 @@ impl fmt::Debug for InOrderError { } impl fmt::Display for InOrderError { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { match self { InOrderError::Service(e) => e.fmt(f), InOrderError::Disconnected => write!(f, "InOrder service disconnected"), @@ -140,7 +140,7 @@ where type Error = InOrderError; type Future = InOrderServiceResponse; - fn poll_ready(&mut self, cx: &mut Context) -> Poll> { + fn poll_ready(&mut self, cx: &mut Context<'_>) -> Poll> { // poll_ready could be called from different task self.task.register(cx.waker()); @@ -192,7 +192,7 @@ pub struct InOrderServiceResponse { impl Future for InOrderServiceResponse { type Output = Result>; - fn poll(mut self: Pin<&mut Self>, cx: &mut Context) -> Poll { + fn poll(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll { match Pin::new(&mut self.rx).poll(cx) { Poll::Pending => Poll::Pending, Poll::Ready(Ok(Ok(res))) => Poll::Ready(Ok(res)), @@ -221,7 +221,7 @@ mod tests { type Error = (); type Future = LocalBoxFuture<'static, Result>; - fn poll_ready(&mut self, _: &mut Context) -> Poll> { + fn poll_ready(&mut self, _: &mut Context<'_>) -> Poll> { Poll::Ready(Ok(())) } diff --git a/actix-utils/src/stream.rs b/actix-utils/src/stream.rs index 58534849..866bbf68 100644 --- a/actix-utils/src/stream.rs +++ b/actix-utils/src/stream.rs @@ -46,7 +46,7 @@ where { type Output = Result<(), T::Error>; - fn poll(mut self: Pin<&mut Self>, cx: &mut Context) -> Poll { + fn poll(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll { let mut this = self.as_mut().project(); if let Poll::Ready(Some(e)) = Pin::new(&mut this.err_rx).poll_next(cx) { @@ -85,7 +85,7 @@ where { type Output = (); - fn poll(self: Pin<&mut Self>, cx: &mut Context) -> Poll { + fn poll(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll { let this = self.project(); match this.fut.poll(cx) { diff --git a/actix-utils/src/task.rs b/actix-utils/src/task.rs index 1370a362..291b55d5 100644 --- a/actix-utils/src/task.rs +++ b/actix-utils/src/task.rs @@ -19,6 +19,7 @@ use std::{fmt, rc}; /// /// A single `AtomicWaker` may be reused for any number of calls to `register` or /// `wake`. +#[derive(Default)] pub struct LocalWaker { waker: UnsafeCell>, _t: PhantomData>, diff --git a/actix-utils/src/timeout.rs b/actix-utils/src/timeout.rs index 80337105..1ffb6956 100644 --- a/actix-utils/src/timeout.rs +++ b/actix-utils/src/timeout.rs @@ -34,7 +34,7 @@ impl From for TimeoutError { } impl fmt::Debug for TimeoutError { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { match self { TimeoutError::Service(e) => write!(f, "TimeoutError::Service({:?})", e), TimeoutError::Timeout => write!(f, "TimeoutError::Timeout"), @@ -43,7 +43,7 @@ impl fmt::Debug for TimeoutError { } impl fmt::Display for TimeoutError { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { match self { TimeoutError::Service(e) => e.fmt(f), TimeoutError::Timeout => write!(f, "Service call timeout"), @@ -193,7 +193,7 @@ mod tests { type Error = (); type Future = LocalBoxFuture<'static, Result<(), ()>>; - fn poll_ready(&mut self, _: &mut Context) -> Poll> { + fn poll_ready(&mut self, _: &mut Context<'_>) -> Poll> { Poll::Ready(Ok(())) }