refactor(lib): update to 2018 edition

This commit is contained in:
Sean McArthur
2019-07-09 14:50:51 -07:00
parent 79ae89e066
commit da9b0319ef
37 changed files with 358 additions and 398 deletions

View File

@@ -22,13 +22,13 @@ use h2;
use tokio_io::{AsyncRead, AsyncWrite};
#[cfg(feature = "runtime")] use tokio_reactor::Handle;
use body::{Body, Payload};
use common::exec::{Exec, H2Exec, NewSvcExec};
use common::io::Rewind;
use error::{Kind, Parse};
use proto;
use service::{MakeServiceRef, Service};
use upgrade::Upgraded;
use crate::body::{Body, Payload};
use crate::common::exec::{Exec, H2Exec, NewSvcExec};
use crate::common::io::Rewind;
use crate::error::{Kind, Parse};
use crate::proto;
use crate::service::{MakeServiceRef, Service};
use crate::upgrade::Upgraded;
pub(super) use self::spawn_all::NoopWatcher;
use self::spawn_all::NewSvcTask;
@@ -413,7 +413,7 @@ impl<E> Http<E> {
/// `make_service` object provided, creating a new service per
/// connection.
#[cfg(feature = "runtime")]
pub fn serve_addr<S, Bd>(&self, addr: &SocketAddr, make_service: S) -> ::Result<Serve<AddrIncoming, S, E>>
pub fn serve_addr<S, Bd>(&self, addr: &SocketAddr, make_service: S) -> crate::Result<Serve<AddrIncoming, S, E>>
where
S: MakeServiceRef<
AddrStream,
@@ -438,7 +438,7 @@ impl<E> Http<E> {
/// `make_service` object provided, creating a new service per
/// connection.
#[cfg(feature = "runtime")]
pub fn serve_addr_handle<S, Bd>(&self, addr: &SocketAddr, handle: &Handle, make_service: S) -> ::Result<Serve<AddrIncoming, S, E>>
pub fn serve_addr_handle<S, Bd>(&self, addr: &SocketAddr, handle: &Handle, make_service: S) -> crate::Result<Serve<AddrIncoming, S, E>>
where
S: MakeServiceRef<
AddrStream,
@@ -547,7 +547,7 @@ where
/// Use [`poll_fn`](https://docs.rs/futures/0.1.25/futures/future/fn.poll_fn.html)
/// and [`try_ready!`](https://docs.rs/futures/0.1.25/futures/macro.try_ready.html)
/// to work with this function; or use the `without_shutdown` wrapper.
pub fn poll_without_shutdown(&mut self) -> Poll<(), ::Error> {
pub fn poll_without_shutdown(&mut self) -> Poll<(), crate::Error> {
loop {
let polled = match *self.conn.as_mut().unwrap() {
Either::A(ref mut h1) => h1.poll_without_shutdown(),
@@ -570,9 +570,9 @@ where
/// Prevent shutdown of the underlying IO object at the end of service the request,
/// instead run `into_parts`. This is a convenience wrapper over `poll_without_shutdown`.
pub fn without_shutdown(self) -> impl Future<Item=Parts<I,S>, Error=::Error> {
pub fn without_shutdown(self) -> impl Future<Item=Parts<I,S>, Error=crate::Error> {
let mut conn = Some(self);
::futures::future::poll_fn(move || -> ::Result<_> {
::futures::future::poll_fn(move || -> crate::Result<_> {
try_ready!(conn.as_mut().unwrap().poll_without_shutdown());
Ok(conn.take().unwrap().into_parts().into())
})
@@ -629,7 +629,7 @@ where
E: H2Exec<S::Future, B>,
{
type Item = ();
type Error = ::Error;
type Error = crate::Error;
fn poll(&mut self) -> Poll<Self::Item, Self::Error> {
loop {
@@ -701,7 +701,7 @@ where
E: H2Exec<<S::Service as Service>::Future, B>,
{
type Item = Connecting<I::Item, S::Future, E>;
type Error = ::Error;
type Error = crate::Error;
fn poll(&mut self) -> Poll<Option<Self::Item>, Self::Error> {
match self.make_service.poll_ready_ref() {
@@ -709,11 +709,11 @@ where
Ok(Async::NotReady) => return Ok(Async::NotReady),
Err(e) => {
trace!("make_service closed");
return Err(::Error::new_user_make_service(e));
return Err(crate::Error::new_user_make_service(e));
}
}
if let Some(io) = try_ready!(self.incoming.poll().map_err(::Error::new_accept)) {
if let Some(io) = try_ready!(self.incoming.poll().map_err(crate::Error::new_accept)) {
let new_fut = self.make_service.make_service_ref(&io);
Ok(Async::Ready(Some(Connecting {
future: new_fut,
@@ -774,7 +774,7 @@ where
B: Payload,
E: H2Exec<<S::Service as Service>::Future, B>,
{
pub(super) fn poll_watch<W>(&mut self, watcher: &W) -> Poll<(), ::Error>
pub(super) fn poll_watch<W>(&mut self, watcher: &W) -> Poll<(), crate::Error>
where
E: NewSvcExec<I::Item, S::Future, S::Service, E, W>,
W: Watcher<I::Item, S::Service, E>,
@@ -795,9 +795,9 @@ pub(crate) mod spawn_all {
use futures::{Future, Poll};
use tokio_io::{AsyncRead, AsyncWrite};
use body::{Body, Payload};
use common::exec::H2Exec;
use service::Service;
use crate::body::{Body, Payload};
use crate::common::exec::H2Exec;
use crate::service::Service;
use super::{Connecting, UpgradeableConnection};
// Used by `SpawnAll` to optionally watch a `Connection` future.
@@ -809,7 +809,7 @@ pub(crate) mod spawn_all {
// connections, and signal that they start to shutdown when prompted, so
// it has a `GracefulWatcher` implementation to do that.
pub trait Watcher<I, S: Service, E>: Clone {
type Future: Future<Item=(), Error=::Error>;
type Future: Future<Item=(), Error=crate::Error>;
fn watch(&self, conn: UpgradeableConnection<I, S, E>) -> Self::Future;
}
@@ -878,7 +878,7 @@ pub(crate) mod spawn_all {
let conn = try_ready!(connecting
.poll()
.map_err(|err| {
let err = ::Error::new_user_make_service(err);
let err = crate::Error::new_user_make_service(err);
debug!("connecting error: {}", err);
}));
let connected = watcher.watch(conn.with_upgrades());
@@ -941,7 +941,7 @@ mod upgrades {
E: super::H2Exec<S::Future, B>,
{
type Item = ();
type Error = ::Error;
type Error = crate::Error;
fn poll(&mut self) -> Poll<Self::Item, Self::Error> {
loop {