#lzma #compression #decompression

lzma-rs

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

6 releases

new 0.2.0 May 2, 2021
0.1.4 May 2, 2021
0.1.3 May 5, 2020
0.1.2 Dec 17, 2019
0.1.0 Jan 7, 2018

#17 in Compression

Download history 2068/week @ 2021-01-16 2802/week @ 2021-01-23 3358/week @ 2021-01-30 2052/week @ 2021-02-06 2200/week @ 2021-02-13 1484/week @ 2021-02-20 2272/week @ 2021-02-27 1796/week @ 2021-03-06 1595/week @ 2021-03-13 1973/week @ 2021-03-20 1632/week @ 2021-03-27 1310/week @ 2021-04-03 2169/week @ 2021-04-10 2160/week @ 2021-04-17 1933/week @ 2021-04-24 2144/week @ 2021-05-01

8,357 downloads per month
Used in 8 crates (5 directly)

MIT license

115KB
3K SLoC

lzma-rs

Crate Documentation Safety Dance Build Status Minimum rust 1.40

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

~125–465KB
~11K SLoC