chore(lib): add dyn keyword to trait objects (#1820)

Requires Rust 1.27.
This commit is contained in:
Sean McArthur
2019-06-03 13:08:13 -07:00
committed by GitHub
parent e0f5a9c6c5
commit 01c03db7ea
28 changed files with 107 additions and 94 deletions

View File

@@ -8,6 +8,7 @@
//! If you don't have need to manage connections yourself, consider using the
//! higher-level [Server](super) API.
use std::error::Error as StdError;
use std::fmt;
use std::mem;
#[cfg(feature = "runtime")] use std::net::SocketAddr;
@@ -179,7 +180,7 @@ impl Http {
#[deprecated(note = "use Http::with_executor instead")]
pub fn executor<E>(&mut self, exec: E) -> &mut Self
where
E: Executor<Box<Future<Item=(), Error=()> + Send>> + Send + Sync + 'static
E: Executor<Box<dyn Future<Item=(), Error=()> + Send>> + Send + Sync + 'static
{
self.exec = Exec::Executor(Arc::new(exec));
self
@@ -364,7 +365,7 @@ impl<E> Http<E> {
pub fn serve_connection<S, I, Bd>(&self, io: I, service: S) -> Connection<I, S, E>
where
S: Service<ReqBody=Body, ResBody=Bd>,
S::Error: Into<Box<::std::error::Error + Send + Sync>>,
S::Error: Into<Box<dyn StdError + Send + Sync>>,
Bd: Payload,
I: AsyncRead + AsyncWrite,
E: H2Exec<S::Future, Bd>,
@@ -419,7 +420,7 @@ impl<E> Http<E> {
ReqBody=Body,
ResBody=Bd,
>,
S::Error: Into<Box<::std::error::Error + Send + Sync>>,
S::Error: Into<Box<dyn StdError + Send + Sync>>,
Bd: Payload,
E: H2Exec<<S::Service as Service>::Future, Bd>,
{
@@ -444,7 +445,7 @@ impl<E> Http<E> {
ReqBody=Body,
ResBody=Bd,
>,
S::Error: Into<Box<::std::error::Error + Send + Sync>>,
S::Error: Into<Box<dyn StdError + Send + Sync>>,
Bd: Payload,
E: H2Exec<<S::Service as Service>::Future, Bd>,
{
@@ -459,14 +460,14 @@ impl<E> Http<E> {
pub fn serve_incoming<I, S, Bd>(&self, incoming: I, make_service: S) -> Serve<I, S, E>
where
I: Stream,
I::Error: Into<Box<::std::error::Error + Send + Sync>>,
I::Error: Into<Box<dyn StdError + Send + Sync>>,
I::Item: AsyncRead + AsyncWrite,
S: MakeServiceRef<
I::Item,
ReqBody=Body,
ResBody=Bd,
>,
S::Error: Into<Box<::std::error::Error + Send + Sync>>,
S::Error: Into<Box<dyn StdError + Send + Sync>>,
Bd: Payload,
E: H2Exec<<S::Service as Service>::Future, Bd>,
{
@@ -484,7 +485,7 @@ impl<E> Http<E> {
impl<I, B, S, E> Connection<I, S, E>
where
S: Service<ReqBody=Body, ResBody=B>,
S::Error: Into<Box<::std::error::Error + Send + Sync>>,
S::Error: Into<Box<dyn StdError + Send + Sync>>,
I: AsyncRead + AsyncWrite,
B: Payload + 'static,
E: H2Exec<S::Future, B>,
@@ -622,7 +623,7 @@ where
impl<I, B, S, E> Future for Connection<I, S, E>
where
S: Service<ReqBody=Body, ResBody=B> + 'static,
S::Error: Into<Box<::std::error::Error + Send + Sync>>,
S::Error: Into<Box<dyn StdError + Send + Sync>>,
I: AsyncRead + AsyncWrite + 'static,
B: Payload + 'static,
E: H2Exec<S::Future, B>,
@@ -692,10 +693,10 @@ impl<I, S, B, E> Stream for Serve<I, S, E>
where
I: Stream,
I::Item: AsyncRead + AsyncWrite,
I::Error: Into<Box<::std::error::Error + Send + Sync>>,
I::Error: Into<Box<dyn StdError + Send + Sync>>,
S: MakeServiceRef<I::Item, ReqBody=Body, ResBody=B>,
//S::Error2: Into<Box<::std::error::Error + Send + Sync>>,
//SME: Into<Box<::std::error::Error + Send + Sync>>,
//S::Error2: Into<Box<StdError + Send + Sync>>,
//SME: Into<Box<StdError + Send + Sync>>,
B: Payload,
E: H2Exec<<S::Service as Service>::Future, B>,
{
@@ -763,7 +764,7 @@ impl<I, S, E> SpawnAll<I, S, E> {
impl<I, S, B, E> SpawnAll<I, S, E>
where
I: Stream,
I::Error: Into<Box<::std::error::Error + Send + Sync>>,
I::Error: Into<Box<dyn StdError + Send + Sync>>,
I::Item: AsyncRead + AsyncWrite + Send + 'static,
S: MakeServiceRef<
I::Item,
@@ -790,6 +791,7 @@ where
}
pub(crate) mod spawn_all {
use std::error::Error as StdError;
use futures::{Future, Poll};
use tokio_io::{AsyncRead, AsyncWrite};
@@ -860,7 +862,7 @@ pub(crate) mod spawn_all {
where
I: AsyncRead + AsyncWrite + Send + 'static,
N: Future<Item=S>,
N::Error: Into<Box<::std::error::Error + Send + Sync>>,
N::Error: Into<Box<dyn StdError + Send + Sync>>,
S: Service<ReqBody=Body, ResBody=B>,
B: Payload,
E: H2Exec<S::Future, B>,
@@ -916,7 +918,7 @@ mod upgrades {
impl<I, B, S, E> UpgradeableConnection<I, S, E>
where
S: Service<ReqBody=Body, ResBody=B>,// + 'static,
S::Error: Into<Box<::std::error::Error + Send + Sync>>,
S::Error: Into<Box<dyn StdError + Send + Sync>>,
I: AsyncRead + AsyncWrite,
B: Payload + 'static,
E: H2Exec<S::Future, B>,
@@ -933,7 +935,7 @@ mod upgrades {
impl<I, B, S, E> Future for UpgradeableConnection<I, S, E>
where
S: Service<ReqBody=Body, ResBody=B> + 'static,
S::Error: Into<Box<::std::error::Error + Send + Sync>>,
S::Error: Into<Box<dyn StdError + Send + Sync>>,
I: AsyncRead + AsyncWrite + Send + 'static,
B: Payload + 'static,
E: super::H2Exec<S::Future, B>,

View File

@@ -54,6 +54,7 @@ pub mod conn;
mod shutdown;
#[cfg(feature = "runtime")] mod tcp;
use std::error::Error as StdError;
use std::fmt;
#[cfg(feature = "runtime")] use std::net::{SocketAddr, TcpListener as StdTcpListener};
@@ -142,10 +143,10 @@ impl<S> Server<AddrIncoming, S> {
impl<I, S, E, B> Server<I, S, E>
where
I: Stream,
I::Error: Into<Box<::std::error::Error + Send + Sync>>,
I::Error: Into<Box<dyn StdError + Send + Sync>>,
I::Item: AsyncRead + AsyncWrite + Send + 'static,
S: MakeServiceRef<I::Item, ReqBody=Body, ResBody=B>,
S::Error: Into<Box<::std::error::Error + Send + Sync>>,
S::Error: Into<Box<dyn StdError + Send + Sync>>,
S::Service: 'static,
B: Payload,
E: H2Exec<<S::Service as Service>::Future, B>,
@@ -201,10 +202,10 @@ where
impl<I, S, B, E> Future for Server<I, S, E>
where
I: Stream,
I::Error: Into<Box<::std::error::Error + Send + Sync>>,
I::Error: Into<Box<dyn StdError + Send + Sync>>,
I::Item: AsyncRead + AsyncWrite + Send + 'static,
S: MakeServiceRef<I::Item, ReqBody=Body, ResBody=B>,
S::Error: Into<Box<::std::error::Error + Send + Sync>>,
S::Error: Into<Box<dyn StdError + Send + Sync>>,
S::Service: 'static,
B: Payload,
E: H2Exec<<S::Service as Service>::Future, B>,
@@ -398,10 +399,10 @@ impl<I, E> Builder<I, E> {
pub fn serve<S, B>(self, new_service: S) -> Server<I, S, E>
where
I: Stream,
I::Error: Into<Box<::std::error::Error + Send + Sync>>,
I::Error: Into<Box<dyn StdError + Send + Sync>>,
I::Item: AsyncRead + AsyncWrite + Send + 'static,
S: MakeServiceRef<I::Item, ReqBody=Body, ResBody=B>,
S::Error: Into<Box<::std::error::Error + Send + Sync>>,
S::Error: Into<Box<dyn StdError + Send + Sync>>,
S::Service: 'static,
B: Payload,
E: NewSvcExec<I::Item, S::Future, S::Service, E, NoopWatcher>,

View File

@@ -1,3 +1,5 @@
use std::error::Error as StdError;
use futures::{Async, Future, Stream, Poll};
use tokio_io::{AsyncRead, AsyncWrite};
@@ -38,11 +40,11 @@ impl<I, S, F, E> Graceful<I, S, F, E> {
impl<I, S, B, F, E> Future for Graceful<I, S, F, E>
where
I: Stream,
I::Error: Into<Box<::std::error::Error + Send + Sync>>,
I::Error: Into<Box<dyn StdError + Send + Sync>>,
I::Item: AsyncRead + AsyncWrite + Send + 'static,
S: MakeServiceRef<I::Item, ReqBody=Body, ResBody=B>,
S::Service: 'static,
S::Error: Into<Box<::std::error::Error + Send + Sync>>,
S::Error: Into<Box<dyn StdError + Send + Sync>>,
B: Payload,
F: Future<Item=()>,
E: H2Exec<<S::Service as Service>::Future, B>,
@@ -109,7 +111,7 @@ where
fn on_drain<I, S, E>(conn: &mut UpgradeableConnection<I, S, E>)
where
S: Service<ReqBody=Body>,
S::Error: Into<Box<::std::error::Error + Send + Sync>>,
S::Error: Into<Box<dyn StdError + Send + Sync>>,
I: AsyncRead + AsyncWrite,
S::ResBody: Payload + 'static,
E: H2Exec<S::Future, S::ResBody>,