Skip to content

Commit 6cd3083

Browse files
committed
feat(lib): rename unstable-stream feature to stream and enable by default
Closes #2034
1 parent a738d03 commit 6cd3083

File tree

6 files changed

+37
-39
lines changed

6 files changed

+37
-39
lines changed

.travis.yml

+3-3
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,11 @@ matrix:
55
fast_finish: true
66
include:
77
- rust: nightly
8-
env: FEATURES="--no-default-features --features runtime,unstable-stream,nightly"
8+
env: FEATURES="--no-default-features --features runtime,stream,nightly"
99
- rust: beta
10-
env: FEATURES="--no-default-features --features runtime,unstable-stream,__internal_happy_eyeballs_tests"
10+
env: FEATURES="--no-default-features --features runtime,stream,__internal_happy_eyeballs_tests"
1111
#- rust: stable
12-
# env: FEATURES="--no-default-features --features runtime,unstable-stream,__internal_happy_eyeballs_tests"
12+
# env: FEATURES="--no-default-features --features runtime,stream,__internal_happy_eyeballs_tests"
1313
- rust: beta #stable
1414
env: FEATURES="--no-default-features"
1515
# Minimum Supported Rust Version

Cargo.toml

+11-10
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ url = "1.0"
5757
default = [
5858
"__internal_flaky_tests",
5959
"runtime",
60+
"stream",
6061
]
6162
runtime = [
6263
"tcp",
@@ -69,8 +70,8 @@ tcp = [
6970
"tokio/time",
7071
]
7172

72-
# unstable features
73-
unstable-stream = []
73+
# `impl Stream` for things
74+
stream = []
7475

7576
# internal features used in CI
7677
nightly = []
@@ -80,7 +81,7 @@ __internal_happy_eyeballs_tests = []
8081
[package.metadata.docs.rs]
8182
features = [
8283
"runtime",
83-
"unstable-stream",
84+
"stream",
8485
]
8586

8687
[profile.release]
@@ -99,12 +100,12 @@ required-features = ["runtime"]
99100
[[example]]
100101
name = "client_json"
101102
path = "examples/client_json.rs"
102-
required-features = ["runtime", "unstable-stream"]
103+
required-features = ["runtime", "stream"]
103104

104105
[[example]]
105106
name = "echo"
106107
path = "examples/echo.rs"
107-
required-features = ["runtime", "unstable-stream"]
108+
required-features = ["runtime", "stream"]
108109

109110
[[example]]
110111
name = "hello"
@@ -119,7 +120,7 @@ required-features = ["runtime"]
119120
[[example]]
120121
name = "params"
121122
path = "examples/params.rs"
122-
required-features = ["runtime", "unstable-stream"]
123+
required-features = ["runtime", "stream"]
123124

124125
[[example]]
125126
name = "proxy"
@@ -160,7 +161,7 @@ required-features = ["runtime"]
160161
[[example]]
161162
name = "web_api"
162163
path = "examples/web_api.rs"
163-
required-features = ["runtime", "unstable-stream"]
164+
required-features = ["runtime", "stream"]
164165

165166

166167
[[bench]]
@@ -181,18 +182,18 @@ required-features = ["runtime"]
181182
[[bench]]
182183
name = "server"
183184
path = "benches/server.rs"
184-
required-features = ["runtime", "unstable-stream"]
185+
required-features = ["runtime", "stream"]
185186

186187

187188
[[test]]
188189
name = "client"
189190
path = "tests/client.rs"
190-
required-features = ["runtime", "unstable-stream"]
191+
required-features = ["runtime", "stream"]
191192

192193
[[test]]
193194
name = "integration"
194195
path = "tests/integration.rs"
195-
required-features = ["runtime", "unstable-stream"]
196+
required-features = ["runtime", "stream"]
196197

197198
[[test]]
198199
name = "server"

src/body/body.rs

+15-15
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
use std::borrow::Cow;
2-
#[cfg(feature = "unstable-stream")]
2+
#[cfg(feature = "stream")]
33
use std::error::Error as StdError;
44
use std::fmt;
55

66
use bytes::Bytes;
77
use futures_core::Stream; // for mpsc::Receiver
88
use futures_channel::{mpsc, oneshot};
9-
#[cfg(feature = "unstable-stream")]
9+
#[cfg(feature = "stream")]
1010
use futures_util::TryStreamExt;
1111
use http_body::{SizeHint, Body as HttpBody};
1212
use http::HeaderMap;
@@ -43,7 +43,7 @@ enum Kind {
4343
// while a borrow of a `Request<Body>` exists.
4444
//
4545
// See https://github.com/rust-lang/rust/issues/57017
46-
#[cfg(feature = "unstable-stream")]
46+
#[cfg(feature = "stream")]
4747
Wrapped(Pin<Box<dyn Stream<Item = Result<Chunk, Box<dyn StdError + Send + Sync>>> + Send + Sync>>),
4848
}
4949

@@ -142,11 +142,11 @@ impl Body {
142142
/// # }
143143
/// ```
144144
///
145-
/// # Unstable
145+
/// # Optional
146146
///
147-
/// This function requires enabling the `unstable-stream` feature in your
147+
/// This function requires enabling the `stream` feature in your
148148
/// `Cargo.toml`.
149-
#[cfg(feature = "unstable-stream")]
149+
#[cfg(feature = "stream")]
150150
pub fn wrap_stream<S, O, E>(stream: S) -> Body
151151
where
152152
S: Stream<Item = Result<O, E>> + Send + Sync + 'static,
@@ -280,7 +280,7 @@ impl Body {
280280
None => Poll::Ready(None),
281281
},
282282

283-
#[cfg(feature = "unstable-stream")]
283+
#[cfg(feature = "stream")]
284284
Kind::Wrapped(ref mut s) => {
285285
match ready!(s.as_mut().poll_next(cx)) {
286286
Some(res) => Poll::Ready(Some(res.map_err(crate::Error::new_body))),
@@ -330,7 +330,7 @@ impl HttpBody for Body {
330330
Kind::Once(ref val) => val.is_none(),
331331
Kind::Chan { content_length, .. } => content_length == Some(0),
332332
Kind::H2 { recv: ref h2, .. } => h2.is_end_stream(),
333-
#[cfg(feature = "unstable-stream")]
333+
#[cfg(feature = "stream")]
334334
Kind::Wrapped(..) => false,
335335
}
336336
}
@@ -345,7 +345,7 @@ impl HttpBody for Body {
345345
Kind::Once(None) => {
346346
SizeHint::default()
347347
},
348-
#[cfg(feature = "unstable-stream")]
348+
#[cfg(feature = "stream")]
349349
Kind::Wrapped(..) => SizeHint::default(),
350350
Kind::Chan { content_length, .. } | Kind::H2 { content_length, .. } => {
351351
let mut hint = SizeHint::default();
@@ -380,11 +380,11 @@ impl fmt::Debug for Body {
380380
}
381381
}
382382

383-
/// # Unstable
383+
/// # Optional
384384
///
385-
/// This function requires enabling the `unstable-stream` feature in your
385+
/// This function requires enabling the `stream` feature in your
386386
/// `Cargo.toml`.
387-
#[cfg(feature = "unstable-stream")]
387+
#[cfg(feature = "stream")]
388388
impl Stream for Body {
389389
type Item = crate::Result<Chunk>;
390390

@@ -394,11 +394,11 @@ impl Stream for Body {
394394
}
395395

396396

397-
/// # Unstable
397+
/// # Optional
398398
///
399-
/// This function requires enabling the `unstable-stream` feature in your
399+
/// This function requires enabling the `stream` feature in your
400400
/// `Cargo.toml`.
401-
#[cfg(feature = "unstable-stream")]
401+
#[cfg(feature = "stream")]
402402
impl
403403
From<Box<dyn Stream<Item = Result<Chunk, Box<dyn StdError + Send + Sync>>> + Send + Sync>>
404404
for Body

src/lib.rs

+1-4
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,7 @@
2727
//! executor.
2828
//! - `tcp` (*enabled by default*): Enables convenient implementations over
2929
//! TCP (using tokio).
30-
//! - `unstable-stream` (*unstable*): Provides `futures::Stream` capabilities.
31-
//!
32-
//! Due to the `Stream` trait not being stable, this feature is also
33-
//! unstable. It does not follow normal semver.
30+
//! - `stream` (*enabled by default*): Provides `futures::Stream` capabilities.
3431
3532
#[doc(hidden)] pub use http;
3633
#[macro_use] extern crate log;

src/server/accept.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
//! connections.
77
//! - Utilities like `poll_fn` to ease creating a custom `Accept`.
88
9-
#[cfg(feature = "unstable-stream")]
9+
#[cfg(feature = "stream")]
1010
use futures_core::Stream;
1111

1212
use crate::common::{Pin, task::{self, Poll}};
@@ -68,11 +68,11 @@ where
6868

6969
/// Adapt a `Stream` of incoming connections into an `Accept`.
7070
///
71-
/// # Unstable
71+
/// # Optional
7272
///
73-
/// This function requires enabling the `unstable-stream` feature in your
73+
/// This function requires enabling the `stream` feature in your
7474
/// `Cargo.toml`.
75-
#[cfg(feature = "unstable-stream")]
75+
#[cfg(feature = "stream")]
7676
pub fn from_stream<S, IO, E>(stream: S) -> impl Accept<Conn = IO, Error = E>
7777
where
7878
S: Stream<Item = Result<IO, E>>,

tests/server.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ use std::time::Duration;
1515

1616
use futures_channel::oneshot;
1717
use futures_util::future::{self, Either, FutureExt, TryFutureExt};
18-
#[cfg(feature = "unstable-stream")]
18+
#[cfg(feature = "stream")]
1919
use futures_util::stream::StreamExt as _;
2020
use http::header::{HeaderName, HeaderValue};
2121
use tokio::net::{TcpListener, TcpStream as TkTcpStream};
@@ -1383,7 +1383,7 @@ async fn max_buf_size() {
13831383
.expect_err("should TooLarge error");
13841384
}
13851385

1386-
#[cfg(feature = "unstable-stream")]
1386+
#[cfg(feature = "stream")]
13871387
#[test]
13881388
fn streaming_body() {
13891389
let _ = pretty_env_logger::try_init();
@@ -1497,7 +1497,7 @@ async fn http2_service_error_sends_reset_reason() {
14971497
assert_eq!(h2_err.reason(), Some(h2::Reason::INADEQUATE_SECURITY));
14981498
}
14991499

1500-
#[cfg(feature = "unstable-stream")]
1500+
#[cfg(feature = "stream")]
15011501
#[test]
15021502
fn http2_body_user_error_sends_reset_reason() {
15031503
use std::error::Error;

0 commit comments

Comments
 (0)