1
0
mirror of https://github.com/fafhrd91/actix-net synced 2024-11-27 15:42: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
## [0.2.0-alpha.2]
* Migrated to `std::future`
## [0.1.2] - 2019-03-27
* Added `Framed::map_io()` method.

View File

@ -1,6 +1,6 @@
[package]
name = "actix-codec"
version = "0.2.0-alpha.1"
version = "0.2.0-alpha.2"
authors = ["Nikolay Kim <fafhrd91@gmail.com>"]
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"

View File

@ -253,7 +253,7 @@ impl<T, U> Framed<T, U> {
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
T: AsyncRead,
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
T: AsyncWrite,
U: Encoder,
@ -346,7 +346,7 @@ impl<T, U> Framed<T, U> {
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
T: AsyncWrite,
U: Encoder,
@ -365,7 +365,7 @@ where
{
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)
}
}
@ -378,7 +378,7 @@ where
{
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() {
Poll::Ready(Ok(()))
} else {
@ -393,11 +393,17 @@ where
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)
}
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)
}
}
@ -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)

View File

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

View File

@ -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

View File

@ -1,6 +1,6 @@
[package]
name = "actix-connect"
version = "1.0.0-alpha.1"
version = "1.0.0-alpha.2"
authors = ["Nikolay Kim <fafhrd91@gmail.com>"]
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" }

View File

@ -132,7 +132,7 @@ impl<T: Address> From<T> 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())
}
}
@ -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<T, U> std::ops::DerefMut 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)
}
}

View File

@ -76,7 +76,7 @@ impl<T: Address> Service for TcpConnector<T> {
type Error = ConnectError;
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(()))
}
@ -134,7 +134,7 @@ impl<T: Address> TcpConnectorResponse<T> {
impl<T: Address> Future for TcpConnectorResponse<T> {
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();
// connect

View File

@ -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::<DefaultResolver>() {
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),

View File

@ -108,7 +108,7 @@ impl<T: Address> Service for Resolver<T> {
type Error = ConnectError;
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(()))
}
@ -153,7 +153,7 @@ impl<T: Address> ResolverFuture<T> {
impl<T: Address> Future for ResolverFuture<T> {
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();
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 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(()))
}
@ -116,7 +116,7 @@ enum ConnectState<T: Address> {
impl<T: Address> ConnectState<T> {
fn poll(
&mut self,
cx: &mut Context,
cx: &mut Context<'_>,
) -> Either<Poll<Result<Connection<T, TcpStream>, ConnectError>>, Connect<T>> {
match self {
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> {
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) {
Either::Right(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 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(()))
}
@ -185,7 +185,7 @@ enum TcpConnectState<T: Address> {
impl<T: Address> TcpConnectState<T> {
fn poll(
&mut self,
cx: &mut Context,
cx: &mut Context<'_>,
) -> Either<Poll<Result<TcpStream, ConnectError>>, Connect<T>> {
match self {
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> {
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) {
Either::Right(res) => {
self.state = TcpConnectState::Connect(self.tcp.call(res));

View File

@ -38,7 +38,7 @@ where
{
pub fn service(connector: SslConnector) -> OpensslConnectorService<T, U> {
OpensslConnectorService {
connector: connector,
connector,
_t: PhantomData,
}
}
@ -98,7 +98,7 @@ where
type Error = io::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(()))
}
@ -131,7 +131,7 @@ where
{
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();
match Pin::new(&mut this.fut).poll(cx) {
@ -218,7 +218,7 @@ impl<T: Address + 'static> Service for OpensslConnectService<T> {
type Error = ConnectError;
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(()))
}
@ -240,14 +240,14 @@ pub struct OpensslConnectServiceResponse<T: Address + 'static> {
impl<T: Address> Future for OpensslConnectServiceResponse<T> {
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 {
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)),
}
}

View File

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

View File

@ -1,6 +1,6 @@
[package]
name = "actix-ioframe"
version = "0.3.0-alpha.1"
version = "0.3.0-alpha.2"
authors = ["Nikolay Kim <fafhrd91@gmail.com>"]
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"

View File

@ -17,7 +17,7 @@ impl<T> Clone 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)
}
}

View File

@ -83,7 +83,7 @@ where
{
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)
}
}
@ -95,7 +95,7 @@ where
{
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() {
Poll::Ready(Ok(()))
} else {

View File

@ -136,7 +136,7 @@ where
{
pub(crate) fn poll(
&mut self,
cx: &mut Context,
cx: &mut Context<'_>,
) -> Poll<Result<(), ServiceError<S::Error, U>>> {
let this = self;
unsafe { this.inner.get_ref().task.register(cx.waker()) };
@ -156,7 +156,7 @@ where
}
fn poll<St, S, T, U>(
cx: &mut Context,
cx: &mut Context<'_>,
srv: &mut S,
state: &mut St,
sink: &mut Sink<<U as Encoder>::Item>,
@ -247,7 +247,7 @@ where
}
fn poll_read<St, S, T, U>(
cx: &mut Context,
cx: &mut Context<'_>,
srv: &mut S,
state: &mut St,
sink: &mut Sink<<U as Encoder>::Item>,
@ -310,7 +310,7 @@ where
/// write to framed object
fn poll_write<St, S, T, U>(
cx: &mut Context,
cx: &mut Context<'_>,
framed: &mut Framed<T, U>,
dispatch_state: &mut FramedState<S, U>,
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 Decoder>::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
<U as Encoder>::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 {
ServiceError::Service(ref e) => write!(fmt, "{}", e),
ServiceError::Encoder(ref e) => write!(fmt, "{:?}", e),

View File

@ -76,7 +76,7 @@ where
Codec: Encoder + Decoder,
<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()
}
}

View File

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

View File

@ -22,6 +22,12 @@ type ResponseItem<U> = Option<<U as Encoder>::Item>;
/// for building instances for framed services.
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> {
pub fn new() -> Builder<St, Codec> {
Builder(PhantomData)
@ -251,7 +257,7 @@ where
type Error = ServiceError<C::Error, Codec>;
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())
}
@ -309,7 +315,7 @@ where
{
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();
loop {
@ -373,7 +379,7 @@ where
#[project]
fn poll(
self: Pin<&mut Self>,
cx: &mut Context,
cx: &mut Context<'_>,
) -> Either<
FramedServiceImplResponseInner<St, Io, Codec, C, T>,
Poll<Result<(), ServiceError<C::Error, Codec>>>,

View File

@ -38,7 +38,7 @@ impl<T> 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()
}
}

View File

@ -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

View File

@ -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"),

View File

@ -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};

View File

@ -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)
}
}

View File

@ -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

View File

@ -1,6 +1,6 @@
[package]
name = "actix-server"
version = "0.8.0-alpha.2"
version = "1.0.0-alpha.2"
authors = ["Nikolay Kim <fafhrd91@gmail.com>"]
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"

View File

@ -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(());
}
};
}

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
#![deny(rust_2018_idioms, warnings)]
#![allow(clippy::type_complexity)]
mod accept;
mod builder;
mod config;
mod counter;
mod server;
mod service;
mod signals;

