Skip to content

Commit 11404fc

Browse files
bors[bot]Nemo157
andauthored
Merge #54
54: Change default features r=Nemo157 a=Nemo157 Disables all features by default and updates documentation for them. closes #46 Co-authored-by: Wim Looman <[email protected]>
2 parents e88c6d5 + a086079 commit 11404fc

File tree

7 files changed

+131
-44
lines changed

7 files changed

+131
-44
lines changed

.travis.yml

+10-9
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ rust:
66
- nightly
77

88
script:
9-
- cargo test --all
9+
- cargo test --all-features
1010

1111
matrix:
1212
include:
@@ -23,16 +23,17 @@ matrix:
2323
- cargo update
2424
- cargo audit
2525

26-
- name: cargo build --features
26+
- name: cargo check --features
2727
script:
2828
# Need to remove dev-dependencies so that they don't affect feature resolution
2929
- cargo run --manifest-path ci/remove-dev-dependencies/Cargo.toml
3030
# A somewhat arbitrary selection of features to check
31-
- cargo build --no-default-features
32-
- cargo build --no-default-features --features brotli,deflate,gzip,zlib,zstd,stream
33-
- cargo build --no-default-features --features brotli,deflate,gzip,zlib,zstd,bufread
34-
- cargo build --no-default-features --features brotli,bufread,stream
35-
- cargo build --no-default-features --features zstd,bufread,stream
31+
- cargo check
32+
- cargo check --features brotli,deflate,gzip,zlib,zstd,stream
33+
- cargo check --features brotli,deflate,gzip,zlib,zstd,bufread
34+
- cargo check --features brotli,bufread,stream
35+
- cargo check --features zstd,bufread,stream
36+
- cargo check --features all
3637

3738
- name: docs.rs
3839
rust: nightly
@@ -44,13 +45,13 @@ matrix:
4445
install:
4546
- rustup component add rustfmt
4647
script:
47-
- cargo fmt --all -- --check
48+
- cargo fmt -- --check
4849

4950
- name: cargo clippy
5051
install:
5152
- rustup component add clippy
5253
script:
53-
- cargo clippy --all --all-targets -- -D warnings
54+
- cargo clippy --all-targets --all-features -- -D warnings
5455

5556
branches:
5657
only: [staging, trying, master]

Cargo.toml

+37-1
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,18 @@ all-features = true
1616
rustdoc-args = ["--cfg", "docsrs"]
1717

1818
[features]
19-
default = ["bufread", "stream", "write", "brotli", "bzip", "deflate", "gzip", "zlib", "zstd"]
19+
# groups
20+
default = []
21+
all = ["all-implementations", "all-algorithms"]
22+
all-implementations = ["bufread", "write", "stream"]
23+
all-algorithms = ["brotli", "bzip", "deflate", "gzip", "zlib", "zstd"]
24+
25+
# implementations
2026
bufread = ["futures-io"]
2127
write = ["futures-io"]
2228
stream = ["bytes"]
29+
30+
# algorithms
2331
brotli = ["brotli2"]
2432
bzip = ["bzip2"]
2533
deflate = ["flate2"]
@@ -47,3 +55,31 @@ futures = "0.3.0"
4755
futures-test = "0.3.0"
4856
ntest = "0.3.3"
4957
timebomb = "0.1.2"
58+
59+
[[test]]
60+
name = "brotli"
61+
required-features = ["all-implementations", "brotli"]
62+
63+
[[test]]
64+
name = "bzip"
65+
required-features = ["all-implementations", "bzip"]
66+
67+
[[test]]
68+
name = "deflate"
69+
required-features = ["all-implementations", "deflate"]
70+
71+
[[test]]
72+
name = "gzip"
73+
required-features = ["all-implementations", "gzip"]
74+
75+
[[test]]
76+
name = "zlib"
77+
required-features = ["all-implementations", "zlib"]
78+
79+
[[test]]
80+
name = "zstd"
81+
required-features = ["all-implementations", "zstd"]
82+
83+
[[test]]
84+
name = "proptest"
85+
required-features = ["all"]

README.md

+10-6
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,13 @@ asynchronous IO types.
99
- [Crates.io][2]
1010
- [Releases][releases]
1111

