Debian Codegraph @

third_party/rust/http-body/src/next.rs

raw
1 use crate::Body;
2
3 use core::future::Future;
4 use core::pin::Pin;
5 use 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`
10 pub struct Data<'a, T: ?Sized>(pub(crate) &'a mut T);
11
12 impl<'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(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`
23 pub struct Trailers<'a, T: ?Sized>(pub(crate) &'a mut T);
24
25 impl<'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(ctx)
30 }
31 }