View File

@ -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<Self::Output> {
fn poll(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Self::Output> {
let this = self.get_mut();
if this.1.is_none() {

View File

@ -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

View File

@ -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 }

View File

@ -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!(),
};
}
}
}

View File

@ -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

View File

@ -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"

View File

@ -61,17 +61,18 @@ where
}
}
#[pin_project::pin_project]
pub struct AndThenServiceResponse<A, B>
where
A: Service,
B: Service<Request = A::Response, Error = A::Error>,
{
b: Cell<B>,
#[pin]
fut_b: Option<B::Future>,
#[pin]
fut_a: Option<A::Future>,
pin_project! {
pub struct AndThenServiceResponse<A, B>
where
A: Service,
B: Service<Request = A::Response, Error = A::Error>,
{
b: Cell<B>,
#[pin]
fut_b: Option<B::Future>,
#[pin]
fut_a: Option<A::Future>,
}
}
impl<A, B> AndThenServiceResponse<A, B>
@ -189,19 +190,20 @@ where
}
}
#[pin_project::pin_project]
pub struct AndThenServiceFactoryResponse<A, B>
where
A: ServiceFactory,
B: ServiceFactory<Request = A::Response>,
{
#[pin]
fut_b: B::Future,
#[pin]
fut_a: A::Future,
pin_project! {
pub struct AndThenServiceFactoryResponse<A, B>
where
A: ServiceFactory,
B: ServiceFactory<Request = A::Response>,
{
#[pin]
fut_b: B::Future,
#[pin]
fut_a: A::Future,
a: Option<A::Service>,
b: Option<B::Service>,
a: Option<A::Service>,
b: Option<B::Service>,
}
}
impl<A, B> AndThenServiceFactoryResponse<A, B>
@ -287,7 +289,7 @@ mod tests {
type Error = ();
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);
Poll::Ready(Ok(()))
}

View File

