Skip to content

Commit

Permalink
Merge pull request rust-lang#216 from alexcrichton/rust-default
Browse files Browse the repository at this point in the history
Switch to the Rust backend by default
  • Loading branch information
alexcrichton authored Oct 2, 2019
2 parents 5751ad9 + 6305575 commit 5aa2c7b
Show file tree
Hide file tree
Showing 9 changed files with 696 additions and 690 deletions.
18 changes: 3 additions & 15 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,13 +39,13 @@ jobs:
echo "##[add-path]$HOME/.cargo/bin"
if: matrix.os == 'macos-latest'
- run: cargo build
- run: rustdoc --test README.md -L target/debug/deps --extern flate2=target/debug/libflate2.rlib
- run: rustdoc --test README.md -L target/debug/deps --extern flate2=target/debug/libflate2.rlib --edition=2018
- run: cargo test
- run: cargo test --features zlib
- run: cargo test --features tokio
- run: cargo test --features "tokio zlib"
- run: cargo test --features miniz-sys
- run: cargo test --features zlib --no-default-features
- run: cargo test --features miniz-sys --no-default-features
- run: cargo test --features tokio

rustfmt:
name: Rustfmt
Expand Down Expand Up @@ -77,18 +77,6 @@ jobs:
run: rustup update stable && rustup default stable && rustup target add ${{ matrix.target }}
- run: cargo build --target ${{ matrix.target }}

rust_backend:
name: Rust Backend
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@master
- name: Install Rust
run: rustup update stable && rustup default stable
- run: cargo test --features rust_backend
continue-on-error: true
- run: cargo test --features rust_backend --no-default-features
continue-on-error: true

publish_docs:
name: Publish Documentation
runs-on: ubuntu-latest
Expand Down
3 changes: 2 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ members = ['systest']

[dependencies]
libc = "0.2"
cfg-if = "0.1"
miniz-sys = { path = "miniz-sys", version = "0.1.11", optional = true }
libz-sys = { version = "1.0", optional = true }
tokio-io = { version = "0.1.11", optional = true }
Expand All @@ -41,7 +42,7 @@ tokio-threadpool = "0.1.10"
futures = "0.1"

[features]
default = ["miniz-sys"]
default = ["rust_backend"]
zlib = ["libz-sys"]
rust_backend = ["miniz_oxide"]
tokio = ["tokio-io", "futures"]
Expand Down
20 changes: 7 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,11 @@
[![Crates.io](https://img.shields.io/crates/v/flate2.svg?maxAge=2592000)](https://crates.io/crates/flate2)
[![Documentation](https://docs.rs/flate2/badge.svg)](https://docs.rs/flate2)

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

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

Supported formats:

Expand All @@ -23,25 +21,23 @@ Supported formats:
flate2 = "1.0"
```

Using zlib instead of miniz:
Using zlib instead of the Rust backend:

```toml
[dependencies]
flate2 = { version = "1.0", features = ["zlib"], default-features = false }
```

Using the rust back-end:
Using `miniz.c`:

```toml
[dependencies]
flate2 = { version = "1.0", features = ["rust_backend"], default-features = false }
flate2 = { version = "1.0", features = ["miniz-sys"], default-features = false }
```

## Compression

```rust
extern crate flate2;

use std::io::prelude::*;
use flate2::Compression;
use flate2::write::ZlibEncoder;
Expand All @@ -57,8 +53,6 @@ fn main() {
## Decompression

```rust,no_run
extern crate flate2;
use std::io::prelude::*;
use flate2::read::GzDecoder;
Expand Down
Loading

0 comments on commit 5aa2c7b

Please sign in to comment.