1
0
mirror of https://github.com/fafhrd91/actix-net synced 2024-11-27 21:22:57 +01:00

clippy warnings

This commit is contained in:
Nikolay Kim 2019-12-02 22:30:09 +06:00
parent 9ed35cca7a
commit 9f575418c1
68 changed files with 355 additions and 452 deletions

View File

@ -1,5 +1,10 @@
# Changes # Changes
## [0.2.0-alpha.2]
* Migrated to `std::future`
## [0.1.2] - 2019-03-27 ## [0.1.2] - 2019-03-27
* Added `Framed::map_io()` method. * Added `Framed::map_io()` method.

View File

@ -1,6 +1,6 @@
[package] [package]
name = "actix-codec" name = "actix-codec"
version = "0.2.0-alpha.1" version = "0.2.0-alpha.2"
authors = ["Nikolay Kim <fafhrd91@gmail.com>"] authors = ["Nikolay Kim <fafhrd91@gmail.com>"]
description = "Utilities for encoding and decoding frames" description = "Utilities for encoding and decoding frames"
keywords = ["network", "framework", "async", "futures"] keywords = ["network", "framework", "async", "futures"]
@ -21,6 +21,6 @@ path = "src/lib.rs"
bytes = "0.4.12" bytes = "0.4.12"
futures = "0.3.1" futures = "0.3.1"
pin-project = "0.4.5" pin-project = "0.4.5"
tokio-io = "0.2.0-alpha.6" tokio-io = "=0.2.0-alpha.6"
tokio-codec = "0.2.0-alpha.6" tokio-codec = "=0.2.0-alpha.6"
log = "0.4" log = "0.4"

View File

@ -253,7 +253,7 @@ impl<T, U> Framed<T, U> {
len < self.write_hw len < self.write_hw
} }
pub fn next_item(&mut self, cx: &mut Context) -> Poll<Option<Result<U::Item, U::Error>>> pub fn next_item(&mut self, cx: &mut Context<'_>) -> Poll<Option<Result<U::Item, U::Error>>>
where where
T: AsyncRead, T: AsyncRead,
U: Decoder, U: Decoder,
@ -311,7 +311,7 @@ impl<T, U> Framed<T, U> {
} }
} }
pub fn flush(&mut self, cx: &mut Context) -> Poll<Result<(), U::Error>> pub fn flush(&mut self, cx: &mut Context<'_>) -> Poll<Result<(), U::Error>>
where where
T: AsyncWrite, T: AsyncWrite,
U: Encoder, U: Encoder,
@ -346,7 +346,7 @@ impl<T, U> Framed<T, U> {
Poll::Ready(Ok(())) Poll::Ready(Ok(()))
} }
pub fn close(&mut self, cx: &mut Context) -> Poll<Result<(), U::Error>> pub fn close(&mut self, cx: &mut Context<'_>) -> Poll<Result<(), U::Error>>
where where
T: AsyncWrite, T: AsyncWrite,
U: Encoder, U: Encoder,
@ -365,7 +365,7 @@ where
{ {
type Item = Result<U::Item, U::Error>; type Item = Result<U::Item, U::Error>;
fn poll_next(mut self: Pin<&mut Self>, cx: &mut Context) -> Poll<Option<Self::Item>> { fn poll_next(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Option<Self::Item>> {
self.next_item(cx) self.next_item(cx)
} }
} }
@ -378,7 +378,7 @@ where
{ {
type Error = U::Error; type Error = U::Error;
fn poll_ready(self: Pin<&mut Self>, _: &mut Context) -> Poll<Result<(), Self::Error>> { fn poll_ready(self: Pin<&mut Self>, _: &mut Context<'_>) -> Poll<Result<(), Self::Error>> {
if self.is_ready() { if self.is_ready() {
Poll::Ready(Ok(())) Poll::Ready(Ok(()))
} else { } else {
@ -393,11 +393,17 @@ where
self.write(item) self.write(item)
} }
fn poll_flush(mut self: Pin<&mut Self>, cx: &mut Context) -> Poll<Result<(), Self::Error>> { fn poll_flush(
mut self: Pin<&mut Self>,
cx: &mut Context<'_>,
) -> Poll<Result<(), Self::Error>> {
self.flush(cx) self.flush(cx)
} }
fn poll_close(mut self: Pin<&mut Self>, cx: &mut Context) -> Poll<Result<(), Self::Error>> { fn poll_close(
mut self: Pin<&mut Self>,
cx: &mut Context<'_>,
) -> Poll<Result<(), Self::Error>> {
self.close(cx) self.close(cx)
} }
} }
@ -407,7 +413,7 @@ where
T: fmt::Debug, T: fmt::Debug,
U: 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") f.debug_struct("Framed")
.field("io", &self.io) .field("io", &self.io)
.field("codec", &self.codec) .field("codec", &self.codec)

View File

@ -9,6 +9,8 @@
//! [`Sink`]: # //! [`Sink`]: #
//! [`Stream`]: # //! [`Stream`]: #
//! [transports]: # //! [transports]: #
#![deny(rust_2018_idioms, warnings)]
#![allow(clippy::type_complexity)]
mod bcodec; mod bcodec;
mod framed; mod framed;

View File

@ -1,5 +1,12 @@
# Changes # Changes
## [1.0.0-alpha.2] - 2019-12-02
### Changed
* Migrated to `std::future`
## [0.3.0] - 2019-10-03 ## [0.3.0] - 2019-10-03
### Changed ### Changed

View File

@ -1,6 +1,6 @@
[package] [package]
name = "actix-connect" name = "actix-connect"
version = "1.0.0-alpha.1" version = "1.0.0-alpha.2"
authors = ["Nikolay Kim <fafhrd91@gmail.com>"] authors = ["Nikolay Kim <fafhrd91@gmail.com>"]
description = "Actix connect - tcp connector service" description = "Actix connect - tcp connector service"
keywords = ["network", "framework", "async", "futures"] keywords = ["network", "framework", "async", "futures"]
@ -33,11 +33,11 @@ openssl = ["open-ssl", "tokio-openssl"]
uri = ["http"] uri = ["http"]
[dependencies] [dependencies]
actix-service = "1.0.0-alpha.1" actix-service = "1.0.0-alpha.2"
actix-codec = "0.2.0-alpha.1" actix-codec = "0.2.0-alpha.2"
actix-utils = "0.5.0-alpha.1" actix-utils = "1.0.0-alpha.2"
actix-rt = "1.0.0-alpha.1" actix-rt = "1.0.0-alpha.2"
derive_more = "0.99" derive_more = "0.99.2"
either = "1.5.2" either = "1.5.2"
futures = "0.3.1" futures = "0.3.1"
http = { version = "0.1.17", optional = true } http = { version = "0.1.17", optional = true }
@ -56,4 +56,4 @@ webpki = { version = "0.21", optional = true }
[dev-dependencies] [dev-dependencies]
bytes = "0.4" bytes = "0.4"
actix-testing = { version="0.3.0-alpha.1" } actix-testing = { version="1.0.0-alpha.2" }

View File

@ -132,7 +132,7 @@ impl<T: Address> From<T> for Connect<T> {
} }
impl<T: Address> fmt::Display for Connect<T> { impl<T: Address> fmt::Display for Connect<T> {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(f, "{}:{}", self.host(), self.port()) write!(f, "{}:{}", self.host(), self.port())
} }
} }
@ -163,7 +163,7 @@ impl Iterator for ConnectAddrsIter<'_> {
} }
impl fmt::Debug 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() f.debug_list().entries(self.clone()).finish()
} }
} }
@ -275,7 +275,7 @@ impl<T, U> std::ops::DerefMut for Connection<T, U> {
} }
impl<T, U: fmt::Debug> fmt::Debug for Connection<T, U> { impl<T, U: fmt::Debug> fmt::Debug for Connection<T, U> {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(f, "Stream {{{:?}}}", self.io) write!(f, "Stream {{{:?}}}", self.io)
} }
} }

View File

