Update to tokio 1.0, bytes 1.0 (#1076)

Co-authored-by: Wim Looman <git@nemo157.com>
Co-authored-by: Paolo Barbolini <paolo@paolo565.org>
This commit is contained in:
messense
2020-12-31 01:57:50 +08:00
committed by GitHub
parent 5ee4fe5ab6
commit a19eb34196
16 changed files with 173 additions and 219 deletions

View File

@@ -7,7 +7,7 @@ use bytes::Bytes;
use futures_core::Stream;
use http_body::Body as HttpBody;
use pin_project_lite::pin_project;
use tokio::time::Delay;
use tokio::time::Sleep;
/// An asynchronous request body.
pub struct Body {
@@ -27,7 +27,7 @@ enum Inner {
+ Sync,
>,
>,
timeout: Option<Delay>,
timeout: Option<Pin<Box<Sleep>>>,
},
}
@@ -103,7 +103,7 @@ impl Body {
}
}
pub(crate) fn response(body: hyper::Body, timeout: Option<Delay>) -> Body {
pub(crate) fn response(body: hyper::Body, timeout: Option<Pin<Box<Sleep>>>) -> Body {
Body {
inner: Inner::Streaming {
body: Box::pin(WrapHyper(body)),
@@ -217,7 +217,7 @@ impl HttpBody for ImplStream {
ref mut timeout,
} => {
if let Some(ref mut timeout) = timeout {
if let Poll::Ready(()) = Pin::new(timeout).poll(cx) {
if let Poll::Ready(()) = timeout.as_mut().poll(cx) {
return Poll::Ready(Some(Err(crate::error::body(crate::error::TimedOut))));
}
}