feat(lib): disable all optional features by default (#2336)
BREAKING CHANGE: All optional features have been disabled by default.
This commit is contained in:
8
.github/workflows/CI.yml
vendored
8
.github/workflows/CI.yml
vendored
@@ -59,11 +59,11 @@ jobs:
|
||||
|
||||
include:
|
||||
- rust: stable
|
||||
features: ""
|
||||
features: "--features full"
|
||||
- rust: beta
|
||||
features: ""
|
||||
features: "--features full"
|
||||
- rust: nightly
|
||||
features: "--features nightly"
|
||||
features: "--features full,nightly"
|
||||
benches: true
|
||||
|
||||
runs-on: ${{ matrix.os }}
|
||||
@@ -132,4 +132,4 @@ jobs:
|
||||
uses: actions-rs/cargo@v1
|
||||
with:
|
||||
command: rustdoc
|
||||
args: -- -D broken-intra-doc-links
|
||||
args: --features full -- -D broken-intra-doc-links
|
||||
|
||||
2
.github/workflows/bench.yml
vendored
2
.github/workflows/bench.yml
vendored
@@ -26,7 +26,7 @@ jobs:
|
||||
|
||||
# Run benchmark and stores the output to a file
|
||||
- name: Run benchmark
|
||||
run: cargo bench --bench ${{ matrix.bench }} | tee output.txt
|
||||
run: cargo bench --features full --bench ${{ matrix.bench }} | tee output.txt
|
||||
|
||||
# Download previous benchmark result from cache (if exists)
|
||||
- name: Download previous benchmark data
|
||||
|
||||
83
Cargo.toml
83
Cargo.toml
@@ -71,14 +71,10 @@ url = "1.0"
|
||||
pnet = "0.25.0"
|
||||
|
||||
[features]
|
||||
default = [
|
||||
"runtime",
|
||||
"stream",
|
||||
"client",
|
||||
"server",
|
||||
"http1",
|
||||
"http2",
|
||||
]
|
||||
# Nothing by default
|
||||
default = []
|
||||
|
||||
# Easily turn it all on
|
||||
full = [
|
||||
"client",
|
||||
"http1",
|
||||
@@ -87,16 +83,6 @@ full = [
|
||||
"stream",
|
||||
"runtime",
|
||||
]
|
||||
runtime = [
|
||||
"tcp",
|
||||
"tokio/rt",
|
||||
]
|
||||
tcp = [
|
||||
"socket2",
|
||||
"tokio/net",
|
||||
"tokio/rt",
|
||||
"tokio/time",
|
||||
]
|
||||
|
||||
# HTTP versions
|
||||
http1 = []
|
||||
@@ -109,6 +95,19 @@ server = []
|
||||
# `impl Stream` for things
|
||||
stream = []
|
||||
|
||||
# Tokio support
|
||||
|
||||
runtime = [
|
||||
"tcp",
|
||||
"tokio/rt",
|
||||
]
|
||||
tcp = [
|
||||
"socket2",
|
||||
"tokio/net",
|
||||
"tokio/rt",
|
||||
"tokio/time",
|
||||
]
|
||||
|
||||
# internal features used in CI
|
||||
nightly = []
|
||||
__internal_happy_eyeballs_tests = []
|
||||
@@ -131,122 +130,122 @@ incremental = false
|
||||
[[example]]
|
||||
name = "client"
|
||||
path = "examples/client.rs"
|
||||
required-features = ["runtime"]
|
||||
required-features = ["full"]
|
||||
|
||||
[[example]]
|
||||
name = "client_json"
|
||||
path = "examples/client_json.rs"
|
||||
required-features = ["runtime"]
|
||||
required-features = ["full"]
|
||||
|
||||
[[example]]
|
||||
name = "echo"
|
||||
path = "examples/echo.rs"
|
||||
required-features = ["runtime", "stream"]
|
||||
required-features = ["full"]
|
||||
|
||||
[[example]]
|
||||
name = "gateway"
|
||||
path = "examples/gateway.rs"
|
||||
required-features = ["runtime"]
|
||||
required-features = ["full"]
|
||||
|
||||
[[example]]
|
||||
name = "hello"
|
||||
path = "examples/hello.rs"
|
||||
required-features = ["runtime"]
|
||||
required-features = ["full"]
|
||||
|
||||
[[example]]
|
||||
name = "http_proxy"
|
||||
path = "examples/http_proxy.rs"
|
||||
required-features = ["runtime"]
|
||||
required-features = ["full"]
|
||||
|
||||
[[example]]
|
||||
name = "multi_server"
|
||||
path = "examples/multi_server.rs"
|
||||
required-features = ["runtime"]
|
||||
required-features = ["full"]
|
||||
|
||||
[[example]]
|
||||
name = "params"
|
||||
path = "examples/params.rs"
|
||||
required-features = ["runtime", "stream"]
|
||||
required-features = ["full"]
|
||||
|
||||
[[example]]
|
||||
name = "send_file"
|
||||
path = "examples/send_file.rs"
|
||||
required-features = ["runtime"]
|
||||
required-features = ["full"]
|
||||
|
||||
[[example]]
|
||||
name = "service_struct_impl"
|
||||
path = "examples/service_struct_impl.rs"
|
||||
required-features = ["runtime"]
|
||||
required-features = ["full"]
|
||||
|
||||
[[example]]
|
||||
name = "single_threaded"
|
||||
path = "examples/single_threaded.rs"
|
||||
required-features = ["runtime"]
|
||||
required-features = ["full"]
|
||||
|
||||
[[example]]
|
||||
name = "state"
|
||||
path = "examples/state.rs"
|
||||
required-features = ["runtime"]
|
||||
required-features = ["full"]
|
||||
|
||||
[[example]]
|
||||
name = "tower_client"
|
||||
path = "examples/tower_client.rs"
|
||||
required-features = ["runtime"]
|
||||
required-features = ["full"]
|
||||
|
||||
[[example]]
|
||||
name = "tower_server"
|
||||
path = "examples/tower_server.rs"
|
||||
required-features = ["runtime"]
|
||||
required-features = ["full"]
|
||||
|
||||
[[example]]
|
||||
name = "upgrades"
|
||||
path = "examples/upgrades.rs"
|
||||
required-features = ["runtime"]
|
||||
required-features = ["full"]
|
||||
|
||||
|
||||
[[example]]
|
||||
name = "web_api"
|
||||
path = "examples/web_api.rs"
|
||||
required-features = ["runtime", "stream"]
|
||||
required-features = ["full"]
|
||||
|
||||
|
||||
[[bench]]
|
||||
name = "body"
|
||||
path = "benches/body.rs"
|
||||
required-features = ["runtime", "stream"]
|
||||
required-features = ["full"]
|
||||
|
||||
[[bench]]
|
||||
name = "connect"
|
||||
path = "benches/connect.rs"
|
||||
required-features = ["runtime"]
|
||||
required-features = ["full"]
|
||||
|
||||
[[bench]]
|
||||
name = "end_to_end"
|
||||
path = "benches/end_to_end.rs"
|
||||
required-features = ["runtime"]
|
||||
required-features = ["full"]
|
||||
|
||||
[[bench]]
|
||||
name = "pipeline"
|
||||
path = "benches/pipeline.rs"
|
||||
required-features = ["runtime"]
|
||||
required-features = ["full"]
|
||||
|
||||
[[bench]]
|
||||
name = "server"
|
||||
path = "benches/server.rs"
|
||||
required-features = ["runtime", "stream"]
|
||||
required-features = ["full"]
|
||||
|
||||
|
||||
[[test]]
|
||||
name = "client"
|
||||
path = "tests/client.rs"
|
||||
required-features = ["runtime", "stream"]
|
||||
required-features = ["full"]
|
||||
|
||||
[[test]]
|
||||
name = "integration"
|
||||
path = "tests/integration.rs"
|
||||
required-features = ["runtime", "stream"]
|
||||
required-features = ["full"]
|
||||
|
||||
[[test]]
|
||||
name = "server"
|
||||
path = "tests/server.rs"
|
||||
required-features = ["runtime"]
|
||||
required-features = ["full"]
|
||||
|
||||
@@ -14,8 +14,7 @@ pub(crate) struct Rewind<T> {
|
||||
}
|
||||
|
||||
impl<T> Rewind<T> {
|
||||
#[cfg(any(feature = "http2", test))]
|
||||
#[cfg(feature = "server")]
|
||||
#[cfg(any(all(feature = "http2", feature = "server"), test))]
|
||||
pub(crate) fn new(io: T) -> Self {
|
||||
Rewind {
|
||||
pre: None,
|
||||
|
||||
27
src/lib.rs
27
src/lib.rs
@@ -31,14 +31,29 @@
|
||||
//!
|
||||
//! # Optional Features
|
||||
//!
|
||||
//! hyper uses a set of [feature flags] to reduce the amount of compiled code.
|
||||
//! It is possible to just enable certain features over others. By default,
|
||||
//! hyper does not enable any features but allows one to enable a subset for
|
||||
//! their use case. Below is a list of the available feature flags. You may
|
||||
//! also notice above each function, struct and trait there is listed one or
|
||||
//! more feature flags that are required for that item to be used.
|
||||
//!
|
||||
//! If you are new to hyper it is possible to enable the `full` feature flag
|
||||
//! which will enable all public APIs. Beware though that this will pull in
|
||||
//! many extra dependencies that you may not need.
|
||||
//!
|
||||
//! The following optional features are available:
|
||||
//!
|
||||
//! - `runtime` (*enabled by default*): Enables convenient integration with
|
||||
//! `tokio`, providing connectors and acceptors for TCP, and a default
|
||||
//! executor.
|
||||
//! - `tcp` (*enabled by default*): Enables convenient implementations over
|
||||
//! TCP (using tokio).
|
||||
//! - `stream` (*enabled by default*): Provides `futures::Stream` capabilities.
|
||||
//! - `http1`: Enables HTTP/1 support.
|
||||
//! - `http2`: Enables HTTP/2 support.
|
||||
//! - `client`: Enables the HTTP `client`.
|
||||
//! - `server`: Enables the HTTP `server`.
|
||||
//! - `runtime`: Enables convenient integration with `tokio`, providing
|
||||
//! connectors and acceptors for TCP, and a default executor.
|
||||
//! - `tcp`: Enables convenient implementations over TCP (using tokio).
|
||||
//! - `stream`: Provides `futures::Stream` capabilities.
|
||||
//!
|
||||
//! [feature flags]: https://doc.rust-lang.org/cargo/reference/manifest.html#the-features-section
|
||||
|
||||
#[doc(hidden)]
|
||||
pub use http;
|
||||
|
||||
Reference in New Issue
Block a user