actix_http/body/
infallible_stream.rs1use std::{
2 convert::Infallible,
3 pin::Pin,
4 task::{Context, Poll},
5};
6
7use bytes::Bytes;
8use futures_core::Stream;
9use pin_project_lite::pin_project;
10
11pin_project! {
12 #[must_use]
17 pub struct InfallibleStream<S> {
18 #[pin]
19 pub(super) stream: S,
20 }
21}
22
23impl<S: Stream<Item = Bytes>> Stream for InfallibleStream<S> {
24 type Item = Result<Bytes, Infallible>;
25
26 #[inline]
27 fn poll_next(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Option<Self::Item>> {
28 self.project()
29 .stream
30 .poll_next(cx)
31 .map(|chunk| chunk.map(Ok))
32 }
33}