1use crate::Body;
2
3use core::future::Future;
4use core::pin::Pin;
5use core::task;
6
7#[must_use = "futures don't do anything unless polled"]
8#[derive(Debug)]
9/// Future that resolves to the next data chunk from `Body`
10pub struct Data<'a, T: ?Sized>(pub(crate) &'a mut T);
11
12impl<'a, T: Body + Unpin + ?Sized> Future for Data<'a, T> {
13 type Output = Option<Result<T::Data, T::Error>>;
14
15 fn poll(mut self: Pin<&mut Self>, ctx: &mut task::Context<'_>) -> task::Poll<Self::Output> {
16 Pin::new(&mut self.0).poll_data(cx:ctx)
17 }
18}
19
20#[must_use = "futures don't do anything unless polled"]
21#[derive(Debug)]
22/// Future that resolves to the optional trailers from `Body`
23pub struct Trailers<'a, T: ?Sized>(pub(crate) &'a mut T);
24
25impl<'a, T: Body + Unpin + ?Sized> Future for Trailers<'a, T> {
26 type Output = Result<Option<http::HeaderMap>, T::Error>;
27
28 fn poll(mut self: Pin<&mut Self>, ctx: &mut task::Context<'_>) -> task::Poll<Self::Output> {
29 Pin::new(&mut self.0).poll_trailers(cx:ctx)
30 }
31}
32