#lzma #java #write

lzma-rust2

LZMA/LZMA2 codec ported from 'tukaani xz for java'

4 releases

new 0.2.1 May 1, 2025
0.2.0 Mar 31, 2025
0.1.8 Feb 25, 2025
0.1.7 Feb 24, 2025

#501 in Compression

Download history 279/week @ 2025-02-21 195/week @ 2025-02-28 170/week @ 2025-03-07 88/week @ 2025-03-14 116/week @ 2025-03-21 166/week @ 2025-03-28 306/week @ 2025-04-04 429/week @ 2025-04-11 926/week @ 2025-04-18 655/week @ 2025-04-25

2,333 downloads per month
Used in 3 crates (via sevenz-rust2)

Apache-2.0

165KB
4K SLoC

Crate Documentation

LZMA/LZMA2 codec ported from tukaani xz for java.

This is a fork of the original, unmaintained lzma-rust crate to continue the development and maintenance.

Usage

lzma

use std::io::{Read, Write};
use lzma_rust2::*;

let s = b"Hello, world!";
let mut out = Vec::new();
let mut options = LZMA2Options::with_preset(6);
options.dict_size = LZMA2Options::DICT_SIZE_DEFAULT;

let mut w = LZMAWriter::new_use_header(CountingWriter::new( & mut out), & options, None).unwrap();
w.write_all(s).unwrap();
w.write( & []).unwrap();
let mut r = LZMAReader::new_mem_limit( & out[..], u32::MAX, None).unwrap();
let mut s2 = vec![0; s.len()];
r.read_exact( & mut s2).unwrap();
println!("{:?}", &out[..]);
assert_eq!(s, &s2[..]);

lzma2

use std::io::{Read, Write};
use lzma_rust2::*;

let s = b"Hello, world!";
let mut out = Vec::new();
let mut options = LZMA2Options::with_preset(6);
options.dict_size = LZMA2Options::DICT_SIZE_DEFAULT;
{
let mut w = LZMA2Writer::new(CountingWriter::new( & mut out), & options);
w.write_all(s).unwrap();
w.write( & []).unwrap();
}
let mut r = LZMA2Reader::new( & out[..], options.dict_size, None);
let mut s2 = vec![0; s.len()];
r.read_exact( & mut s2).unwrap();
println!("{:?}", &out[..]);
assert_eq!(s, &s2[..]);

Dependencies

~125KB