Crate bzip3

Source
Expand description

§BZip3-rs

BZip3 compression for Rust.

§BZip3 file structure:

[ magic number ([u8; 5]) | block size (i32) | block1 | block2 | blockN… ]

Structure of each block: [ new size (i32) | read size (i32) | data ]

Due to the naming from the original bzip3 library, new size indicates the data size after compression, and read size indicates the original data size.

§Examples

use std::io::Read;
use bzip3::read::{Bz3Decoder, Bz3Encoder};

let data = "hello, world".as_bytes();
let block_size = 100 * 1024; // 100 kiB

let mut compressor = Bz3Encoder::new(data, block_size).unwrap();
let mut decompressor = Bz3Decoder::new(&mut compressor).unwrap();

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

Re-exports§

pub use errors::Error;
pub use errors::Result;

Modules§

errors
read
Read-based BZip3 compressor and decompressor.
stream
BZip3 compressor and decompressor that do a direct stream-to-stream process.
write
Write-based BZip3 compressor and decompressor.

Structs§

Bz3State
Wrapper for the raw Bz3State.

Constants§

BLOCK_SIZE_MAX
Maximum block size.
BLOCK_SIZE_MIN
Minimum block size.
MAGIC_NUMBER
Signature of a bzip3 file.

Functions§

bound
Returns the recommended output buffer size for the compression function.
version
Version of the underlying bzip3 library.