mirror of
https://github.com/tokio-rs/axum.git
synced 2026-08-28 00:00:20 +02:00
Move response futures into their own modules (#130)
It cleans up the docs to have the futures in their own modules as users are unlikely to look at them. Also matches the pattern used in tower https://docs.rs/tower/0.4.8/tower/util/future/index.html. Added re-exports to the old locations so its not a breaking change.
This commit is contained in:
@@ -50,3 +50,27 @@ where
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pin_project! {
|
||||
/// Response future for [`BoxResponseBody`].
|
||||
#[derive(Debug)]
|
||||
pub struct BoxResponseBodyFuture<F> {
|
||||
#[pin]
|
||||
pub(super) future: F,
|
||||
}
|
||||
}
|
||||
|
||||
impl<F, B, E> Future for BoxResponseBodyFuture<F>
|
||||
where
|
||||
F: Future<Output = Result<Response<B>, E>>,
|
||||
B: http_body::Body<Data = Bytes> + Send + Sync + 'static,
|
||||
B::Error: Into<BoxError> + Send + Sync + 'static,
|
||||
{
|
||||
type Output = Result<Response<BoxBody>, E>;
|
||||
|
||||
fn poll(self: std::pin::Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Self::Output> {
|
||||
let res = ready!(self.project().future.poll(cx))?;
|
||||
let res = res.map(box_body);
|
||||
Poll::Ready(Ok(res))
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user