12+
## Development
13+
14+
When developing you will need to enable appropriate features for the different
15+
test cases to run, the simplest is `cargo test --all-features`, but you can
16+
enable different subsets of features as appropriate for the code you are
17+
testing to avoid compiling all dependencies.
18+
1219
## License
1320

1421
Licensed under either of
@@ -26,14 +33,11 @@ additional terms or conditions.
2633

2734
[1]: https://img.shields.io/crates/v/async-compression.svg?style=flat-square
2835
[2]: https://crates.io/crates/async-compression
29-
[3]: https://img.shields.io/travis/rustasync/async-compression/master.svg?style=flat-square
30-
[4]: https://travis-ci.org/rustasync/async-compression
36+
[3]: https://img.shields.io/travis/Nemo157/async-compression/master.svg?style=flat-square
37+
[4]: https://travis-ci.com/Nemo157/async-compression
3138
[5]: https://img.shields.io/crates/d/async-compression.svg?style=flat-square
3239
[6]: https://crates.io/crates/async-compression
3340
[7]: https://img.shields.io/badge/docs-latest-blue.svg?style=flat-square
3441
[8]: https://docs.rs/async-compression
3542

36-
[releases]: https://github.com/rustasync/async-compression/releases
37-
[contributing]: https://github.com/rustasync/async-compression/blob/master.github/CONTRIBUTING.md
38-
[good-first-issue]: https://github.com/rustasync/async-compression/labels/good%20first%20issue
39-
[help-wanted]: https://github.com/rustasync/async-compression/labels/help%20wanted
43+
[releases]: https://github.com/Nemo157/async-compression/releases

src/lib.rs

