Fix hyper_warp example warnings (#390)
This commit is contained in:
@@ -6,7 +6,6 @@
|
|||||||
use futures::future::{self, Either, TryFutureExt};
|
use futures::future::{self, Either, TryFutureExt};
|
||||||
use http::version::Version;
|
use http::version::Version;
|
||||||
use hyper::{service::make_service_fn, Server};
|
use hyper::{service::make_service_fn, Server};
|
||||||
use pin_project::pin_project;
|
|
||||||
use std::convert::Infallible;
|
use std::convert::Infallible;
|
||||||
use std::{
|
use std::{
|
||||||
pin::Pin,
|
pin::Pin,
|
||||||
@@ -77,16 +76,15 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
|
|||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
#[pin_project(project = EitherBodyProj)]
|
|
||||||
enum EitherBody<A, B> {
|
enum EitherBody<A, B> {
|
||||||
Left(#[pin] A),
|
Left(A),
|
||||||
Right(#[pin] B),
|
Right(B),
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<A, B> http_body::Body for EitherBody<A, B>
|
impl<A, B> http_body::Body for EitherBody<A, B>
|
||||||
where
|
where
|
||||||
A: http_body::Body + Send,
|
A: http_body::Body + Send + Unpin,
|
||||||
B: http_body::Body<Data = A::Data> + Send,
|
B: http_body::Body<Data = A::Data> + Send + Unpin,
|
||||||
A::Error: Into<Error>,
|
A::Error: Into<Error>,
|
||||||
B::Error: Into<Error>,
|
B::Error: Into<Error>,
|
||||||
{
|
{
|
||||||
@@ -104,9 +102,9 @@ where
|
|||||||
self: Pin<&mut Self>,
|
self: Pin<&mut Self>,
|
||||||
cx: &mut Context<'_>,
|
cx: &mut Context<'_>,
|
||||||
) -> Poll<Option<Result<Self::Data, Self::Error>>> {
|
) -> Poll<Option<Result<Self::Data, Self::Error>>> {
|
||||||
match self.project() {
|
match self.get_mut() {
|
||||||
EitherBodyProj::Left(b) => b.poll_data(cx).map(map_option_err),
|
EitherBody::Left(b) => Pin::new(b).poll_data(cx).map(map_option_err),
|
||||||
EitherBodyProj::Right(b) => b.poll_data(cx).map(map_option_err),
|
EitherBody::Right(b) => Pin::new(b).poll_data(cx).map(map_option_err),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -114,9 +112,9 @@ where
|
|||||||
self: Pin<&mut Self>,
|
self: Pin<&mut Self>,
|
||||||
cx: &mut Context<'_>,
|
cx: &mut Context<'_>,
|
||||||
) -> Poll<Result<Option<http::HeaderMap>, Self::Error>> {
|
) -> Poll<Result<Option<http::HeaderMap>, Self::Error>> {
|
||||||
match self.project() {
|
match self.get_mut() {
|
||||||
EitherBodyProj::Left(b) => b.poll_trailers(cx).map_err(Into::into),
|
EitherBody::Left(b) => Pin::new(b).poll_trailers(cx).map_err(Into::into),
|
||||||
EitherBodyProj::Right(b) => b.poll_trailers(cx).map_err(Into::into),
|
EitherBody::Right(b) => Pin::new(b).poll_trailers(cx).map_err(Into::into),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user