patina_lzma_rs

Crates.iopatina_lzma_rs
lib.rspatina_lzma_rs
version0.3.2
created_at2025-10-12 02:03:21.721151+00
updated_at2025-10-12 02:03:21.721151+00
descriptionA codec for LZMA, LZMA2 and XZ written in pure Rust
homepage
repositoryhttps://github.com/OpenDevicePartnership/patina-lzma-rs
max_upload_size
id1878742
size159,623
(patina-fw)

documentation

README

patina_lzma_rs

Minimum Rust 1.78 Safety Dance Build Status

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

Commit count: 0

cargo fmt