+71-25
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,30 @@
11
//! Adaptors between compression crates and Rust's modern asynchronous IO types.
22
//!
3-
//!
3+
44
//! # Feature Organization
55
//!
66
//! This crate is divided up along two axes, which can each be individually selected via Cargo
77
//! features.
88
//!
9-
//! All features are default active, it's recommended you use this crate with `default-features =
10-
//! false` and enable just the features you need. (We're considering disabling this and shipping
11-
//! with no features active by default, please [leave a comment][#46] if you have an opinion either
12-
//! way).
9+
//! All features are disabled by default, you should enable just the ones you need from the lists
10+
//! below.
1311
//!
14-
//! [#46]: https://github.com/rustasync/async-compression/issues/46
12+
//! If you want to pull in everything there are three group features defined:
1513
//!
16-
//! ## IO type
14+
15+
//! Feature | Does
16+
//! ---------|------
17+
//! `all` | Activates all implementations and algorithms.
18+
//! `all-implementations` | Activates all implementations, needs to be pared with a selection of algorithms
19+
//! `all-algorithms` | Activates all algorithms, needs to be pared with a selection of implementations
1720
//!
18-
//! The first division is which underlying asynchronous IO type will be wrapped, these are
19-
//! available as two separate features that have corresponding top-level modules:
21+
22+
//! ## IO implementation
2023
//!
24+
//! The first division is which underlying asynchronous IO trait will be wrapped, these are
25+
//! available as separate features that have corresponding top-level modules:
26+
//!
27+
2128
//! Feature | Type
2229
//! ---------|------
2330
// TODO: Kill rustfmt on this section, `#![rustfmt::skip::attributes(cfg_attr)]` should do it, but
@@ -47,24 +54,63 @@
4754
doc = "`stream` (*inactive*) | `futures::stream::Stream<Item = std::io::Result<bytes::Bytes>>`"
4855
)]
4956
//!
57+
58+
//! ## Compression algorithm
5059
//!
51-
//! ## Compression implementation
52-
//!
53-
//! The second division is which compression scheme to use, there are currently a few available
54-
//! choices, these determine which types will be available inside the above modules:
60+
//! The second division is which compression schemes to support, there are currently a few
61+
//! available choices, these determine which types will be available inside the above modules:
5562
//!
56-
#![cfg_attr(feature = "brotli", doc = "* `brotli`")]
57-
#![cfg_attr(not(feature = "brotli"), doc = "* `brotli` (*inactive*)")]
58-
#![cfg_attr(feature = "bzip", doc = "* `bzip`")]
59-
#![cfg_attr(not(feature = "bzip"), doc = "* `bzip` (*inactive*)")]
60-
#![cfg_attr(feature = "deflate", doc = "* `deflate`")]
61-
#![cfg_attr(not(feature = "deflate"), doc = "* `deflate` (*inactive*)")]
62-
#![cfg_attr(feature = "gzip", doc = "* `gzip`")]
63-
#![cfg_attr(not(feature = "gzip"), doc = "* `gzip` (*inactive*)")]
64-
#![cfg_attr(feature = "zlib", doc = "* `zlib`")]
65-
#![cfg_attr(not(feature = "zlib"), doc = "* `zlib` (*inactive*)")]
66-
#![cfg_attr(feature = "zstd", doc = "* `zstd`")]
67-
#![cfg_attr(not(feature = "zstd"), doc = "* `zstd` (*inactive*)")]
63+
64+
//! Feature | Types
65+
//! ---------|------
66+
#![cfg_attr(
67+
feature = "brotli",
68+
doc = "`brotli` | [`BrotliEncoder`](?search=BrotliEncoder), [`BrotliDecoder`](?search=BrotliDecoder)"
69+
)]
70+
#![cfg_attr(
71+
not(feature = "brotli"),
72+
doc = "`brotli` (*inactive*) | `BrotliEncoder`, `BrotliDecoder`"
73+
)]
74+
#![cfg_attr(
75+
feature = "bzip",
76+
doc = "`bzip` | [`BzEncoder`](?search=BzEncoder), [`BzDecoder`](?search=BzDecoder)"
77+
)]
78+
#![cfg_attr(
79+
not(feature = "bzip"),
80+
doc = "`bzip` (*inactive*) | `BzEncoder`, `BzDecoder`"
81+
)]
82+
#![cfg_attr(
83+
feature = "deflate",
84+
doc = "`deflate` | [`DeflateEncoder`](?search=DeflateEncoder), [`DeflateDecoder`](?search=DeflateDecoder)"
85+
)]
86+
#![cfg_attr(
87+
not(feature = "deflate"),
88+
doc = "`deflate` (*inactive*) | `DeflateEncoder`, `DeflateDecoder`"
89+
)]
90+
#![cfg_attr(
91+
feature = "gzip",
92+
doc = "`gzip` | [`GzipEncoder`](?search=GzipEncoder), [`GzipDecoder`](?search=GzipDecoder)"
93+
)]
94+
#![cfg_attr(
95+
not(feature = "gzip"),
96+
doc = "`gzip` (*inactive*) | `GzipEncoder`, `GzipDecoder`"
97+
)]
98+
#![cfg_attr(
99+
feature = "zlib",
100+
doc = "`zlib` | [`ZlibEncoder`](?search=ZlibEncoder), [`ZlibDecoder`](?search=ZlibDecoder)"
101+
)]
102+
#![cfg_attr(
103+
not(feature = "zlib"),
104+
doc = "`zlib` (*inactive*) | `ZlibEncoder`, `ZlibDecoder`"
105+
)]
106+
#![cfg_attr(
107+
feature = "zstd",
108+
doc = "`zstd` | [`ZstdEncoder`](?search=ZstdEncoder), [`ZstdDecoder`](?search=ZstdDecoder)"
109+
)]
110+
#![cfg_attr(
111+
not(feature = "zstd"),
112+
doc = "`zstd` (*inactive*) | `ZstdEncoder`, `ZstdDecoder`"
113+
)]
68114
//!
69115
70116
#![cfg_attr(docsrs, feature(doc_cfg))]
+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
#[macro_use]
22
mod utils;
33

4-
test_cases!(bzip2);
4+
test_cases!(bzip);

tests/proptest.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -74,4 +74,4 @@ macro_rules! tests {
7474
}
7575
}
7676

77-
tests!(brotli, bzip2, deflate, gzip, zlib, zstd);
77+
tests!(brotli, bzip, deflate, gzip, zlib, zstd);

tests/utils/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,7 @@ pub mod brotli {
190190
}
191191
}
192192

193-
pub mod bzip2 {
193+
pub mod bzip {
194194
pub mod sync {
195195
use crate::utils::prelude::*;
196196

0 commit comments

Comments
 (0)