Add unique future types for all services (#157)

So we can more easily change them in the future.
This commit is contained in:
David Pedersen
2021-08-07 22:27:27 +02:00
committed by GitHub
parent 2389761ce7
commit 6ce355cca3
7 changed files with 106 additions and 14 deletions
+27 -2
View File
@@ -6,14 +6,14 @@ use crate::{
};
use bytes::Bytes;
use futures_util::ready;
use http::Response;
use http::{Request, Response};
use pin_project_lite::pin_project;
use std::{
future::Future,
pin::Pin,
task::{Context, Poll},
};
use tower::BoxError;
use tower::{BoxError, Service};
pin_project! {
/// Response future for [`HandleError`](super::HandleError).
@@ -74,3 +74,28 @@ where
Poll::Ready(Ok(res))
}
}
pin_project! {
/// The response future for [`OnMethod`](super::OnMethod).
#[derive(Debug)]
pub struct OnMethodFuture<S, F, B>
where
S: Service<Request<B>>,
F: Service<Request<B>>
{
#[pin]
pub(super) inner: crate::routing::future::RouteFuture<S, F, B>,
}
}
impl<S, F, B> Future for OnMethodFuture<S, F, B>
where
S: Service<Request<B>, Response = Response<BoxBody>>,
F: Service<Request<B>, Response = Response<BoxBody>, Error = S::Error>,
{
type Output = Result<Response<BoxBody>, S::Error>;
fn poll(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Self::Output> {
self.project().inner.poll(cx)
}
}