11 releases (6 breaking)

0.11.0 Dec 18, 2024
0.9.0 Dec 8, 2023
0.8.3 Oct 20, 2023
0.8.0 Jun 11, 2023
0.5.0 Mar 25, 2023

#232 in Compression

Download history 57/week @ 2024-12-04 182/week @ 2024-12-11 381/week @ 2024-12-18 2/week @ 2024-12-25 219/week @ 2025-01-01 40/week @ 2025-01-08 214/week @ 2025-01-15 272/week @ 2025-01-29 43/week @ 2025-02-05 454/week @ 2025-02-12 14/week @ 2025-02-19 202/week @ 2025-02-26 167/week @ 2025-03-12 7/week @ 2025-03-19

378 downloads per month
Used in 2 crates

LGPL-3.0-only

135KB
2.5K SLoC

C 1.5K SLoC // 0.1% comments Rust 743 SLoC // 0.0% comments M4 311 SLoC // 0.5% comments Automake 56 SLoC // 0.0% comments Shell 17 SLoC // 0.1% comments

bzip3-rs

This is a Rust wrapper for bzip3.

Documentation

Crate Features

  • bundled: use bundled libbzip3

Current bundled bzip3 library version is kspalaiologos/bzip3@1.5.1.

TODO

Stream encoder/decoder multithreading support.


lib.rs:

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

Dependencies

~1.5–4MB
~82K SLoC