@ -76,7 +76,7 @@ impl<T: Address> Service for TcpConnector<T> {
type Error = ConnectError; type Error = ConnectError;
type Future = Either<TcpConnectorResponse<T>, Ready<Result<Self::Response, Self::Error>>>; type Future = Either<TcpConnectorResponse<T>, Ready<Result<Self::Response, Self::Error>>>;
fn poll_ready(&mut self, _: &mut Context) -> Poll<Result<(), Self::Error>> { fn poll_ready(&mut self, _: &mut Context<'_>) -> Poll<Result<(), Self::Error>> {
Poll::Ready(Ok(())) Poll::Ready(Ok(()))
} }
@ -134,7 +134,7 @@ impl<T: Address> TcpConnectorResponse<T> {
impl<T: Address> Future for TcpConnectorResponse<T> { impl<T: Address> Future for TcpConnectorResponse<T> {
type Output = Result<Connection<T, TcpStream>, ConnectError>; type Output = Result<Connection<T, TcpStream>, ConnectError>;
fn poll(self: Pin<&mut Self>, cx: &mut Context) -> Poll<Self::Output> { fn poll(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Self::Output> {
let this = self.get_mut(); let this = self.get_mut();
// connect // connect

View File

@ -2,9 +2,10 @@
//! //!
//! ## Package feature //! ## Package feature
//! //!
//! * `ssl` - enables ssl support via `openssl` crate //! * `openssl` - enables ssl support via `openssl` crate
//! * `rust-tls` - enables ssl support via `rustls` crate //! * `rustls` - enables ssl support via `rustls` crate
#![deny(rust_2018_idioms, warnings)]
#![allow(clippy::type_complexity)]
#![recursion_limit = "128"] #![recursion_limit = "128"]
#[macro_use] #[macro_use]
@ -43,7 +44,7 @@ struct DefaultResolver(AsyncResolver);
pub(crate) fn get_default_resolver() -> AsyncResolver { pub(crate) fn get_default_resolver() -> AsyncResolver {
if Arbiter::contains_item::<DefaultResolver>() { if Arbiter::contains_item::<DefaultResolver>() {
return Arbiter::get_item(|item: &DefaultResolver| item.0.clone()); Arbiter::get_item(|item: &DefaultResolver| item.0.clone())
} else { } else {
let (cfg, opts) = match read_system_conf() { let (cfg, opts) = match read_system_conf() {
Ok((cfg, opts)) => (cfg, opts), Ok((cfg, opts)) => (cfg, opts),

View File

@ -108,7 +108,7 @@ impl<T: Address> Service for Resolver<T> {
type Error = ConnectError; type Error = ConnectError;
type Future = Either<ResolverFuture<T>, Ready<Result<Connect<T>, Self::Error>>>; type Future = Either<ResolverFuture<T>, Ready<Result<Connect<T>, Self::Error>>>;
fn poll_ready(&mut self, _: &mut Context) -> Poll<Result<(), Self::Error>> { fn poll_ready(&mut self, _: &mut Context<'_>) -> Poll<Result<(), Self::Error>> {
Poll::Ready(Ok(())) Poll::Ready(Ok(()))
} }
@ -153,7 +153,7 @@ impl<T: Address> ResolverFuture<T> {
impl<T: Address> Future for ResolverFuture<T> { impl<T: Address> Future for ResolverFuture<T> {
type Output = Result<Connect<T>, ConnectError>; type Output = Result<Connect<T>, ConnectError>;
fn poll(self: Pin<&mut Self>, cx: &mut Context) -> Poll<Self::Output> { fn poll(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Self::Output> {
let this = self.get_mut(); let this = self.get_mut();
match Pin::new(&mut this.lookup).poll(cx) { match Pin::new(&mut this.lookup).poll(cx) {

View File

@ -96,7 +96,7 @@ impl<T: Address> Service for ConnectService<T> {
type Error = ConnectError; type Error = ConnectError;
type Future = ConnectServiceResponse<T>; type Future = ConnectServiceResponse<T>;
fn poll_ready(&mut self, _: &mut Context) -> Poll<Result<(), Self::Error>> { fn poll_ready(&mut self, _: &mut Context<'_>) -> Poll<Result<(), Self::Error>> {
Poll::Ready(Ok(())) Poll::Ready(Ok(()))
} }
@ -116,7 +116,7 @@ enum ConnectState<T: Address> {
impl<T: Address> ConnectState<T> { impl<T: Address> ConnectState<T> {
fn poll( fn poll(
&mut self, &mut self,
cx: &mut Context, cx: &mut Context<'_>,
) -> Either<Poll<Result<Connection<T, TcpStream>, ConnectError>>, Connect<T>> { ) -> Either<Poll<Result<Connection<T, TcpStream>, ConnectError>>, Connect<T>> {
match self { match self {
ConnectState::Resolve(ref mut fut) => match Pin::new(fut).poll(cx) { ConnectState::Resolve(ref mut fut) => match Pin::new(fut).poll(cx) {
@ -137,7 +137,7 @@ pub struct ConnectServiceResponse<T: Address> {
impl<T: Address> Future for ConnectServiceResponse<T> { impl<T: Address> Future for ConnectServiceResponse<T> {
type Output = Result<Connection<T, TcpStream>, ConnectError>; type Output = Result<Connection<T, TcpStream>, ConnectError>;
fn poll(mut self: Pin<&mut Self>, cx: &mut Context) -> Poll<Self::Output> { fn poll(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Self::Output> {
let res = match self.state.poll(cx) { let res = match self.state.poll(cx) {
Either::Right(res) => { Either::Right(res) => {
self.state = ConnectState::Connect(self.tcp.call(res)); self.state = ConnectState::Connect(self.tcp.call(res));
@ -165,7 +165,7 @@ impl<T: Address + 'static> Service for TcpConnectService<T> {
type Error = ConnectError; type Error = ConnectError;
type Future = TcpConnectServiceResponse<T>; type Future = TcpConnectServiceResponse<T>;
fn poll_ready(&mut self, _: &mut Context) -> Poll<Result<(), Self::Error>> { fn poll_ready(&mut self, _: &mut Context<'_>) -> Poll<Result<(), Self::Error>> {
Poll::Ready(Ok(())) Poll::Ready(Ok(()))
} }
@ -185,7 +185,7 @@ enum TcpConnectState<T: Address> {
impl<T: Address> TcpConnectState<T> { impl<T: Address> TcpConnectState<T> {
fn poll( fn poll(
&mut self, &mut self,
cx: &mut Context, cx: &mut Context<'_>,
) -> Either<Poll<Result<TcpStream, ConnectError>>, Connect<T>> { ) -> Either<Poll<Result<TcpStream, ConnectError>>, Connect<T>> {
match self { match self {
TcpConnectState::Resolve(ref mut fut) => match Pin::new(fut).poll(cx) { TcpConnectState::Resolve(ref mut fut) => match Pin::new(fut).poll(cx) {
@ -214,7 +214,7 @@ pub struct TcpConnectServiceResponse<T: Address> {
impl<T: Address> Future for TcpConnectServiceResponse<T> { impl<T: Address> Future for TcpConnectServiceResponse<T> {
type Output = Result<TcpStream, ConnectError>; type Output = Result<TcpStream, ConnectError>;
fn poll(mut self: Pin<&mut Self>, cx: &mut Context) -> Poll<Self::Output> { fn poll(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Self::Output> {
let res = match self.state.poll(cx) { let res = match self.state.poll(cx) {
Either::Right(res) => { Either::Right(res) => {
self.state = TcpConnectState::Connect(self.tcp.call(res)); self.state = TcpConnectState::Connect(self.tcp.call(res));

View File

@ -38,7 +38,7 @@ where
{ {
pub fn service(connector: SslConnector) -> OpensslConnectorService<T, U> { pub fn service(connector: SslConnector) -> OpensslConnectorService<T, U> {
OpensslConnectorService { OpensslConnectorService {
connector: connector, connector,
_t: PhantomData, _t: PhantomData,
} }
} }
@ -98,7 +98,7 @@ where
type Error = io::Error; type Error = io::Error;
type Future = Either<ConnectAsyncExt<T, U>, Ready<Result<Self::Response, Self::Error>>>; type Future = Either<ConnectAsyncExt<T, U>, Ready<Result<Self::Response, Self::Error>>>;
fn poll_ready(&mut self, _: &mut Context) -> Poll<Result<(), Self::Error>> { fn poll_ready(&mut self, _: &mut Context<'_>) -> Poll<Result<(), Self::Error>> {
Poll::Ready(Ok(())) Poll::Ready(Ok(()))
} }
@ -131,7 +131,7 @@ where
{ {
type Output = Result<Connection<T, SslStream<U>>, io::Error>; type Output = Result<Connection<T, SslStream<U>>, io::Error>;
fn poll(self: Pin<&mut Self>, cx: &mut Context) -> Poll<Self::Output> { fn poll(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Self::Output> {
let this = self.get_mut(); let this = self.get_mut();
match Pin::new(&mut this.fut).poll(cx) { match Pin::new(&mut this.fut).poll(cx) {
@ -218,7 +218,7 @@ impl<T: Address + 'static> Service for OpensslConnectService<T> {
type Error = ConnectError; type Error = ConnectError;
type Future = OpensslConnectServiceResponse<T>; type Future = OpensslConnectServiceResponse<T>;
fn poll_ready(&mut self, _: &mut Context) -> Poll<Result<(), Self::Error>> { fn poll_ready(&mut self, _: &mut Context<'_>) -> Poll<Result<(), Self::Error>> {
Poll::Ready(Ok(())) Poll::Ready(Ok(()))
} }
@ -240,14 +240,14 @@ pub struct OpensslConnectServiceResponse<T: Address + 'static> {
impl<T: Address> Future for OpensslConnectServiceResponse<T> { impl<T: Address> Future for OpensslConnectServiceResponse<T> {
type Output = Result<SslStream<TcpStream>, ConnectError>; type Output = Result<SslStream<TcpStream>, ConnectError>;
fn poll(mut self: Pin<&mut Self>, cx: &mut Context) -> Poll<Self::Output> { fn poll(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Self::Output> {
if let Some(ref mut fut) = self.fut1 { if let Some(ref mut fut) = self.fut1 {
match futures::ready!(Pin::new(fut).poll(cx)) { match futures::ready!(Pin::new(fut).poll(cx)) {
Ok(res) => { Ok(res) => {
let _ = self.fut1.take(); let _ = self.fut1.take();
self.fut2 = Some(self.openssl.call(res)); self.fut2 = Some(self.openssl.call(res));
} }
Err(e) => return Poll::Ready(Err(e.into())), Err(e) => return Poll::Ready(Err(e)),
} }
} }

View File

@ -1,5 +1,9 @@
# Changes # Changes
## [0.3.0-alpha.2] - 2019-12-02
* Migrate to `std::future`
## [0.1.1] - 2019-10-14 ## [0.1.1] - 2019-10-14

View File

@ -1,6 +1,6 @@
[package] [package]
name = "actix-ioframe" name = "actix-ioframe"
version = "0.3.0-alpha.1" version = "0.3.0-alpha.2"
authors = ["Nikolay Kim <fafhrd91@gmail.com>"] authors = ["Nikolay Kim <fafhrd91@gmail.com>"]
description = "Actix framed service" description = "Actix framed service"
keywords = ["network", "framework", "async", "futures"] keywords = ["network", "framework", "async", "futures"]
@ -18,16 +18,16 @@ name = "actix_ioframe"
path = "src/lib.rs" path = "src/lib.rs"
[dependencies] [dependencies]
actix-service = "1.0.0-alpha.1" actix-service = "1.0.0-alpha.2"
actix-codec = "0.2.0-alpha.1" actix-codec = "0.2.0-alpha.2"
actix-utils = "0.5.0-alpha.1" actix-utils = "1.0.0-alpha.2"
actix-rt = "1.0.0-alpha.1" actix-rt = "1.0.0-alpha.2"
bytes = "0.4" bytes = "0.4"
either = "1.5.2" either = "1.5.2"
futures = "0.3.1" futures = "0.3.1"
pin-project = "0.4.5" pin-project = "0.4.6"
log = "0.4" log = "0.4"
[dev-dependencies] [dev-dependencies]
actix-connect = "1.0.0-alpha.1" actix-connect = "1.0.0-alpha.2"
actix-testing = "0.3.0-alpha.1" actix-testing = "1.0.0-alpha.2"

View File

@ -17,7 +17,7 @@ impl<T> Clone for Cell<T> {
} }
impl<T: fmt::Debug> fmt::Debug for Cell<T> { impl<T: fmt::Debug> fmt::Debug for Cell<T> {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
self.inner.fmt(f) self.inner.fmt(f)
} }
} }

View File

@ -83,7 +83,7 @@ where
{ {
type Item = Result<<Codec as Decoder>::Item, <Codec as Decoder>::Error>; type Item = Result<<Codec as Decoder>::Item, <Codec as Decoder>::Error>;
fn poll_next(self: Pin<&mut Self>, cx: &mut Context) -> Poll<Option<Self::Item>> { fn poll_next(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Option<Self::Item>> {
self.project().framed.next_item(cx) self.project().framed.next_item(cx)
} }
} }
@ -95,7 +95,7 @@ where
{ {
type Error = <Codec as Encoder>::Error; type Error = <Codec as Encoder>::Error;
fn poll_ready(self: Pin<&mut Self>, _: &mut Context) -> Poll<Result<(), Self::Error>> { fn poll_ready(self: Pin<&mut Self>, _: &mut Context<'_>) -> Poll<Result<(), Self::Error>> {
if self.framed.is_ready() { if self.framed.is_ready() {
Poll::Ready(Ok(())) Poll::Ready(Ok(()))
} else { } else {

View File

@ -136,7 +136,7 @@ where
{ {
pub(crate) fn poll( pub(crate) fn poll(
&mut self, &mut self,
cx: &mut Context, cx: &mut Context<'_>,
) -> Poll<Result<(), ServiceError<S::Error, U>>> { ) -> Poll<Result<(), ServiceError<S::Error, U>>> {
let this = self; let this = self;
unsafe { this.inner.get_ref().task.register(cx.waker()) }; unsafe { this.inner.get_ref().task.register(cx.waker()) };
@ -156,7 +156,7 @@ where
} }
fn poll<St, S, T, U>( fn poll<St, S, T, U>(
cx: &mut Context, cx: &mut Context<'_>,
srv: &mut S, srv: &mut S,
state: &mut St, state: &mut St,
sink: &mut Sink<<U as Encoder>::Item>, sink: &mut Sink<<U as Encoder>::Item>,
@ -247,7 +247,7 @@ where
} }
fn poll_read<St, S, T, U>( fn poll_read<St, S, T, U>(
cx: &mut Context, cx: &mut Context<'_>,
srv: &mut S, srv: &mut S,
state: &mut St, state: &mut St,
sink: &mut Sink<<U as Encoder>::Item>, sink: &mut Sink<<U as Encoder>::Item>,
@ -310,7 +310,7 @@ where
/// write to framed object /// write to framed object
fn poll_write<St, S, T, U>( fn poll_write<St, S, T, U>(
cx: &mut Context, cx: &mut Context<'_>,
framed: &mut Framed<T, U>, framed: &mut Framed<T, U>,
dispatch_state: &mut FramedState<S, U>, dispatch_state: &mut FramedState<S, U>,
rx: &mut Option<mpsc::Receiver<FramedMessage<<U as Encoder>::Item>>>, rx: &mut Option<mpsc::Receiver<FramedMessage<<U as Encoder>::Item>>>,

View File

@ -24,7 +24,7 @@ where
<U as Encoder>::Error: fmt::Debug, <U as Encoder>::Error: fmt::Debug,
<U as Decoder>::Error: fmt::Debug, <U as Decoder>::Error: fmt::Debug,
{ {
fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result {
match *self { match *self {
ServiceError::Service(ref e) => write!(fmt, "ServiceError::Service({:?})", e), ServiceError::Service(ref e) => write!(fmt, "ServiceError::Service({:?})", e),
ServiceError::Encoder(ref e) => write!(fmt, "ServiceError::Encoder({:?})", e), ServiceError::Encoder(ref e) => write!(fmt, "ServiceError::Encoder({:?})", e),
@ -39,7 +39,7 @@ where
<U as Encoder>::Error: fmt::Debug, <U as Encoder>::Error: fmt::Debug,
<U as Decoder>::Error: fmt::Debug, <U as Decoder>::Error: fmt::Debug,
{ {
fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result {
match *self { match *self {
ServiceError::Service(ref e) => write!(fmt, "{}", e), ServiceError::Service(ref e) => write!(fmt, "{}", e),
ServiceError::Encoder(ref e) => write!(fmt, "{:?}", e), ServiceError::Encoder(ref e) => write!(fmt, "{:?}", e),

View File

@ -76,7 +76,7 @@ where
Codec: Encoder + Decoder, Codec: Encoder + Decoder,
<Codec as Decoder>::Item: fmt::Debug, <Codec as 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() f.debug_tuple("FramedItem").field(&self.item).finish()
} }
} }

View File

@ -1,3 +1,6 @@
#![deny(rust_2018_idioms, warnings)]
#![allow(clippy::type_complexity, clippy::too_many_arguments)]
mod cell; mod cell;
mod connect; mod connect;
mod dispatcher; mod dispatcher;

View File

@ -22,6 +22,12 @@ type ResponseItem<U> = Option<<U as Encoder>::Item>;
/// for building instances for framed services. /// for building instances for framed services.
pub struct Builder<St, Codec>(PhantomData<(St, Codec)>); pub struct Builder<St, Codec>(PhantomData<(St, Codec)>);
impl<St: Clone, Codec> Default for Builder<St, Codec> {
fn default() -> Builder<St, Codec> {
Builder::new()
}
}
impl<St: Clone, Codec> Builder<St, Codec> { impl<St: Clone, Codec> Builder<St, Codec> {
pub fn new() -> Builder<St, Codec> { pub fn new() -> Builder<St, Codec> {
Builder(PhantomData) Builder(PhantomData)
@ -251,7 +257,7 @@ where
type Error = ServiceError<C::Error, Codec>; type Error = ServiceError<C::Error, Codec>;
type Future = FramedServiceImplResponse<St, Io, Codec, C, T>; type Future = FramedServiceImplResponse<St, Io, Codec, C, T>;
fn poll_ready(&mut self, cx: &mut Context) -> Poll<Result<(), Self::Error>> { fn poll_ready(&mut self, cx: &mut Context<'_>) -> Poll<Result<(), Self::Error>> {
self.connect.poll_ready(cx).map_err(|e| e.into()) self.connect.poll_ready(cx).map_err(|e| e.into())
} }
@ -309,7 +315,7 @@ where
{ {
type Output = Result<(), ServiceError<C::Error, Codec>>; type Output = Result<(), ServiceError<C::Error, Codec>>;
fn poll(mut self: Pin<&mut Self>, cx: &mut Context) -> Poll<Self::Output> { fn poll(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Self::Output> {
let mut this = self.as_mut().project(); let mut this = self.as_mut().project();
loop { loop {
@ -373,7 +379,7 @@ where
#[project] #[project]
fn poll( fn poll(
self: Pin<&mut Self>, self: Pin<&mut Self>,
cx: &mut Context, cx: &mut Context<'_>,
) -> Either< ) -> Either<
FramedServiceImplResponseInner<St, Io, Codec, C, T>, FramedServiceImplResponseInner<St, Io, Codec, C, T>,
Poll<Result<(), ServiceError<C::Error, Codec>>>, Poll<Result<(), ServiceError<C::Error, Codec>>>,

View File

@ -38,7 +38,7 @@ impl<T> Sink<T> {
} }
impl<T> fmt::Debug for Sink<T> { impl<T> fmt::Debug for Sink<T> {
fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result {
fmt.debug_struct("Sink").finish() fmt.debug_struct("Sink").finish()
} }
} }

View File

@ -1,6 +1,6 @@
# Changes # Changes
## [1.0.0-alpha.2] - 2019-11-xx ## [1.0.0-alpha.2] - 2019-12-02
Added Added
@ -8,6 +8,8 @@ Added
* Export `time` module (re-export of tokio-timer) * Export `time` module (re-export of tokio-timer)
* Export `net` module (re-export of tokio-net)
## [1.0.0-alpha.1] - 2019-11-22 ## [1.0.0-alpha.1] - 2019-11-22

View File

@ -32,7 +32,7 @@ pub(crate) enum ArbiterCommand {
} }
impl fmt::Debug for 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 { match self {
ArbiterCommand::Stop => write!(f, "ArbiterCommand::Stop"), ArbiterCommand::Stop => write!(f, "ArbiterCommand::Stop"),
ArbiterCommand::Execute(_) => write!(f, "ArbiterCommand::Execute"), ArbiterCommand::Execute(_) => write!(f, "ArbiterCommand::Execute"),

View File

@ -1,4 +1,6 @@
//! A runtime implementation that runs everything on the current thread. //! 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 #[cfg(not(test))] // Work around for rust-lang/rust#62127
pub use actix_macros::{main, test}; pub use actix_macros::{main, test};

View File

@ -32,7 +32,7 @@ pub struct RunError {
} }
impl fmt::Display for 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) write!(fmt, "{}", self.inner)
} }
} }

View File

@ -1,9 +1,11 @@
# Changes # Changes
## [0.8.0-alpha.2] - 2019-11-xx ## [1.0.0-alpha.2] - 2019-12-02
### Changed ### Changed
* Simplify server service (remove actix-server-config)
* Allow to wait on `Server` until server stops * Allow to wait on `Server` until server stops

View File

@ -1,6 +1,6 @@
[package] [package]
name = "actix-server" name = "actix-server"
version = "0.8.0-alpha.2" version = "1.0.0-alpha.2"
authors = ["Nikolay Kim <fafhrd91@gmail.com>"] authors = ["Nikolay Kim <fafhrd91@gmail.com>"]
description = "Actix server - General purpose tcp server" description = "Actix server - General purpose tcp server"
keywords = ["network", "framework", "async", "futures"] keywords = ["network", "framework", "async", "futures"]
@ -21,9 +21,10 @@ path = "src/lib.rs"
default = [] default = []
[dependencies] [dependencies]
actix-service = "1.0.0-alpha.1" actix-service = "1.0.0-alpha.2"
actix-rt = "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" log = "0.4"
num_cpus = "1.0" num_cpus = "1.0"
@ -40,5 +41,4 @@ mio-uds = { version = "0.6.7" }
[dev-dependencies] [dev-dependencies]
bytes = "0.4" bytes = "0.4"
actix-codec = "0.2.0-alpha.1"
env_logger = "0.6" env_logger = "0.6"

View File

@ -3,6 +3,7 @@ use std::{fmt, io, net};
use actix_rt::net::TcpStream; use actix_rt::net::TcpStream;
use actix_service as actix; use actix_service as actix;
use actix_utils::counter::CounterGuard;
use futures::future::{Future, FutureExt, LocalBoxFuture}; use futures::future::{Future, FutureExt, LocalBoxFuture};
use log::error; use log::error;
@ -11,7 +12,6 @@ use super::service::{
BoxedServerService, InternalServiceFactory, ServerMessage, StreamService, BoxedServerService, InternalServiceFactory, ServerMessage, StreamService,
}; };
use super::Token; use super::Token;
use crate::counter::CounterGuard;
pub struct ServiceConfig { pub struct ServiceConfig {
pub(crate) services: Vec<(String, net::TcpListener)>, pub(crate) services: Vec<(String, net::TcpListener)>,
@ -126,9 +126,9 @@ impl InternalServiceFactory for ConfiguredService {
Ok(serv) => { Ok(serv) => {
res.push((token, serv)); res.push((token, serv));
} }
Err(e) => { Err(_) => {
error!("Can not construct service {:?}", e); error!("Can not construct service");
return Err(e); return Err(());
} }
}; };
} }

View File

@ -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<CounterInner>);
#[derive(Debug)]
struct CounterInner {
count: Cell<usize>,
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<CounterInner>);
impl CounterGuard {
fn new(inner: Rc<CounterInner>) -> 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
}
}

View File

@ -1,9 +1,10 @@
//! General purpose tcp server //! General purpose tcp server
#![deny(rust_2018_idioms, warnings)]
#![allow(clippy::type_complexity)]
mod accept; mod accept;
mod builder; mod builder;
mod config; mod config;
mod counter;
mod server; mod server;
mod service; mod service;
mod signals; mod signals;

View File

@ -88,7 +88,7 @@ impl Clone for Server {
impl Future for Server { impl Future for Server {
type Output = io::Result<()>; type Output = io::Result<()>;
fn poll(self: Pin<&mut Self>, cx: &mut Context) -> Poll<Self::Output> { fn poll(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Self::Output> {
let this = self.get_mut(); let this = self.get_mut();
if this.1.is_none() { if this.1.is_none() {

View File

@ -5,12 +5,12 @@ use std::time::Duration;
use actix_rt::spawn; use actix_rt::spawn;
use actix_service::{self as actix, Service, ServiceFactory as ActixServiceFactory}; use actix_service::{self as actix, Service, ServiceFactory as ActixServiceFactory};
use actix_utils::counter::CounterGuard;
use futures::future::{err, ok, LocalBoxFuture, Ready}; use futures::future::{err, ok, LocalBoxFuture, Ready};
use futures::{FutureExt, TryFutureExt}; use futures::{FutureExt, TryFutureExt};
use log::error; use log::error;
use super::Token; use super::Token;
use crate::counter::CounterGuard;
use crate::socket::{FromStream, StdStream}; use crate::socket::{FromStream, StdStream};
/// Server message /// Server message

View File

@ -50,10 +50,8 @@ impl Signals {
(unix::SignalKind::quit(), Signal::Quit), (unix::SignalKind::quit(), Signal::Quit),
]; ];
for (kind, sig) in sig_map.into_iter() { for (kind, sig) in sig_map.iter() {
let sig = sig.clone(); streams.push((*sig, unix::signal(*kind)?));
let fut = unix::signal(*kind)?;
streams.push((sig, fut));
} }
Signals { srv, streams } Signals { srv, streams }

View File

@ -6,6 +6,7 @@ use std::{mem, time};
use actix_rt::time::{delay, Delay}; use actix_rt::time::{delay, Delay};
use actix_rt::{spawn, Arbiter}; use actix_rt::{spawn, Arbiter};
use actix_utils::counter::Counter;
use futures::channel::mpsc::{UnboundedReceiver, UnboundedSender}; use futures::channel::mpsc::{UnboundedReceiver, UnboundedSender};
use futures::channel::oneshot; use futures::channel::oneshot;
use futures::future::{join_all, LocalBoxFuture, MapOk}; use futures::future::{join_all, LocalBoxFuture, MapOk};
@ -13,7 +14,6 @@ use futures::{Future, FutureExt, Stream, TryFutureExt};
use log::{error, info, trace}; use log::{error, info, trace};
use crate::accept::AcceptNotify; use crate::accept::AcceptNotify;
use crate::counter::Counter;
use crate::service::{BoxedServerService, InternalServiceFactory, ServerMessage}; use crate::service::{BoxedServerService, InternalServiceFactory, ServerMessage};
use crate::socket::{SocketAddr, StdStream}; use crate::socket::{SocketAddr, StdStream};
use crate::Token; use crate::Token;
@ -332,11 +332,11 @@ impl Future for Worker {
} }
} }
self.availability.set(true); self.availability.set(true);
return self.poll(cx); self.poll(cx)
} }
Ok(false) => { Ok(false) => {
self.state = WorkerState::Unavailable(conns); self.state = WorkerState::Unavailable(conns);
return Poll::Pending; Poll::Pending
} }
Err((token, idx)) => { Err((token, idx)) => {
trace!( trace!(
@ -345,7 +345,7 @@ impl Future for Worker {
); );
self.state = self.state =
WorkerState::Restarting(idx, token, self.factories[idx].create()); 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 Poll::Pending;
} }
} }
return self.poll(cx); self.poll(cx)
} }
WorkerState::Shutdown(mut t1, mut t2, tx) => { WorkerState::Shutdown(mut t1, mut t2, tx) => {
let num = num_connections(); let num = num_connections();
@ -402,7 +402,7 @@ impl Future for Worker {
} }
} }
self.state = WorkerState::Shutdown(t1, t2, tx); self.state = WorkerState::Shutdown(t1, t2, tx);
return Poll::Pending; Poll::Pending
} }
WorkerState::Available => { WorkerState::Available => {
loop { loop {
@ -448,6 +448,6 @@ impl Future for Worker {
} }
} }
WorkerState::None => panic!(), WorkerState::None => panic!(),
}; }
} }
} }

View File

@ -1,6 +1,8 @@
# Changes # 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 ### Renamed BoxedNewService/BoxedService to BoxServiceFactory/BoxService

View File

@ -24,7 +24,7 @@ path = "src/lib.rs"
[dependencies] [dependencies]
futures = "0.3.1" futures = "0.3.1"
pin-project = "0.4.6" pin-project-lite = "0.1.1"
[dev-dependencies] [dev-dependencies]
actix-rt = "1.0.0-alpha.1" actix-rt = "1.0.0-alpha.2"

View File

@ -61,17 +61,18 @@ where
} }
} }
#[pin_project::pin_project] pin_project! {
pub struct AndThenServiceResponse<A, B> pub struct AndThenServiceResponse<A, B>
where where
A: Service, A: Service,
B: Service<Request = A::Response, Error = A::Error>, B: Service<Request = A::Response, Error = A::Error>,
{ {
b: Cell<B>, b: Cell<B>,
#[pin] #[pin]
fut_b: Option<B::Future>, fut_b: Option<B::Future>,
#[pin] #[pin]
fut_a: Option<A::Future>, fut_a: Option<A::Future>,
}
} }
impl<A, B> AndThenServiceResponse<A, B> impl<A, B> AndThenServiceResponse<A, B>
@ -189,12 +190,12 @@ where
} }
} }
#[pin_project::pin_project] pin_project! {
pub struct AndThenServiceFactoryResponse<A, B> pub struct AndThenServiceFactoryResponse<A, B>
where where
A: ServiceFactory, A: ServiceFactory,
B: ServiceFactory<Request = A::Response>, B: ServiceFactory<Request = A::Response>,
{ {
#[pin] #[pin]
fut_b: B::Future, fut_b: B::Future,
#[pin] #[pin]
@ -202,6 +203,7 @@ where
a: Option<A::Service>, a: Option<A::Service>,
b: Option<B::Service>, b: Option<B::Service>,
}
} }
impl<A, B> AndThenServiceFactoryResponse<A, B> impl<A, B> AndThenServiceFactoryResponse<A, B>
@ -287,7 +289,7 @@ mod tests {
type Error = (); type Error = ();
type Future = Ready<Result<Self::Response, ()>>; type Future = Ready<Result<Self::Response, ()>>;
fn poll_ready(&mut self, _: &mut Context) -> Poll<Result<(), Self::Error>> { fn poll_ready(&mut self, _: &mut Context<'_>) -> Poll<Result<(), Self::Error>> {
self.0.set(self.0.get() + 1); self.0.set(self.0.get() + 1);
Poll::Ready(Ok(())) Poll::Ready(Ok(()))
} }

View File

@ -122,17 +122,18 @@ where
} }
} }
#[pin_project::pin_project] pin_project! {
pub struct ApplyServiceFactoryResponse<T, F, R, In, Out, Err> pub struct ApplyServiceFactoryResponse<T, F, R, In, Out, Err>
where where
T: ServiceFactory<Error = Err>, T: ServiceFactory<Error = Err>,
F: FnMut(In, &mut T::Service) -> R + Clone, F: FnMut(In, &mut T::Service) -> R,
R: Future<Output = Result<Out, Err>>, R: Future<Output = Result<Out, Err>>,
{ {
#[pin] #[pin]
fut: T::Future, fut: T::Future,
f: Option<F>, f: Option<F>,
r: PhantomData<(In, Out)>, r: PhantomData<(In, Out)>,
}
} }
impl<T, F, R, In, Out, Err> ApplyServiceFactoryResponse<T, F, R, In, Out, Err> impl<T, F, R, In, Out, Err> ApplyServiceFactoryResponse<T, F, R, In, Out, Err>
@ -187,7 +188,7 @@ mod tests {
type Error = (); type Error = ();
type Future = Ready<Result<(), ()>>; type Future = Ready<Result<(), ()>>;
fn poll_ready(&mut self, _: &mut Context) -> Poll<Result<(), Self::Error>> { fn poll_ready(&mut self, _: &mut Context<'_>) -> Poll<Result<(), Self::Error>> {
Poll::Ready(Ok(())) Poll::Ready(Ok(()))
} }

View File

@ -149,15 +149,15 @@ where
} }
} }
#[pin_project::pin_project] pin_project! {
pub struct ApplyConfigServiceFactoryResponse<F, C, T, R, S> pub struct ApplyConfigServiceFactoryResponse<F, C, T, R, S>
where where
F: FnMut(C, &mut T::Service) -> R, F: FnMut(C, &mut T::Service) -> R,
T: ServiceFactory<Config = ()>, T: ServiceFactory<Config = ()>,
T::InitError: From<T::Error>, T::InitError: From<T::Error>,
R: Future<Output = Result<S, T::InitError>>, R: Future<Output = Result<S, T::InitError>>,
S: Service, S: Service,
{ {
cfg: Option<C>, cfg: Option<C>,
f: Cell<F>, f: Cell<F>,
srv: Option<T::Service>, srv: Option<T::Service>,
@ -166,6 +166,7 @@ where
#[pin] #[pin]
fut: Option<R>, fut: Option<R>,
_t: PhantomData<(S,)>, _t: PhantomData<(S,)>,
}
} }
impl<F, C, T, R, S> Future for ApplyConfigServiceFactoryResponse<F, C, T, R, S> impl<F, C, T, R, S> Future for ApplyConfigServiceFactoryResponse<F, C, T, R, S>

View File

@ -14,7 +14,7 @@ impl<T> Clone for Cell<T> {
} }
impl<T: fmt::Debug> fmt::Debug for Cell<T> { impl<T: fmt::Debug> fmt::Debug for Cell<T> {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
self.inner.fmt(f) self.inner.fmt(f)
} }
} }

View File

@ -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::cell::RefCell;
use std::future::Future; use std::future::Future;
use std::rc::Rc; use std::rc::Rc;

View File

@ -62,15 +62,16 @@ where
} }
} }
#[pin_project::pin_project] pin_project! {
pub struct MapFuture<A, F, Response> pub struct MapFuture<A, F, Response>
where where
A: Service, A: Service,
F: FnMut(A::Response) -> Response, F: FnMut(A::Response) -> Response,
{ {
f: F, f: F,
#[pin] #[pin]
fut: A::Future, fut: A::Future,
}
} }
impl<A, F, Response> MapFuture<A, F, Response> impl<A, F, Response> MapFuture<A, F, Response>
@ -156,15 +157,16 @@ where
} }
} }
#[pin_project::pin_project] pin_project! {
pub struct MapServiceFuture<A, F, Res> pub struct MapServiceFuture<A, F, Res>
where where
A: ServiceFactory, A: ServiceFactory,
F: FnMut(A::Response) -> Res, F: FnMut(A::Response) -> Res,
{ {
#[pin] #[pin]
fut: A::Future, fut: A::Future,
f: Option<F>, f: Option<F>,
}
} }
impl<A, F, Res> MapServiceFuture<A, F, Res> impl<A, F, Res> MapServiceFuture<A, F, Res>
@ -210,7 +212,7 @@ mod tests {
type Error = (); type Error = ();
type Future = Ready<Result<(), ()>>; type Future = Ready<Result<(), ()>>;
fn poll_ready(&mut self, _: &mut Context) -> Poll<Result<(), Self::Error>> { fn poll_ready(&mut self, _: &mut Context<'_>) -> Poll<Result<(), Self::Error>> {
Poll::Ready(Ok(())) Poll::Ready(Ok(()))
} }

View File

@ -63,15 +63,16 @@ where
} }
} }
#[pin_project::pin_project] pin_project! {
pub struct MapErrFuture<A, F, E> pub struct MapErrFuture<A, F, E>
where where
A: Service, A: Service,
F: Fn(A::Error) -> E, F: Fn(A::Error) -> E,
{ {
f: F, f: F,
#[pin] #[pin]
fut: A::Future, fut: A::Future,
}
} }
impl<A, F, E> MapErrFuture<A, F, E> impl<A, F, E> MapErrFuture<A, F, E>
@ -159,15 +160,16 @@ where
} }
} }
#[pin_project::pin_project] pin_project! {
pub struct MapErrServiceFuture<A, F, E> pub struct MapErrServiceFuture<A, F, E>
where where
A: ServiceFactory, A: ServiceFactory,
F: Fn(A::Error) -> E, F: Fn(A::Error) -> E,
{ {
#[pin] #[pin]
fut: A::Future, fut: A::Future,
f: F, f: F,
}
} }
impl<A, F, E> MapErrServiceFuture<A, F, E> impl<A, F, E> MapErrServiceFuture<A, F, E>
@ -212,7 +214,7 @@ mod tests {
type Error = (); type Error = ();
type Future = Ready<Result<(), ()>>; type Future = Ready<Result<(), ()>>;
fn poll_ready(&mut self, _: &mut Context) -> Poll<Result<(), Self::Error>> { fn poll_ready(&mut self, _: &mut Context<'_>) -> Poll<Result<(), Self::Error>> {
Poll::Ready(Err(())) Poll::Ready(Err(()))
} }

View File

@ -60,15 +60,16 @@ where
} }
} }
#[pin_project::pin_project] pin_project! {
pub struct MapInitErrFuture<A, F, E> pub struct MapInitErrFuture<A, F, E>
where where
A: ServiceFactory, A: ServiceFactory,
F: Fn(A::InitError) -> E, F: Fn(A::InitError) -> E,
{ {
f: F, f: F,
#[pin] #[pin]
fut: A::Future, fut: A::Future,
}
} }
impl<A, F, E> MapInitErrFuture<A, F, E> impl<A, F, E> MapInitErrFuture<A, F, E>

View File

@ -61,17 +61,18 @@ where
} }
} }
#[pin_project::pin_project] pin_project! {
pub struct ThenServiceResponse<A, B> pub struct ThenServiceResponse<A, B>
where where
A: Service, A: Service,
B: Service<Request = Result<A::Response, A::Error>>, B: Service<Request = Result<A::Response, A::Error>>,
{ {
b: Cell<B>, b: Cell<B>,
#[pin] #[pin]
fut_b: Option<B::Future>, fut_b: Option<B::Future>,
#[pin] #[pin]
fut_a: Option<A::Future>, fut_a: Option<A::Future>,
}
} }
impl<A, B> ThenServiceResponse<A, B> impl<A, B> ThenServiceResponse<A, B>
@ -184,23 +185,23 @@ where
} }
} }
#[pin_project::pin_project] pin_project! {
pub struct ThenServiceFactoryResponse<A, B> pub struct ThenServiceFactoryResponse<A, B>
where where
A: ServiceFactory, A: ServiceFactory,
B: ServiceFactory< B: ServiceFactory<
Config = A::Config, Config = A::Config,
Request = Result<A::Response, A::Error>, Request = Result<A::Response, A::Error>,
Error = A::Error, Error = A::Error,
InitError = A::InitError, InitError = A::InitError>
>, {
{
#[pin] #[pin]
fut_b: B::Future, fut_b: B::Future,
#[pin] #[pin]
fut_a: A::Future, fut_a: A::Future,
a: Option<A::Service>, a: Option<A::Service>,
b: Option<B::Service>, b: Option<B::Service>,
}
} }
impl<A, B> ThenServiceFactoryResponse<A, B> impl<A, B> ThenServiceFactoryResponse<A, B>

View File

@ -134,17 +134,18 @@ where
} }
} }
#[pin_project::pin_project] pin_project! {
pub struct ApplyTransformFuture<T, S> pub struct ApplyTransformFuture<T, S>
where where
S: ServiceFactory, S: ServiceFactory,
T: Transform<S::Service, InitError = S::InitError>, T: Transform<S::Service, InitError = S::InitError>,
{ {
#[pin] #[pin]
fut_a: S::Future, fut_a: S::Future,
#[pin] #[pin]
fut_t: Option<T::Future>, fut_t: Option<T::Future>,
t_cell: Rc<T>, t_cell: Rc<T>,
}
} }
impl<T, S> Future for ApplyTransformFuture<T, S> impl<T, S> Future for ApplyTransformFuture<T, S>
@ -167,7 +168,7 @@ where
this.fut_t.set(Some(fut)); this.fut_t.set(Some(fut));
this.fut_t.as_pin_mut().unwrap().poll(cx) this.fut_t.as_pin_mut().unwrap().poll(cx)
} else { } else {
return Poll::Pending; Poll::Pending
} }
} }
} }

View File

@ -1,6 +1,6 @@
# Changes # Changes
## [0.3.0-alpha.2] - 2019-11-xx ## [1.0.0-alpha.2] - 2019-12-02
* Re-export `test` attribute macros * Re-export `test` attribute macros

View File

@ -1,6 +1,6 @@
[package] [package]
name = "actix-testing" name = "actix-testing"
version = "0.3.0-alpha.2" version = "1.0.0-alpha.2"
authors = ["Nikolay Kim <fafhrd91@gmail.com>"] authors = ["Nikolay Kim <fafhrd91@gmail.com>"]
description = "Actix testing utils" description = "Actix testing utils"
keywords = ["network", "framework", "async", "futures"] keywords = ["network", "framework", "async", "futures"]
@ -17,11 +17,10 @@ name = "actix_testing"
path = "src/lib.rs" path = "src/lib.rs"
[dependencies] [dependencies]
actix-rt = "1.0.0-alpha.1" actix-rt = "1.0.0-alpha.2"
actix-macros = "0.1.0-alpha.1" actix-macros = "0.1.0-alpha.1"
actix-server = "0.8.0-alpha.1" actix-server = "1.0.0-alpha.2"
actix-server-config = "0.3.0-alpha.1" actix-service = "1.0.0-alpha.2"
actix-service = "1.0.0-alpha.1"
log = "0.4" log = "0.4"
net2 = "0.2" net2 = "0.2"

View File

@ -1,10 +1,12 @@
//! Various helpers for Actix applications to use during testing. //! Various helpers for Actix applications to use during testing.
#![deny(rust_2018_idioms, warnings)]
#![allow(clippy::type_complexity)]
use std::sync::mpsc; use std::sync::mpsc;
use std::{net, thread}; use std::{net, thread};
use actix_rt::{net::TcpStream, System}; use actix_rt::{net::TcpStream, System};
use actix_server::{Server, ServerBuilder, ServiceFactory}; use actix_server::{Server, ServerBuilder, ServiceFactory};
pub use actix_server_config::{Io, ServerConfig};
use net2::TcpBuilder; use net2::TcpBuilder;
use tokio_net::driver::Handle; use tokio_net::driver::Handle;
@ -46,7 +48,7 @@ pub struct TestServerRuntime {
impl TestServer { impl TestServer {
/// Start new server with server builder /// Start new server with server builder
pub fn new<F>(mut factory: F) -> TestServerRuntime pub fn start<F>(mut factory: F) -> TestServerRuntime
where where
F: FnMut(ServerBuilder) -> ServerBuilder + Send + 'static, F: FnMut(ServerBuilder) -> ServerBuilder + Send + 'static,
{ {

View File

@ -1,90 +1,5 @@
# Changes # Changes
## [0.3.0] - 2019-10-03 ## [1.0.0-alpha.1] - 2019-12-02
### Changed * Split openssl accetor from actix-server package
* 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

View File

@ -29,11 +29,11 @@ openssl = ["open-ssl", "tokio-openssl"]
rustls = ["rust-tls", "webpki"] rustls = ["rust-tls", "webpki"]
[dependencies] [dependencies]
actix-service = "1.0.0-alpha.1" actix-service = "1.0.0-alpha.2"
actix-codec = "0.2.0-alpha.1" actix-codec = "0.2.0-alpha.2"
actix-utils = "0.5.0-alpha.1" actix-utils = "1.0.0-alpha.2"
actix-rt = "1.0.0-alpha.1" actix-rt = "1.0.0-alpha.2"
derive_more = "0.99" derive_more = "0.99.2"
either = "1.5.2" either = "1.5.2"
futures = "0.3.1" futures = "0.3.1"
log = "0.4" log = "0.4"
@ -51,4 +51,4 @@ webpki-roots = { version = "0.17", optional = true }
[dev-dependencies] [dev-dependencies]
bytes = "0.4" bytes = "0.4"
actix-testing = { version="0.3.0-alpha.1" } actix-testing = { version="1.0.0-alpha.2" }

View File

@ -1,4 +1,7 @@
//! SSL Services //! SSL Services
#![deny(rust_2018_idioms, warnings)]
#![allow(clippy::type_complexity)]
use std::sync::atomic::{AtomicUsize, Ordering}; use std::sync::atomic::{AtomicUsize, Ordering};
use actix_utils::counter::Counter; use actix_utils::counter::Counter;

View File

@ -1,5 +1,9 @@
# Changes # Changes
## [1.0.0-alpha.2] - 2019-12-02
* Migrate to `std::future`
## [0.4.7] - 2019-10-14 ## [0.4.7] - 2019-10-14
* Re-register task on every framed transport poll. * Re-register task on every framed transport poll.

View File

@ -1,6 +1,6 @@
[package] [package]
name = "actix-utils" name = "actix-utils"
version = "0.5.0-alpha1" version = "1.0.0-alpha.2"
authors = ["Nikolay Kim <fafhrd91@gmail.com>"] authors = ["Nikolay Kim <fafhrd91@gmail.com>"]
description = "Actix utils - various actix net related services" description = "Actix utils - various actix net related services"
keywords = ["network", "framework", "async", "futures"] keywords = ["network", "framework", "async", "futures"]
@ -18,11 +18,11 @@ name = "actix_utils"
path = "src/lib.rs" path = "src/lib.rs"
[dependencies] [dependencies]
actix-service = "1.0.0-alpha.1" actix-service = "1.0.0-alpha.2"
actix-rt = "1.0.0-alpha.1" actix-rt = "1.0.0-alpha.2"
actix-codec = "0.2.0-alpha.1" actix-codec = "0.2.0-alpha.2"
bytes = "0.4" bytes = "0.4"
either = "1.5.2" either = "1.5.2"
futures = "0.3.1" futures = "0.3.1"
pin-project = "0.4.5" pin-project = "0.4.6"
log = "0.4" log = "0.4"

View File

@ -17,7 +17,7 @@ impl<T> Clone for Cell<T> {
} }
impl<T: fmt::Debug> fmt::Debug for Cell<T> { impl<T: fmt::Debug> fmt::Debug for Cell<T> {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
self.inner.fmt(f) self.inner.fmt(f)
} }
} }

View File

@ -33,7 +33,7 @@ impl Counter {
/// Check if counter is not at capacity. If counter at capacity /// Check if counter is not at capacity. If counter at capacity
/// it registers notification for current task. /// 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) 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 { if self.count.get() < self.capacity {
true true
} else { } else {

View File

@ -34,7 +34,7 @@ where
type Error = A::Error; type Error = A::Error;
type Future = future::Either<A::Future, B::Future>; type Future = future::Either<A::Future, B::Future>;
fn poll_ready(&mut self, cx: &mut Context) -> Poll<Result<(), Self::Error>> { fn poll_ready(&mut self, cx: &mut Context<'_>) -> Poll<Result<(), Self::Error>> {
let left = self.left.poll_ready(cx)?; let left = self.left.poll_ready(cx)?;
let right = self.right.poll_ready(cx)?; let right = self.right.poll_ready(cx)?;
@ -131,7 +131,7 @@ where
{ {
type Output = Result<EitherService<A::Service, B::Service>, A::InitError>; type Output = Result<EitherService<A::Service, B::Service>, A::InitError>;
fn poll(self: Pin<&mut Self>, cx: &mut Context) -> Poll<Self::Output> { fn poll(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Self::Output> {
let this = self.project(); let this = self.project();
if this.left.is_none() { if this.left.is_none() {

View File

@ -37,7 +37,7 @@ where
<U as Encoder>::Error: fmt::Debug, <U as Encoder>::Error: fmt::Debug,
<U as Decoder>::Error: fmt::Debug, <U as Decoder>::Error: fmt::Debug,
{ {
fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result {
match *self { match *self {
FramedTransportError::Service(ref e) => { FramedTransportError::Service(ref e) => {
write!(fmt, "FramedTransportError::Service({:?})", e) write!(fmt, "FramedTransportError::Service({:?})", e)
@ -58,7 +58,7 @@ where
<U as Encoder>::Error: fmt::Debug, <U as Encoder>::Error: fmt::Debug,
<U as Decoder>::Error: fmt::Debug, <U as Decoder>::Error: fmt::Debug,
{ {
fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result {
match *self { match *self {
FramedTransportError::Service(ref e) => write!(fmt, "{}", e), FramedTransportError::Service(ref e) => write!(fmt, "{}", e),
FramedTransportError::Encoder(ref e) => write!(fmt, "{:?}", e), FramedTransportError::Encoder(ref e) => write!(fmt, "{:?}", e),
@ -177,7 +177,7 @@ where
{ {
type Output = Result<(), FramedTransportError<S::Error, U>>; type Output = Result<(), FramedTransportError<S::Error, U>>;
fn poll(self: Pin<&mut Self>, cx: &mut Context) -> Poll<Self::Output> { fn poll(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Self::Output> {
self.inner.get_ref().task.register(cx.waker()); self.inner.get_ref().task.register(cx.waker());
let this = self.project(); let this = self.project();
@ -193,7 +193,7 @@ where
} }
fn poll<S, T, U>( fn poll<S, T, U>(
cx: &mut Context, cx: &mut Context<'_>,
srv: &mut S, srv: &mut S,
state: &mut TransportState<S, U>, state: &mut TransportState<S, U>,
framed: &mut Framed<T, U>, framed: &mut Framed<T, U>,
@ -248,7 +248,7 @@ where
} }
fn poll_read<S, T, U>( fn poll_read<S, T, U>(
cx: &mut Context, cx: &mut Context<'_>,
srv: &mut S, srv: &mut S,
state: &mut TransportState<S, U>, state: &mut TransportState<S, U>,
framed: &mut Framed<T, U>, framed: &mut Framed<T, U>,
@ -300,7 +300,7 @@ where
/// write to framed object /// write to framed object
fn poll_write<S, T, U>( fn poll_write<S, T, U>(
cx: &mut Context, cx: &mut Context<'_>,
state: &mut TransportState<S, U>, state: &mut TransportState<S, U>,
framed: &mut Framed<T, U>, framed: &mut Framed<T, U>,
rx: &mut Rx<U>, rx: &mut Rx<U>,

View File

@ -73,7 +73,7 @@ where
type Error = T::Error; type Error = T::Error;
type Future = InFlightServiceResponse<T>; type Future = InFlightServiceResponse<T>;
fn poll_ready(&mut self, cx: &mut Context) -> Poll<Result<(), Self::Error>> { fn poll_ready(&mut self, cx: &mut Context<'_>) -> Poll<Result<(), Self::Error>> {
if let Poll::Pending = self.service.poll_ready(cx)? { if let Poll::Pending = self.service.poll_ready(cx)? {
Poll::Pending Poll::Pending
} else if !self.count.available(cx) { } else if !self.count.available(cx) {
@ -103,7 +103,7 @@ pub struct InFlightServiceResponse<T: Service> {
impl<T: Service> Future for InFlightServiceResponse<T> { impl<T: Service> Future for InFlightServiceResponse<T> {
type Output = Result<T::Response, T::Error>; type Output = Result<T::Response, T::Error>;
fn poll(self: Pin<&mut Self>, cx: &mut Context) -> Poll<Self::Output> { fn poll(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Self::Output> {
self.project().fut.poll(cx) self.project().fut.poll(cx)
} }
} }
@ -126,7 +126,7 @@ mod tests {
type Error = (); type Error = ();
type Future = LocalBoxFuture<'static, Result<(), ()>>; type Future = LocalBoxFuture<'static, Result<(), ()>>;
fn poll_ready(&mut self, _: &mut Context) -> Poll<Result<(), Self::Error>> { fn poll_ready(&mut self, _: &mut Context<'_>) -> Poll<Result<(), Self::Error>> {
Poll::Ready(Ok(())) Poll::Ready(Ok(()))
} }

View File

@ -102,7 +102,7 @@ where
type Error = E; type Error = E;
type Future = Ready<Result<R, E>>; type Future = Ready<Result<R, E>>;
fn poll_ready(&mut self, cx: &mut Context) -> Poll<Result<(), Self::Error>> { fn poll_ready(&mut self, cx: &mut Context<'_>) -> Poll<Result<(), Self::Error>> {
match Pin::new(&mut self.delay).poll(cx) { match Pin::new(&mut self.delay).poll(cx) {
Poll::Ready(_) => { Poll::Ready(_) => {
let now = self.time.now(); let now = self.time.now();

View File

@ -1,4 +1,6 @@
//! Actix utils - various helper services //! Actix utils - various helper services
#![deny(rust_2018_idioms, warnings)]
#![allow(clippy::type_complexity)]
mod cell; mod cell;
pub mod counter; pub mod counter;

View File

@ -72,7 +72,7 @@ impl<T> Clone for Sender<T> {
impl<T> Sink<T> for Sender<T> { impl<T> Sink<T> for Sender<T> {
type Error = SendError<T>; type Error = SendError<T>;
fn poll_ready(self: Pin<&mut Self>, _: &mut Context) -> Poll<Result<(), Self::Error>> { fn poll_ready(self: Pin<&mut Self>, _: &mut Context<'_>) -> Poll<Result<(), Self::Error>> {
Poll::Ready(Ok(())) Poll::Ready(Ok(()))
} }
@ -80,11 +80,11 @@ impl<T> Sink<T> for Sender<T> {
self.send(item) self.send(item)
} }
fn poll_flush(self: Pin<&mut Self>, _: &mut Context) -> Poll<Result<(), SendError<T>>> { fn poll_flush(self: Pin<&mut Self>, _: &mut Context<'_>) -> Poll<Result<(), SendError<T>>> {
Poll::Ready(Ok(())) Poll::Ready(Ok(()))
} }
fn poll_close(self: Pin<&mut Self>, _: &mut Context) -> Poll<Result<(), Self::Error>> { fn poll_close(self: Pin<&mut Self>, _: &mut Context<'_>) -> Poll<Result<(), Self::Error>> {
Poll::Ready(Ok(())) Poll::Ready(Ok(()))
} }
} }
@ -144,7 +144,7 @@ impl<T> Receiver<T> {
impl<T> Stream for Receiver<T> { impl<T> Stream for Receiver<T> {
type Item = T; type Item = T;
fn poll_next(mut self: Pin<&mut Self>, cx: &mut Context) -> Poll<Option<Self::Item>> { fn poll_next(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Option<Self::Item>> {
let me = match self.state { let me = match self.state {
State::Open(ref mut me) => me, State::Open(ref mut me) => me,
State::Closed(ref mut items) => return Poll::Ready(items.pop_front()), State::Closed(ref mut items) => return Poll::Ready(items.pop_front()),
@ -177,13 +177,13 @@ impl<T> Drop for Receiver<T> {
pub struct SendError<T>(T); pub struct SendError<T>(T);
impl<T> fmt::Debug for SendError<T> { impl<T> fmt::Debug for SendError<T> {
fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result {
fmt.debug_tuple("SendError").field(&"...").finish() fmt.debug_tuple("SendError").field(&"...").finish()
} }
} }
impl<T> fmt::Display for SendError<T> { impl<T> fmt::Display for SendError<T> {
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") write!(fmt, "send failed because receiver is gone")
} }
} }

View File

@ -111,7 +111,7 @@ impl<T> Sender<T> {
/// able to receive a message if sent. The current task, however, is /// able to receive a message if sent. The current task, however, is
/// scheduled to receive a notification if the corresponding `Receiver` goes /// scheduled to receive a notification if the corresponding `Receiver` goes
/// away. /// 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() { match self.inner.upgrade() {
Some(inner) => { Some(inner) => {
inner.borrow_mut().tx_task.register(cx.waker()); inner.borrow_mut().tx_task.register(cx.waker());

View File

@ -33,7 +33,7 @@ impl<E> From<E> for InOrderError<E> {
} }
impl<E: fmt::Debug> fmt::Debug for InOrderError<E> { impl<E: fmt::Debug> fmt::Debug for InOrderError<E> {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match self { match self {
InOrderError::Service(e) => write!(f, "InOrderError::Service({:?})", e), InOrderError::Service(e) => write!(f, "InOrderError::Service({:?})", e),
InOrderError::Disconnected => write!(f, "InOrderError::Disconnected"), InOrderError::Disconnected => write!(f, "InOrderError::Disconnected"),
@ -42,7 +42,7 @@ impl<E: fmt::Debug> fmt::Debug for InOrderError<E> {
} }
impl<E: fmt::Display> fmt::Display for InOrderError<E> { impl<E: fmt::Display> fmt::Display for InOrderError<E> {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match self { match self {
InOrderError::Service(e) => e.fmt(f), InOrderError::Service(e) => e.fmt(f),
InOrderError::Disconnected => write!(f, "InOrder service disconnected"), InOrderError::Disconnected => write!(f, "InOrder service disconnected"),
@ -140,7 +140,7 @@ where
type Error = InOrderError<S::Error>; type Error = InOrderError<S::Error>;
type Future = InOrderServiceResponse<S>; type Future = InOrderServiceResponse<S>;
fn poll_ready(&mut self, cx: &mut Context) -> Poll<Result<(), Self::Error>> { fn poll_ready(&mut self, cx: &mut Context<'_>) -> Poll<Result<(), Self::Error>> {
// poll_ready could be called from different task // poll_ready could be called from different task
self.task.register(cx.waker()); self.task.register(cx.waker());
@ -192,7 +192,7 @@ pub struct InOrderServiceResponse<S: Service> {
impl<S: Service> Future for InOrderServiceResponse<S> { impl<S: Service> Future for InOrderServiceResponse<S> {
type Output = Result<S::Response, InOrderError<S::Error>>; type Output = Result<S::Response, InOrderError<S::Error>>;
fn poll(mut self: Pin<&mut Self>, cx: &mut Context) -> Poll<Self::Output> { fn poll(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Self::Output> {
match Pin::new(&mut self.rx).poll(cx) { match Pin::new(&mut self.rx).poll(cx) {
Poll::Pending => Poll::Pending, Poll::Pending => Poll::Pending,
Poll::Ready(Ok(Ok(res))) => Poll::Ready(Ok(res)), Poll::Ready(Ok(Ok(res))) => Poll::Ready(Ok(res)),
@ -221,7 +221,7 @@ mod tests {
type Error = (); type Error = ();
type Future = LocalBoxFuture<'static, Result<usize, ()>>; type Future = LocalBoxFuture<'static, Result<usize, ()>>;
fn poll_ready(&mut self, _: &mut Context) -> Poll<Result<(), Self::Error>> { fn poll_ready(&mut self, _: &mut Context<'_>) -> Poll<Result<(), Self::Error>> {
Poll::Ready(Ok(())) Poll::Ready(Ok(()))
} }

View File

@ -46,7 +46,7 @@ where
{ {
type Output = Result<(), T::Error>; type Output = Result<(), T::Error>;
fn poll(mut self: Pin<&mut Self>, cx: &mut Context) -> Poll<Self::Output> { fn poll(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Self::Output> {
let mut this = self.as_mut().project(); let mut this = self.as_mut().project();
if let Poll::Ready(Some(e)) = Pin::new(&mut this.err_rx).poll_next(cx) { if let Poll::Ready(Some(e)) = Pin::new(&mut this.err_rx).poll_next(cx) {
@ -85,7 +85,7 @@ where
{ {
type Output = (); type Output = ();
fn poll(self: Pin<&mut Self>, cx: &mut Context) -> Poll<Self::Output> { fn poll(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Self::Output> {
let this = self.project(); let this = self.project();
match this.fut.poll(cx) { match this.fut.poll(cx) {

View File

@ -19,6 +19,7 @@ use std::{fmt, rc};
/// ///
/// A single `AtomicWaker` may be reused for any number of calls to `register` or /// A single `AtomicWaker` may be reused for any number of calls to `register` or
/// `wake`. /// `wake`.
#[derive(Default)]
pub struct LocalWaker { pub struct LocalWaker {
waker: UnsafeCell<Option<Waker>>, waker: UnsafeCell<Option<Waker>>,
_t: PhantomData<rc::Rc<()>>, _t: PhantomData<rc::Rc<()>>,

View File

@ -34,7 +34,7 @@ impl<E> From<E> for TimeoutError<E> {
} }
impl<E: fmt::Debug> fmt::Debug for TimeoutError<E> { impl<E: fmt::Debug> fmt::Debug for TimeoutError<E> {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match self { match self {
TimeoutError::Service(e) => write!(f, "TimeoutError::Service({:?})", e), TimeoutError::Service(e) => write!(f, "TimeoutError::Service({:?})", e),
TimeoutError::Timeout => write!(f, "TimeoutError::Timeout"), TimeoutError::Timeout => write!(f, "TimeoutError::Timeout"),
@ -43,7 +43,7 @@ impl<E: fmt::Debug> fmt::Debug for TimeoutError<E> {
} }
impl<E: fmt::Display> fmt::Display for TimeoutError<E> { impl<E: fmt::Display> fmt::Display for TimeoutError<E> {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match self { match self {
TimeoutError::Service(e) => e.fmt(f), TimeoutError::Service(e) => e.fmt(f),
TimeoutError::Timeout => write!(f, "Service call timeout"), TimeoutError::Timeout => write!(f, "Service call timeout"),
@ -193,7 +193,7 @@ mod tests {
type Error = (); type Error = ();
type Future = LocalBoxFuture<'static, Result<(), ()>>; type Future = LocalBoxFuture<'static, Result<(), ()>>;
fn poll_ready(&mut self, _: &mut Context) -> Poll<Result<(), Self::Error>> { fn poll_ready(&mut self, _: &mut Context<'_>) -> Poll<Result<(), Self::Error>> {
Poll::Ready(Ok(())) Poll::Ready(Ok(()))
} }