refactor(lib): rename 'stream' feature to 'unstable-stream'
This commit is contained in:
		| @@ -1,14 +1,12 @@ | ||||
| use std::borrow::Cow; | ||||
| #[cfg(feature = "stream")] | ||||
| #[cfg(feature = "unstable-stream")] | ||||
| use std::error::Error as StdError; | ||||
| use std::fmt; | ||||
|  | ||||
| use bytes::Bytes; | ||||
| use futures_core::Stream; // for mpsc::Receiver | ||||
| #[cfg(feature = "stream")] | ||||
| use futures_core::TryStream; | ||||
| use futures_channel::{mpsc, oneshot}; | ||||
| #[cfg(feature = "stream")] | ||||
| #[cfg(feature = "unstable-stream")] | ||||
| use futures_util::TryStreamExt; | ||||
| use http_body::{SizeHint, Body as HttpBody}; | ||||
| use http::HeaderMap; | ||||
| @@ -45,7 +43,7 @@ enum Kind { | ||||
|     // while a borrow of a `Request<Body>` exists. | ||||
|     // | ||||
|     // See https://github.com/rust-lang/rust/issues/57017 | ||||
|     #[cfg(feature = "stream")] | ||||
|     #[cfg(feature = "unstable-stream")] | ||||
|     Wrapped(Pin<Box<dyn Stream<Item = Result<Chunk, Box<dyn StdError + Send + Sync>>> + Send + Sync>>), | ||||
| } | ||||
|  | ||||
| @@ -146,16 +144,16 @@ impl Body { | ||||
|     /// | ||||
|     /// # Unstable | ||||
|     /// | ||||
|     /// This function requires enabling the unstable `stream` feature in your | ||||
|     /// This function requires enabling the `unstable-stream` feature in your | ||||
|     /// `Cargo.toml`. | ||||
|     #[cfg(feature = "stream")] | ||||
|     pub fn wrap_stream<S>(stream: S) -> Body | ||||
|     #[cfg(feature = "unstable-stream")] | ||||
|     pub fn wrap_stream<S, O, E>(stream: S) -> Body | ||||
|     where | ||||
|         S: TryStream + Send + Sync + 'static, | ||||
|         S::Error: Into<Box<dyn StdError + Send + Sync>>, | ||||
|         Chunk: From<S::Ok>, | ||||
|         S: Stream<Item = Result<O, E>> + Send + Sync + 'static, | ||||
|         O: Into<Chunk> + 'static, | ||||
|         E: Into<Box<dyn StdError + Send + Sync>> + 'static, | ||||
|     { | ||||
|         let mapped = stream.map_ok(Chunk::from).map_err(Into::into); | ||||
|         let mapped = stream.map_ok(Into::into).map_err(Into::into); | ||||
|         Body::new(Kind::Wrapped(Box::pin(mapped))) | ||||
|     } | ||||
|  | ||||
| @@ -287,7 +285,7 @@ impl Body { | ||||
|                 None => Poll::Ready(None), | ||||
|             }, | ||||
|  | ||||
|             #[cfg(feature = "stream")] | ||||
|             #[cfg(feature = "unstable-stream")] | ||||
|             Kind::Wrapped(ref mut s) => { | ||||
|                 match ready!(s.as_mut().poll_next(cx)) { | ||||
|                     Some(res) => Poll::Ready(Some(res.map_err(crate::Error::new_body))), | ||||
| @@ -337,7 +335,7 @@ impl HttpBody for Body { | ||||
|             Kind::Once(ref val) => val.is_none(), | ||||
|             Kind::Chan { content_length, .. } => content_length == Some(0), | ||||
|             Kind::H2 { recv: ref h2, .. } => h2.is_end_stream(), | ||||
|             #[cfg(feature = "stream")] | ||||
|             #[cfg(feature = "unstable-stream")] | ||||
|             Kind::Wrapped(..) => false, | ||||
|         } | ||||
|     } | ||||
| @@ -352,7 +350,7 @@ impl HttpBody for Body { | ||||
|             Kind::Once(None) => { | ||||
|                 SizeHint::default() | ||||
|             }, | ||||
|             #[cfg(feature = "stream")] | ||||
|             #[cfg(feature = "unstable-stream")] | ||||
|             Kind::Wrapped(..) => SizeHint::default(), | ||||
|             Kind::Chan { content_length, .. } | Kind::H2 { content_length, .. } => { | ||||
|                 let mut hint = SizeHint::default(); | ||||
| @@ -387,7 +385,11 @@ impl fmt::Debug for Body { | ||||
|     } | ||||
| } | ||||
|  | ||||
| #[cfg(feature = "stream")] | ||||
| /// # Unstable | ||||
| /// | ||||
| /// This function requires enabling the `unstable-stream` feature in your | ||||
| /// `Cargo.toml`. | ||||
| #[cfg(feature = "unstable-stream")] | ||||
| impl Stream for Body { | ||||
|     type Item = crate::Result<Chunk>; | ||||
|  | ||||
| @@ -397,7 +399,11 @@ impl Stream for Body { | ||||
| } | ||||
|  | ||||
|  | ||||
| #[cfg(feature = "stream")] | ||||
| /// # Unstable | ||||
| /// | ||||
| /// This function requires enabling the `unstable-stream` feature in your | ||||
| /// `Cargo.toml`. | ||||
| #[cfg(feature = "unstable-stream")] | ||||
| impl | ||||
|     From<Box<dyn Stream<Item = Result<Chunk, Box<dyn StdError + Send + Sync>>> + Send + Sync>> | ||||
|     for Body | ||||
|   | ||||
		Reference in New Issue
	
	Block a user