chore(body): re-enable Body::wrap_stream

This commit is contained in:
Sean McArthur
2019-07-10 14:17:36 -07:00
parent f0478c6267
commit ccc7c25334

View File

@@ -3,8 +3,9 @@ use std::error::Error as StdError;
use std::fmt; use std::fmt;
use bytes::Bytes; use bytes::Bytes;
use futures_core::Stream; use futures_core::{Stream, TryStream};
use futures_channel::{mpsc, oneshot}; use futures_channel::{mpsc, oneshot};
use futures_util::TryStreamExt;
use tokio_buf::SizeHint; use tokio_buf::SizeHint;
use h2; use h2;
use http::HeaderMap; use http::HeaderMap;
@@ -119,7 +120,6 @@ impl Body {
(tx, rx) (tx, rx)
} }
/*
/// Wrap a futures `Stream` in a box inside `Body`. /// Wrap a futures `Stream` in a box inside `Body`.
/// ///
/// # Example /// # Example
@@ -142,14 +142,13 @@ impl Body {
/// ``` /// ```
pub fn wrap_stream<S>(stream: S) -> Body pub fn wrap_stream<S>(stream: S) -> Body
where where
S: Stream + Send + 'static, S: TryStream + Send + 'static,
S::Error: Into<Box<dyn StdError + Send + Sync>>, S::Error: Into<Box<dyn StdError + Send + Sync>>,
Chunk: From<S::Item>, Chunk: From<S::Ok>,
{ {
let mapped = stream.map(Chunk::from).map_err(Into::into); let mapped = stream.map_ok(Chunk::from).map_err(Into::into);
Body::new(Kind::Wrapped(Box::new(mapped))) Body::new(Kind::Wrapped(Box::pin(mapped)))
} }
*/
/// dox /// dox
pub async fn next(&mut self) -> Option<crate::Result<Chunk>> { pub async fn next(&mut self) -> Option<crate::Result<Chunk>> {