1 unstable release
| 0.3.2 | Oct 12, 2025 |
|---|
#545 in Compression
1,887 downloads per month
Used in patina_ffs_extractors
155KB
4K
SLoC
patina_lzma_rs
Origin
This repo is forked off of Guillaume Endignoux's lzma-rs with the intent of providing no_std compatibility while maintaining all existing functionality. This crate should be considered temporary in that, should no_std compatibility be added to the upstream, this crate will no longer have a reason to exist.
Description
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();
patina_lzma_rs::xz_decompress(&mut f, &mut decomp).unwrap();
// Decompressed content is now in "decomp"
Compress a slice into a vector in a no_std environment.
#![no_std]
extern crate alloc;
use alloc::vec::Vec;
let data: &[u8] = gather_my_data();
let compressed_data: Vec<u8> = Vec::new();
patina_lzma_rs::lzma_compress(&mut lzma_compress::io::Cursor::new(data), compressed_data).unwrap();
// Compressed 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
~175–265KB