bzip2 0.3.1

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

Crate bzip2 [] [src]

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!");

Modules

bufread

I/O streams for wrapping BufRead types as encoders/decoders

read

Reader-based compression/decompression streams

write

Writer-based compression/decompression streams

Structs

Compress

Representation of an in-memory compression stream.

Decompress

Representation of an in-memory decompression stream.

Enums

Action

Possible actions to take on compression.

Compression

When compressing data, the compression level can be specified by a value in this enum.

Error

Fatal errors encountered when compressing/decompressing bytes.

Status

Result of compression or decompression