@ -122,17 +122,18 @@ where
}
}
#[pin_project::pin_project]
pub struct ApplyServiceFactoryResponse<T, F, R, In, Out, Err>
where
T: ServiceFactory<Error = Err>,
F: FnMut(In, &mut T::Service) -> R + Clone,
R: Future<Output = Result<Out, Err>>,
{
#[pin]
fut: T::Future,
f: Option<F>,
r: PhantomData<(In, Out)>,
pin_project! {
pub struct ApplyServiceFactoryResponse<T, F, R, In, Out, Err>
where
T: ServiceFactory<Error = Err>,
F: FnMut(In, &mut T::Service) -> R,
R: Future<Output = Result<Out, Err>>,
{
#[pin]
fut: T::Future,
f: Option<F>,
r: PhantomData<(In, Out)>,
}
}
impl<T, F, R, In, Out, Err> ApplyServiceFactoryResponse<T, F, R, In, Out, Err>
@ -187,7 +188,7 @@ mod tests {
type Error = ();
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(()))
}

View File

@ -149,23 +149,24 @@ where
}
}
#[pin_project::pin_project]
pub struct ApplyConfigServiceFactoryResponse<F, C, T, R, S>
where
F: FnMut(C, &mut T::Service) -> R,
T: ServiceFactory<Config = ()>,
T::InitError: From<T::Error>,
R: Future<Output = Result<S, T::InitError>>,
S: Service,
{
cfg: Option<C>,
f: Cell<F>,
srv: Option<T::Service>,
#[pin]
srv_fut: Option<T::Future>,
#[pin]
fut: Option<R>,
_t: PhantomData<(S,)>,
pin_project! {
pub struct ApplyConfigServiceFactoryResponse<F, C, T, R, S>
where
F: FnMut(C, &mut T::Service) -> R,
T: ServiceFactory<Config = ()>,
T::InitError: From<T::Error>,
R: Future<Output = Result<S, T::InitError>>,
S: Service,
{
cfg: Option<C>,
f: Cell<F>,
srv: Option<T::Service>,
#[pin]
srv_fut: Option<T::Future>,
#[pin]
fut: Option<R>,
_t: PhantomData<(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> {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
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::future::Future;
use std::rc::Rc;

View File

@ -62,15 +62,16 @@ where
}
}
#[pin_project::pin_project]
pub struct MapFuture<A, F, Response>
where
A: Service,
F: FnMut(A::Response) -> Response,
{
f: F,
#[pin]
fut: A::Future,
pin_project! {
pub struct MapFuture<A, F, Response>
where
A: Service,
F: FnMut(A::Response) -> Response,
{
f: F,
#[pin]
fut: A::Future,
}
}
impl<A, F, Response> MapFuture<A, F, Response>
@ -156,15 +157,16 @@ where
}
}
#[pin_project::pin_project]
pub struct MapServiceFuture<A, F, Res>
where
A: ServiceFactory,
F: FnMut(A::Response) -> Res,
{
#[pin]
fut: A::Future,
f: Option<F>,
pin_project! {
pub struct MapServiceFuture<A, F, Res>
where
A: ServiceFactory,
F: FnMut(A::Response) -> Res,
{
#[pin]
fut: A::Future,
f: Option<F>,
}
}
impl<A, F, Res> MapServiceFuture<A, F, Res>
@ -210,7 +212,7 @@ mod tests {
type Error = ();
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(()))
}

View File

@ -63,15 +63,16 @@ where
}
}
#[pin_project::pin_project]
pub struct MapErrFuture<A, F, E>
where
A: Service,
F: Fn(A::Error) -> E,
{
f: F,
#[pin]
fut: A::Future,
pin_project! {
pub struct MapErrFuture<A, F, E>
where
A: Service,
F: Fn(A::Error) -> E,
{
f: F,
#[pin]
fut: A::Future,
}
}
impl<A, F, E> MapErrFuture<A, F, E>
@ -159,15 +160,16 @@ where
}
}
#[pin_project::pin_project]
pub struct MapErrServiceFuture<A, F, E>
where
A: ServiceFactory,
F: Fn(A::Error) -> E,
{
#[pin]
fut: A::Future,
f: F,
pin_project! {
pub struct MapErrServiceFuture<A, F, E>
where
A: ServiceFactory,
F: Fn(A::Error) -> E,
{
#[pin]
fut: A::Future,
f: F,
}
}
impl<A, F, E> MapErrServiceFuture<A, F, E>
@ -212,7 +214,7 @@ mod tests {
type Error = ();
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(()))
}

View File

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

View File

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

View File

@ -134,17 +134,18 @@ where
}
}
#[pin_project::pin_project]
pub struct ApplyTransformFuture<T, S>
where
S: ServiceFactory,
T: Transform<S::Service, InitError = S::InitError>,
{
#[pin]
fut_a: S::Future,
#[pin]
fut_t: Option<T::Future>,
t_cell: Rc<T>,
pin_project! {
pub struct ApplyTransformFuture<T, S>
where
S: ServiceFactory,
T: Transform<S::Service, InitError = S::InitError>,
{
#[pin]
fut_a: S::Future,
#[pin]
fut_t: Option<T::Future>,
t_cell: Rc<T>,
}
}
impl<T, S> Future for ApplyTransformFuture<T, S>
@ -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
}
}
}

