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 interfact to libbz2.

Example

use std::io::prelude::*;
use bzip2::Compress;
use bzip2::reader::{BzCompressor, BzDecompressor};

// 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 = BzCompressor::new(data, Compress::Best);
let mut decompressor = BzDecompressor::new(compressor);

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

Modules

raw

Raw low-level manipulations of bz streams.

reader

Reader-based compression/decompression streams

writer

Writer-based compression/decompression streams

Enums

Compress

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

Functions

compress

Compress a block of input data into a bzip2 encoded output vector.

decompress

Decompress a block of compressed input data into a raw output vector.