Skip to content

Commit ccc7c25

Browse files
committed
chore(body): re-enable Body::wrap_stream
1 parent f0478c6 commit ccc7c25

File tree

1 file changed

+6
-7
lines changed

1 file changed

+6
-7
lines changed

src/body/body.rs

+6-7
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,9 @@ use std::error::Error as StdError;
33
use std::fmt;
44

55
use bytes::Bytes;
6-
use futures_core::Stream;
6+
use futures_core::{Stream, TryStream};
77
use futures_channel::{mpsc, oneshot};
8+
use futures_util::TryStreamExt;
89
use tokio_buf::SizeHint;
910
use h2;
1011
use http::HeaderMap;
@@ -119,7 +120,6 @@ impl Body {
119120
(tx, rx)
120121
}
121122

122-
/*
123123
/// Wrap a futures `Stream` in a box inside `Body`.
124124
///
125125
/// # Example
@@ -142,14 +142,13 @@ impl Body {
142142
/// ```
143143
pub fn wrap_stream<S>(stream: S) -> Body
144144
where
145-
S: Stream + Send + 'static,
145+
S: TryStream + Send + 'static,
146146
S::Error: Into<Box<dyn StdError + Send + Sync>>,
147-
Chunk: From<S::Item>,
147+
Chunk: From<S::Ok>,
148148
{
149-
let mapped = stream.map(Chunk::from).map_err(Into::into);
150-
Body::new(Kind::Wrapped(Box::new(mapped)))
149+
let mapped = stream.map_ok(Chunk::from).map_err(Into::into);
150+
Body::new(Kind::Wrapped(Box::pin(mapped)))
151151
}
152-
*/
153152

154153
/// dox
155154
pub async fn next(&mut self) -> Option<crate::Result<Chunk>> {

0 commit comments

Comments
 (0)