feat(lib): rename unstable-stream feature to stream and enable by default
Closes #2034
This commit is contained in:
@@ -5,11 +5,11 @@ matrix:
|
|||||||
fast_finish: true
|
fast_finish: true
|
||||||
include:
|
include:
|
||||||
- rust: nightly
|
- rust: nightly
|
||||||
env: FEATURES="--no-default-features --features runtime,unstable-stream,nightly"
|
env: FEATURES="--no-default-features --features runtime,stream,nightly"
|
||||||
- rust: beta
|
- rust: beta
|
||||||
env: FEATURES="--no-default-features --features runtime,unstable-stream,__internal_happy_eyeballs_tests"
|
env: FEATURES="--no-default-features --features runtime,stream,__internal_happy_eyeballs_tests"
|
||||||
#- rust: stable
|
#- rust: stable
|
||||||
# env: FEATURES="--no-default-features --features runtime,unstable-stream,__internal_happy_eyeballs_tests"
|
# env: FEATURES="--no-default-features --features runtime,stream,__internal_happy_eyeballs_tests"
|
||||||
- rust: beta #stable
|
- rust: beta #stable
|
||||||
env: FEATURES="--no-default-features"
|
env: FEATURES="--no-default-features"
|
||||||
# Minimum Supported Rust Version
|
# Minimum Supported Rust Version
|
||||||
|
|||||||
21
Cargo.toml
21
Cargo.toml
@@ -57,6 +57,7 @@ url = "1.0"
|
|||||||
default = [
|
default = [
|
||||||
"__internal_flaky_tests",
|
"__internal_flaky_tests",
|
||||||
"runtime",
|
"runtime",
|
||||||
|
"stream",
|
||||||
]
|
]
|
||||||
runtime = [
|
runtime = [
|
||||||
"tcp",
|
"tcp",
|
||||||
@@ -69,8 +70,8 @@ tcp = [
|
|||||||
"tokio/time",
|
"tokio/time",
|
||||||
]
|
]
|
||||||
|
|
||||||
# unstable features
|
# `impl Stream` for things
|
||||||
unstable-stream = []
|
stream = []
|
||||||
|
|
||||||
# internal features used in CI
|
# internal features used in CI
|
||||||
nightly = []
|
nightly = []
|
||||||
@@ -80,7 +81,7 @@ __internal_happy_eyeballs_tests = []
|
|||||||
[package.metadata.docs.rs]
|
[package.metadata.docs.rs]
|
||||||
features = [
|
features = [
|
||||||
"runtime",
|
"runtime",
|
||||||
"unstable-stream",
|
"stream",
|
||||||
]
|
]
|
||||||
|
|
||||||
[profile.release]
|
[profile.release]
|
||||||
@@ -99,12 +100,12 @@ required-features = ["runtime"]
|
|||||||
[[example]]
|
[[example]]
|
||||||
name = "client_json"
|
name = "client_json"
|
||||||
path = "examples/client_json.rs"
|
path = "examples/client_json.rs"
|
||||||
required-features = ["runtime", "unstable-stream"]
|
required-features = ["runtime", "stream"]
|
||||||
|
|
||||||
[[example]]
|
[[example]]
|
||||||
name = "echo"
|
name = "echo"
|
||||||
path = "examples/echo.rs"
|
path = "examples/echo.rs"
|
||||||
required-features = ["runtime", "unstable-stream"]
|
required-features = ["runtime", "stream"]
|
||||||
|
|
||||||
[[example]]
|
[[example]]
|
||||||
name = "hello"
|
name = "hello"
|
||||||
@@ -119,7 +120,7 @@ required-features = ["runtime"]
|
|||||||
[[example]]
|
[[example]]
|
||||||
name = "params"
|
name = "params"
|
||||||
path = "examples/params.rs"
|
path = "examples/params.rs"
|
||||||
required-features = ["runtime", "unstable-stream"]
|
required-features = ["runtime", "stream"]
|
||||||
|
|
||||||
[[example]]
|
[[example]]
|
||||||
name = "proxy"
|
name = "proxy"
|
||||||
@@ -160,7 +161,7 @@ required-features = ["runtime"]
|
|||||||
[[example]]
|
[[example]]
|
||||||
name = "web_api"
|
name = "web_api"
|
||||||
path = "examples/web_api.rs"
|
path = "examples/web_api.rs"
|
||||||
required-features = ["runtime", "unstable-stream"]
|
required-features = ["runtime", "stream"]
|
||||||
|
|
||||||
|
|
||||||
[[bench]]
|
[[bench]]
|
||||||
@@ -181,18 +182,18 @@ required-features = ["runtime"]
|
|||||||
[[bench]]
|
[[bench]]
|
||||||
name = "server"
|
name = "server"
|
||||||
path = "benches/server.rs"
|
path = "benches/server.rs"
|
||||||
required-features = ["runtime", "unstable-stream"]
|
required-features = ["runtime", "stream"]
|
||||||
|
|
||||||
|
|
||||||
[[test]]
|
[[test]]
|
||||||
name = "client"
|
name = "client"
|
||||||
path = "tests/client.rs"
|
path = "tests/client.rs"
|
||||||
required-features = ["runtime", "unstable-stream"]
|
required-features = ["runtime", "stream"]
|
||||||
|
|
||||||
[[test]]
|
[[test]]
|
||||||
name = "integration"
|
name = "integration"
|
||||||
path = "tests/integration.rs"
|
path = "tests/integration.rs"
|
||||||
required-features = ["runtime", "unstable-stream"]
|
required-features = ["runtime", "stream"]
|
||||||
|
|
||||||
[[test]]
|
[[test]]
|
||||||
name = "server"
|
name = "server"
|
||||||
|
|||||||
@@ -1,12 +1,12 @@
|
|||||||
use std::borrow::Cow;
|
use std::borrow::Cow;
|
||||||
#[cfg(feature = "unstable-stream")]
|
#[cfg(feature = "stream")]
|
||||||
use std::error::Error as StdError;
|
use std::error::Error as StdError;
|
||||||
use std::fmt;
|
use std::fmt;
|
||||||
|
|
||||||
use bytes::Bytes;
|
use bytes::Bytes;
|
||||||
use futures_core::Stream; // for mpsc::Receiver
|
use futures_core::Stream; // for mpsc::Receiver
|
||||||
use futures_channel::{mpsc, oneshot};
|
use futures_channel::{mpsc, oneshot};
|
||||||
#[cfg(feature = "unstable-stream")]
|
#[cfg(feature = "stream")]
|
||||||
use futures_util::TryStreamExt;
|
use futures_util::TryStreamExt;
|
||||||
use http_body::{SizeHint, Body as HttpBody};
|
use http_body::{SizeHint, Body as HttpBody};
|
||||||
use http::HeaderMap;
|
use http::HeaderMap;
|
||||||
@@ -43,7 +43,7 @@ enum Kind {
|
|||||||
// while a borrow of a `Request<Body>` exists.
|
// while a borrow of a `Request<Body>` exists.
|
||||||
//
|
//
|
||||||
// See https://github.com/rust-lang/rust/issues/57017
|
// See https://github.com/rust-lang/rust/issues/57017
|
||||||
#[cfg(feature = "unstable-stream")]
|
#[cfg(feature = "stream")]
|
||||||
Wrapped(Pin<Box<dyn Stream<Item = Result<Chunk, Box<dyn StdError + Send + Sync>>> + Send + Sync>>),
|
Wrapped(Pin<Box<dyn Stream<Item = Result<Chunk, Box<dyn StdError + Send + Sync>>> + Send + Sync>>),
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -142,11 +142,11 @@ impl Body {
|
|||||||
/// # }
|
/// # }
|
||||||
/// ```
|
/// ```
|
||||||
///
|
///
|
||||||
/// # Unstable
|
/// # Optional
|
||||||
///
|
///
|
||||||
/// This function requires enabling the `unstable-stream` feature in your
|
/// This function requires enabling the `stream` feature in your
|
||||||
/// `Cargo.toml`.
|
/// `Cargo.toml`.
|
||||||
#[cfg(feature = "unstable-stream")]
|
#[cfg(feature = "stream")]
|
||||||
pub fn wrap_stream<S, O, E>(stream: S) -> Body
|
pub fn wrap_stream<S, O, E>(stream: S) -> Body
|
||||||
where
|
where
|
||||||
S: Stream<Item = Result<O, E>> + Send + Sync + 'static,
|
S: Stream<Item = Result<O, E>> + Send + Sync + 'static,
|
||||||
@@ -280,7 +280,7 @@ impl Body {
|
|||||||
None => Poll::Ready(None),
|
None => Poll::Ready(None),
|
||||||
},
|
},
|
||||||
|
|
||||||
#[cfg(feature = "unstable-stream")]
|
#[cfg(feature = "stream")]
|
||||||
Kind::Wrapped(ref mut s) => {
|
Kind::Wrapped(ref mut s) => {
|
||||||
match ready!(s.as_mut().poll_next(cx)) {
|
match ready!(s.as_mut().poll_next(cx)) {
|
||||||
Some(res) => Poll::Ready(Some(res.map_err(crate::Error::new_body))),
|
Some(res) => Poll::Ready(Some(res.map_err(crate::Error::new_body))),
|
||||||
@@ -330,7 +330,7 @@ impl HttpBody for Body {
|
|||||||
Kind::Once(ref val) => val.is_none(),
|
Kind::Once(ref val) => val.is_none(),
|
||||||
Kind::Chan { content_length, .. } => content_length == Some(0),
|
Kind::Chan { content_length, .. } => content_length == Some(0),
|
||||||
Kind::H2 { recv: ref h2, .. } => h2.is_end_stream(),
|
Kind::H2 { recv: ref h2, .. } => h2.is_end_stream(),
|
||||||
#[cfg(feature = "unstable-stream")]
|
#[cfg(feature = "stream")]
|
||||||
Kind::Wrapped(..) => false,
|
Kind::Wrapped(..) => false,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -345,7 +345,7 @@ impl HttpBody for Body {
|
|||||||
Kind::Once(None) => {
|
Kind::Once(None) => {
|
||||||
SizeHint::default()
|
SizeHint::default()
|
||||||
},
|
},
|
||||||
#[cfg(feature = "unstable-stream")]
|
#[cfg(feature = "stream")]
|
||||||
Kind::Wrapped(..) => SizeHint::default(),
|
Kind::Wrapped(..) => SizeHint::default(),
|
||||||
Kind::Chan { content_length, .. } | Kind::H2 { content_length, .. } => {
|
Kind::Chan { content_length, .. } | Kind::H2 { content_length, .. } => {
|
||||||
let mut hint = SizeHint::default();
|
let mut hint = SizeHint::default();
|
||||||
@@ -380,11 +380,11 @@ impl fmt::Debug for Body {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// # Unstable
|
/// # Optional
|
||||||
///
|
///
|
||||||
/// This function requires enabling the `unstable-stream` feature in your
|
/// This function requires enabling the `stream` feature in your
|
||||||
/// `Cargo.toml`.
|
/// `Cargo.toml`.
|
||||||
#[cfg(feature = "unstable-stream")]
|
#[cfg(feature = "stream")]
|
||||||
impl Stream for Body {
|
impl Stream for Body {
|
||||||
type Item = crate::Result<Chunk>;
|
type Item = crate::Result<Chunk>;
|
||||||
|
|
||||||
@@ -394,11 +394,11 @@ impl Stream for Body {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/// # Unstable
|
/// # Optional
|
||||||
///
|
///
|
||||||
/// This function requires enabling the `unstable-stream` feature in your
|
/// This function requires enabling the `stream` feature in your
|
||||||
/// `Cargo.toml`.
|
/// `Cargo.toml`.
|
||||||
#[cfg(feature = "unstable-stream")]
|
#[cfg(feature = "stream")]
|
||||||
impl
|
impl
|
||||||
From<Box<dyn Stream<Item = Result<Chunk, Box<dyn StdError + Send + Sync>>> + Send + Sync>>
|
From<Box<dyn Stream<Item = Result<Chunk, Box<dyn StdError + Send + Sync>>> + Send + Sync>>
|
||||||
for Body
|
for Body
|
||||||
|
|||||||
@@ -27,10 +27,7 @@
|
|||||||
//! executor.
|
//! executor.
|
||||||
//! - `tcp` (*enabled by default*): Enables convenient implementations over
|
//! - `tcp` (*enabled by default*): Enables convenient implementations over
|
||||||
//! TCP (using tokio).
|
//! TCP (using tokio).
|
||||||
//! - `unstable-stream` (*unstable*): Provides `futures::Stream` capabilities.
|
//! - `stream` (*enabled by default*): Provides `futures::Stream` capabilities.
|
||||||
//!
|
|
||||||
//! Due to the `Stream` trait not being stable, this feature is also
|
|
||||||
//! unstable. It does not follow normal semver.
|
|
||||||
|
|
||||||
#[doc(hidden)] pub use http;
|
#[doc(hidden)] pub use http;
|
||||||
#[macro_use] extern crate log;
|
#[macro_use] extern crate log;
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
//! connections.
|
//! connections.
|
||||||
//! - Utilities like `poll_fn` to ease creating a custom `Accept`.
|
//! - Utilities like `poll_fn` to ease creating a custom `Accept`.
|
||||||
|
|
||||||
#[cfg(feature = "unstable-stream")]
|
#[cfg(feature = "stream")]
|
||||||
use futures_core::Stream;
|
use futures_core::Stream;
|
||||||
|
|
||||||
use crate::common::{Pin, task::{self, Poll}};
|
use crate::common::{Pin, task::{self, Poll}};
|
||||||
@@ -68,11 +68,11 @@ where
|
|||||||
|
|
||||||
/// Adapt a `Stream` of incoming connections into an `Accept`.
|
/// Adapt a `Stream` of incoming connections into an `Accept`.
|
||||||
///
|
///
|
||||||
/// # Unstable
|
/// # Optional
|
||||||
///
|
///
|
||||||
/// This function requires enabling the `unstable-stream` feature in your
|
/// This function requires enabling the `stream` feature in your
|
||||||
/// `Cargo.toml`.
|
/// `Cargo.toml`.
|
||||||
#[cfg(feature = "unstable-stream")]
|
#[cfg(feature = "stream")]
|
||||||
pub fn from_stream<S, IO, E>(stream: S) -> impl Accept<Conn = IO, Error = E>
|
pub fn from_stream<S, IO, E>(stream: S) -> impl Accept<Conn = IO, Error = E>
|
||||||
where
|
where
|
||||||
S: Stream<Item = Result<IO, E>>,
|
S: Stream<Item = Result<IO, E>>,
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ use std::time::Duration;
|
|||||||
|
|
||||||
use futures_channel::oneshot;
|
use futures_channel::oneshot;
|
||||||
use futures_util::future::{self, Either, FutureExt, TryFutureExt};
|
use futures_util::future::{self, Either, FutureExt, TryFutureExt};
|
||||||
#[cfg(feature = "unstable-stream")]
|
#[cfg(feature = "stream")]
|
||||||
use futures_util::stream::StreamExt as _;
|
use futures_util::stream::StreamExt as _;
|
||||||
use http::header::{HeaderName, HeaderValue};
|
use http::header::{HeaderName, HeaderValue};
|
||||||
use tokio::net::{TcpListener, TcpStream as TkTcpStream};
|
use tokio::net::{TcpListener, TcpStream as TkTcpStream};
|
||||||
@@ -1383,7 +1383,7 @@ async fn max_buf_size() {
|
|||||||
.expect_err("should TooLarge error");
|
.expect_err("should TooLarge error");
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(feature = "unstable-stream")]
|
#[cfg(feature = "stream")]
|
||||||
#[test]
|
#[test]
|
||||||
fn streaming_body() {
|
fn streaming_body() {
|
||||||
let _ = pretty_env_logger::try_init();
|
let _ = pretty_env_logger::try_init();
|
||||||
@@ -1497,7 +1497,7 @@ async fn http2_service_error_sends_reset_reason() {
|
|||||||
assert_eq!(h2_err.reason(), Some(h2::Reason::INADEQUATE_SECURITY));
|
assert_eq!(h2_err.reason(), Some(h2::Reason::INADEQUATE_SECURITY));
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(feature = "unstable-stream")]
|
#[cfg(feature = "stream")]
|
||||||
#[test]
|
#[test]
|
||||||
fn http2_body_user_error_sends_reset_reason() {
|
fn http2_body_user_error_sends_reset_reason() {
|
||||||
use std::error::Error;
|
use std::error::Error;
|
||||||
|
|||||||
Reference in New Issue
Block a user