#bzip #encoding

bzip2

Bindings to libbzip2 for bzip2 compression and decompression exposed as Reader/Writer streams.

15 releases

0.3.2 Apr 12, 2017
0.3.1 Jan 20, 2017
0.3.0 Feb 8, 2016
0.2.3 Apr 3, 2015
0.0.3 Nov 19, 2014

#10 in Compression

Download history 3542/week @ 2018-05-06 4500/week @ 2018-05-13 4394/week @ 2018-05-20 4824/week @ 2018-05-27 4197/week @ 2018-06-03 5509/week @ 2018-06-10 3988/week @ 2018-06-17 4594/week @ 2018-06-24 4477/week @ 2018-07-01 3120/week @ 2018-07-08 4092/week @ 2018-07-15 4595/week @ 2018-07-22 3171/week @ 2018-07-29

11,072 downloads per month

bzip2

Build Status Build status

Documentation

A streaming compression/decompression library for rust with bindings to libbz2.

# Cargo.toml
[dependencies]
bzip2 = "0.3.2"

License

This project is licensed under either of

at your option.

Contribution

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in Serde by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.


lib.rs:

Bzip compression for Rust

This library contains bindings to libbz2 to support bzip compression and decompression for Rust. The streams offered in this library are primarily found in the reader and writer modules. Both compressors and decompressors are available in each module depending on what operation you need.

Access to the raw decompression/compression stream is also provided through the raw module which has a much closer interface to libbz2.

Example

use std::io::prelude::*;
use bzip2::Compression;
use bzip2::read::{BzEncoder, BzDecoder};

// Round trip some bytes from a byte source, into a compressor, into a
// decompressor, and finally into a vector.
let data = "Hello, World!".as_bytes();
let compressor = BzEncoder::new(data, Compression::Best);
let mut decompressor = BzDecoder::new(compressor);

let mut contents = String::new();
decompressor.read_to_string(&mut contents).unwrap();
assert_eq!(contents, "Hello, World!");

Async I/O

This crate optionally can support async I/O streams with the Tokio stack via the tokio feature of this crate:

bzip2 = { version = "0.3", features = ["tokio"] }

All methods are internally capable of working with streams that may return ErrorKind::WouldBlock when they're not ready to perform the particular operation.

Note that care needs to be taken when using these objects, however. The Tokio runtime, in particular, requires that data is fully flushed before dropping streams. For compatibility with blocking streams all streams are flushed/written when they are dropped, and this is not always a suitable time to perform I/O. If I/O streams are flushed before drop, however, then these operations will be a noop.

MIT/Apache-2.0 license

Dependencies

Reverse deps