Skip to content

Commit c479d06

Browse files
committed
Switch to the Rust backend by default
Closes #215
1 parent 5751ad9 commit c479d06

File tree

4 files changed

+47
-37
lines changed

4 files changed

+47
-37
lines changed

.github/workflows/main.yml

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -42,10 +42,10 @@ jobs:
4242
- run: rustdoc --test README.md -L target/debug/deps --extern flate2=target/debug/libflate2.rlib
4343
- run: cargo test
4444
- run: cargo test --features zlib
45-
- run: cargo test --features tokio
46-
- run: cargo test --features "tokio zlib"
45+
- run: cargo test --features miniz-sys
4746
- run: cargo test --features zlib --no-default-features
4847
- run: cargo test --features miniz-sys --no-default-features
48+
- run: cargo test --features tokio
4949

5050
rustfmt:
5151
name: Rustfmt
@@ -77,18 +77,6 @@ jobs:
7777
run: rustup update stable && rustup default stable && rustup target add ${{ matrix.target }}
7878
- run: cargo build --target ${{ matrix.target }}
7979

80-
rust_backend:
81-
name: Rust Backend
82-
runs-on: ubuntu-latest
83-
steps:
84-
- uses: actions/checkout@master
85-
- name: Install Rust
86-
run: rustup update stable && rustup default stable
87-
- run: cargo test --features rust_backend
88-
continue-on-error: true
89-
- run: cargo test --features rust_backend --no-default-features
90-
continue-on-error: true
91-
9280
publish_docs:
9381
name: Publish Documentation
9482
runs-on: ubuntu-latest

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ tokio-threadpool = "0.1.10"
4141
futures = "0.1"
4242

4343
[features]
44-
default = ["miniz-sys"]
44+
default = ["rust_backend"]
4545
zlib = ["libz-sys"]
4646
rust_backend = ["miniz_oxide"]
4747
tokio = ["tokio-io", "futures"]

README.md

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,11 @@
33
[![Crates.io](https://img.shields.io/crates/v/flate2.svg?maxAge=2592000)](https://crates.io/crates/flate2)
44
[![Documentation](https://docs.rs/flate2/badge.svg)](https://docs.rs/flate2)
55

6-
A streaming compression/decompression library for Rust. The underlying
7-
implementation by default uses [`miniz`](https://github.com/richgel999/miniz) but
8-
can optionally be configured to use the system zlib, if available.
6+
A streaming compression/decompression library DEFALTE-based streams in Rust.
97

10-
There is also an experimental rust backend that uses the
11-
[`miniz_oxide`](https://crates.io/crates/miniz_oxide) crate. This avoids the need
12-
to build C code, but hasn't gone through as much testing as the other backends.
8+
This crate by default implemented as a wrapper around the `miniz_oxide` crate, a
9+
port of `miniz.c` to Rust. This crate can also optionally use the zlib library
10+
or `miniz.c` itself.
1311

1412
Supported formats:
1513

@@ -23,25 +21,23 @@ Supported formats:
2321
flate2 = "1.0"
2422
```
2523

26-
Using zlib instead of miniz:
24+
Using zlib instead of the Rust backend:
2725

2826
```toml
2927
[dependencies]
3028
flate2 = { version = "1.0", features = ["zlib"], default-features = false }
3129
```
3230

33-
Using the rust back-end:
31+
Using `miniz.c`:
3432

3533
```toml
3634
[dependencies]
37-
flate2 = { version = "1.0", features = ["rust_backend"], default-features = false }
35+
flate2 = { version = "1.0", features = ["miniz-sys"], default-features = false }
3836
```
3937

4038
## Compression
4139

4240
```rust
43-
extern crate flate2;
44-
4541
use std::io::prelude::*;
4642
use flate2::Compression;
4743
use flate2::write::ZlibEncoder;
@@ -57,8 +53,6 @@ fn main() {
5753
## Decompression
5854

5955
```rust,no_run
60-
extern crate flate2;
61-
6256
use std::io::prelude::*;
6357
use flate2::read::GzDecoder;
6458

src/lib.rs

Lines changed: 37 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,42 @@
11
//! A DEFLATE-based stream compression/decompression library
22
//!
3-
//! This library is meant to supplement/replace the
4-
//! `flate` library that was previously part of the standard rust distribution
5-
//! providing a streaming encoder/decoder rather than purely
6-
//! an in-memory encoder/decoder.
7-
//!
8-
//! Like with [`flate`], flate2 is based on [`miniz.c`][1]
9-
//!
10-
//! [1]: https://github.com/richgel999/miniz
11-
//! [`flate`]: https://github.com/rust-lang/rust/tree/1.19.0/src/libflate
3+
//! This library provides support for compression and decompression of
4+
//! DEFLATE-based streams:
5+
//!
6+
//! * the DEFLATE format itself
7+
//! * the zlib format
8+
//! * gzip
9+
//!
10+
//! These three formats are all closely related and largely only differ in their
11+
//! headers/footers. This crate has three types in each submodule for dealing
12+
//! with these three formats.
13+
//!
14+
//! # Implementation
15+
//!
16+
//! In addition to supporting three formats, this crate supports three different
17+
//! backends, controlled through this crate's features:
18+
//!
19+
//! * `default`, or `rust_backend` - this implementation uses the `miniz_oxide`
20+
//! crate which is a port of `miniz.c` (below) to Rust. This feature does not
21+
//! require a C compiler and only requires Rust code.
22+
//!
23+
//! * `miniz-sys` - when enabled this feature will enable this crate to instead
24+
//! use `miniz.c`, distributed with `miniz-sys`, to implement
25+
//! compression/decompression.
26+
//!
27+
//! * `zlib` - finally, this feature will enable linking against the `libz`
28+
//! library, typically found on most Linux systems by default. If the library
29+
//! isn't found to already be on the system it will be compiled from source
30+
//! (this is a C library).
31+
//!
32+
//! There's various tradeoffs associated with each implementation, but in
33+
//! general you probably won't have to tweak the defaults. The default choice is
34+
//! selected to avoid the need for a C compiler at build time. The `miniz-sys`
35+
//! feature is largely a historical artifact at this point and is unlikely to be
36+
//! needed, and `zlib` is often useful if you're already using `zlib` for other
37+
//! C dependencies. The compression ratios and performance of each of these
38+
//! feature should be roughly comparable, but you'll likely want to run your own
39+
//! tests if you're curious about the performance.
1240
//!
1341
//! # Organization
1442
//!

0 commit comments

Comments
 (0)