Hidden ResponseFuture type

This commit is contained in:
ItsEthra 2023-12-03 15:16:33 +03:00
parent 140a74c071
commit d7a8ee55b1

View file

@ -63,7 +63,7 @@ where
{
type Response = S::Response;
type Error = S::Error;
type Future = ResponseFuture<'a, S::Future>;
type Future = private::ResponseFuture<'a, S::Future>;
fn poll_ready(&mut self, cx: &mut Context<'_>) -> Poll<Result<(), Self::Error>> {
self.inner.poll_ready(cx)
@ -77,7 +77,7 @@ where
let response_future = self.inner.call(req);
ResponseFuture {
private::ResponseFuture {
response_future,
hx_request: self.hx_request,
layer: self.layer.clone(),
@ -85,20 +85,23 @@ where
}
}
pin_project! {
mod private {
use super::*;
pin_project! {
pub struct ResponseFuture<'a, F> {
#[pin]
response_future: F,
hx_request: bool,
layer: HxRequestGuardLayer<'a>,
pub(super) response_future: F,
pub(super) hx_request: bool,
pub(super) layer: HxRequestGuardLayer<'a>,
}
}
}
impl<'a, F, B, E> Future for ResponseFuture<'a, F>
where
impl<'a, F, B, E> Future for ResponseFuture<'a, F>
where
F: Future<Output = Result<Response<B>, E>>,
B: Default,
{
{
type Output = Result<Response<B>, E>;
fn poll(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Self::Output> {
@ -118,6 +121,7 @@ where
}
}
}
}
}
#[derive(Debug, Default)]