Sample code for 30+ languages & platforms
Rust

bz2 Compress File

Compress a file to the bz2 file format.

Chilkat Rust Downloads

Rust

// This example requires the Chilkat API to have been previously unlocked.
// See Global Unlock Sample for sample code.

let bz2 = chilkat::Bz2::new();

// Compress the file qa_data/hamlet.xml to create qa_output/hamlet.bz2
if bz2.compress_file("qa_data/hamlet.xml", "qa_output/hamlet.bz2").is_err() {
    println!("{}", bz2.last_error_text());
    return;
}

println!("Success.");