View File

@ -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

View File

@ -1,6 +1,6 @@
[package]
name = "actix-testing"
version = "0.3.0-alpha.2"
version = "1.0.0-alpha.2"
authors = ["Nikolay Kim <fafhrd91@gmail.com>"]
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"

View File

@ -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<F>(mut factory: F) -> TestServerRuntime
pub fn start<F>(mut factory: F) -> TestServerRuntime
where
F: FnMut(ServerBuilder) -> ServerBuilder + Send + 'static,
{

View File

@ -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

View File

@ -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" }

View File

@ -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;

View File

@ -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.

View File

@ -1,6 +1,6 @@
[package]
name = "actix-utils"
version = "0.5.0-alpha1"
version = "1.0.0-alpha.2"
authors = ["Nikolay Kim <fafhrd91@gmail.com>"]
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"

View File

@ -17,7 +17,7 @@ impl<T> Clone 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)
}
}

View File

@ -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 {

View File

@ -34,7 +34,7 @@ where
type Error = A::Error;
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 right = self.right.poll_ready(cx)?;
@ -131,7 +131,7 @@ where
{
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();
if this.left.is_none() {

View File

@ -37,7 +37,7 @@ where
<U as Encoder>::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 {
FramedTransportError::Service(ref e) => {
write!(fmt, "FramedTransportError::Service({:?})", e)
@ -58,7 +58,7 @@ where
<U as Encoder>::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 {
FramedTransportError::Service(ref e) => write!(fmt, "{}", e),
FramedTransportError::Encoder(ref e) => write!(fmt, "{:?}", e),
@ -177,7 +177,7 @@ where
{
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());
let this = self.project();
@ -193,7 +193,7 @@ where
}
fn poll<S, T, U>(
cx: &mut Context,
cx: &mut Context<'_>,
srv: &mut S,
state: &mut TransportState<S, U>,
framed: &mut Framed<T, U>,
@ -248,7 +248,7 @@ where
}
fn poll_read<S, T, U>(
cx: &mut Context,
cx: &mut Context<'_>,
srv: &mut S,
state: &mut TransportState<S, U>,
framed: &mut Framed<T, U>,
@ -300,7 +300,7 @@ where
/// write to framed object
fn poll_write<S, T, U>(
cx: &mut Context,
cx: &mut Context<'_>,
state: &mut TransportState<S, U>,
framed: &mut Framed<T, U>,
rx: &mut Rx<U>,

View File

@ -73,7 +73,7 @@ where
type Error = T::Error;
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)? {
Poll::Pending
} else if !self.count.available(cx) {
@ -103,7 +103,7 @@ pub struct InFlightServiceResponse<T: Service> {
impl<T: Service> Future for InFlightServiceResponse<T> {
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)
}
}
@ -126,7 +126,7 @@ mod tests {
type Error = ();
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(()))
}

View File

@ -102,7 +102,7 @@ where
type Error = 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) {
Poll::Ready(_) => {
let now = self.time.now();

View File

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

View File

@ -72,7 +72,7 @@ impl<T> Clone for Sender<T> {
impl<T> Sink<T> for Sender<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(()))
}
@ -80,11 +80,11 @@ impl<T> Sink<T> for Sender<T> {
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(()))
}
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(()))
}
}
@ -144,7 +144,7 @@ impl<T> Receiver<T> {
impl<T> Stream for Receiver<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 {
State::Open(ref mut me) => me,
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);
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()
}
}
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")
}
}

View File

@ -111,7 +111,7 @@ impl<T> Sender<T> {
/// 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());

View File

@ -33,7 +33,7 @@ impl<E> From<E> 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 {
InOrderError::Service(e) => write!(f, "InOrderError::Service({:?})", e),
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> {
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<S::Error>;
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
self.task.register(cx.waker());
@ -192,7 +192,7 @@ pub struct InOrderServiceResponse<S: Service> {
impl<S: Service> Future for InOrderServiceResponse<S> {
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) {
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<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(()))
}

View File

@ -46,7 +46,7 @@ where
{
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();
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<Self::Output> {
fn poll(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Self::Output> {
let this = self.project();
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
/// `wake`.
#[derive(Default)]
pub struct LocalWaker {
waker: UnsafeCell<Option<Waker>>,
_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> {
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<E: fmt::Debug> fmt::Debug 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 {
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<Result<(), Self::Error>> {
fn poll_ready(&mut self, _: &mut Context<'_>) -> Poll<Result<(), Self::Error>> {
Poll::Ready(Ok(()))
}