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

@@ -18,12 +18,12 @@ use futures::future::{self, Either, Executor};
use h2;
use tokio_io::{AsyncRead, AsyncWrite};
use body::Payload;
use common::Exec;
use upgrade::Upgraded;
use proto;
use crate::body::Payload;
use crate::common::Exec;
use crate::upgrade::Upgraded;
use crate::proto;
use super::dispatch;
use {Body, Request, Response};
use crate::{Body, Request, Response};
type Http1Dispatcher<T, B, R> = proto::dispatch::Dispatcher<
proto::dispatch::Client<B>,
@@ -39,7 +39,7 @@ type ConnEither<T, B> = Either<
/// Returns a `Handshake` future over some IO.
///
/// This is a shortcut for `Builder::new().handshake(io)`.
pub fn handshake<T>(io: T) -> Handshake<T, ::Body>
pub fn handshake<T>(io: T) -> Handshake<T, crate::Body>
where
T: AsyncRead + AsyncWrite + Send + 'static,
{
@@ -98,7 +98,7 @@ pub struct Handshake<T, B> {
pub struct ResponseFuture {
// for now, a Box is used to hide away the internal `B`
// that can be returned if canceled
inner: Box<dyn Future<Item=Response<Body>, Error=::Error> + Send>,
inner: Box<dyn Future<Item=Response<Body>, Error=crate::Error> + Send>,
}
/// Deconstructed parts of a `Connection`.
@@ -145,7 +145,7 @@ impl<B> SendRequest<B>
/// Polls to determine whether this sender can be used yet for a request.
///
/// If the associated connection is closed, this returns an Error.
pub fn poll_ready(&mut self) -> Poll<(), ::Error> {
pub fn poll_ready(&mut self) -> Poll<(), crate::Error> {
self.dispatch.poll_ready()
}
@@ -235,7 +235,7 @@ where
},
Err(_req) => {
debug!("connection was not ready");
let err = ::Error::new_canceled().with("connection was not ready");
let err = crate::Error::new_canceled().with("connection was not ready");
Either::B(future::err(err))
}
};
@@ -245,7 +245,7 @@ where
}
}
pub(crate) fn send_request_retryable(&mut self, req: Request<B>) -> impl Future<Item = Response<Body>, Error = (::Error, Option<Request<B>>)>
pub(crate) fn send_request_retryable(&mut self, req: Request<B>) -> impl Future<Item = Response<Body>, Error = (crate::Error, Option<Request<B>>)>
where
B: Send,
{
@@ -262,7 +262,7 @@ where
},
Err(req) => {
debug!("connection was not ready");
let err = ::Error::new_canceled().with("connection was not ready");
let err = crate::Error::new_canceled().with("connection was not ready");
Either::B(future::err((err, Some(req))))
}
}
@@ -305,7 +305,7 @@ impl<B> Http2SendRequest<B>
where
B: Payload + 'static,
{
pub(super) fn send_request_retryable(&mut self, req: Request<B>) -> impl Future<Item=Response<Body>, Error=(::Error, Option<Request<B>>)>
pub(super) fn send_request_retryable(&mut self, req: Request<B>) -> impl Future<Item=Response<Body>, Error=(crate::Error, Option<Request<B>>)>
where
B: Send,
{
@@ -322,7 +322,7 @@ where
},
Err(req) => {
debug!("connection was not ready");
let err = ::Error::new_canceled().with("connection was not ready");
let err = crate::Error::new_canceled().with("connection was not ready");
Either::B(future::err((err, Some(req))))
}
}
@@ -380,7 +380,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> {
match self.inner.as_mut().expect("already upgraded") {
&mut Either::A(ref mut h1) => {
h1.poll_without_shutdown()
@@ -393,9 +393,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<T>, Error=::Error> {
pub fn without_shutdown(self) -> impl Future<Item=Parts<T>, 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())
})
@@ -408,7 +408,7 @@ where
B: Payload + 'static,
{
type Item = ();
type Error = ::Error;
type Error = crate::Error;
fn poll(&mut self) -> Poll<Self::Item, Self::Error> {
match try_ready!(self.inner.poll()) {
@@ -552,7 +552,7 @@ where
B: Payload + 'static,
{
type Item = (SendRequest<B>, Connection<T, B>);
type Error = ::Error;
type Error = crate::Error;
fn poll(&mut self) -> Poll<Self::Item, Self::Error> {
let io = self.io.take().expect("polled more than once");
@@ -601,7 +601,7 @@ impl<T, B> fmt::Debug for Handshake<T, B> {
impl Future for ResponseFuture {
type Item = Response<Body>;
type Error = ::Error;
type Error = crate::Error;
#[inline]
fn poll(&mut self) -> Poll<Self::Item, Self::Error> {
@@ -620,7 +620,7 @@ impl fmt::Debug for ResponseFuture {
impl<B> Future for WhenReady<B> {
type Item = SendRequest<B>;
type Error = ::Error;
type Error = crate::Error;
fn poll(&mut self) -> Poll<Self::Item, Self::Error> {
let mut tx = self.tx.take().expect("polled after complete");