#decompression #lzma #file-format

lzma-rs

A codec for LZMA, LZMA2 and XZ written in pure Rust

7 releases

0.3.0 Jan 4, 2023
0.2.0 May 2, 2021
0.1.4 May 2, 2021
0.1.3 May 5, 2020
0.1.0 Jan 7, 2018

#67 in Compression

Download history 204511/week @ 2024-11-16 153657/week @ 2024-11-23 156573/week @ 2024-11-30 264328/week @ 2024-12-07 219851/week @ 2024-12-14 83810/week @ 2024-12-21 135921/week @ 2024-12-28 244914/week @ 2025-01-04 294373/week @ 2025-01-11 223193/week @ 2025-01-18 247811/week @ 2025-01-25 253659/week @ 2025-02-01 267935/week @ 2025-02-08 268642/week @ 2025-02-15 337330/week @ 2025-02-22 279222/week @ 2025-03-01

1,193,685 downloads per month
Used in 105 crates (49 directly)

MIT license

125KB
3K SLoC

lzma-rs

Crate Documentation Safety Dance Build Status Minimum rust 1.50 Codecov

This project is a decoder for LZMA and its variants written in pure Rust, with focus on clarity. It already supports LZMA, LZMA2 and a subset of the .xz file format.

Usage

Decompress a .xz file.

let filename = "foo.xz";
let mut f = std::io::BufReader::new(std::fs::File::open(filename).unwrap());
// "decomp" can be anything that implements "std::io::Write"
let mut decomp: Vec<u8> = Vec::new();
lzma_rs::xz_decompress(&mut f, &mut decomp).unwrap();
// Decompressed content is now in "decomp"

Encoder

For now, there is also a dumb encoder that only uses byte literals, with many hard-coded constants for code simplicity. Better encoders are welcome!

Contributing

Pull-requests are welcome, to improve the decoder, add better encoders, or more tests. Ultimately, this project should also implement .xz and .7z files.

License

MIT

Dependencies

~0.2–7MB
~46K SLoC