#lzma #codec #xz #java #ported #lzma2

lzma-rust

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

8 releases

0.1.7 Jul 17, 2024
0.1.6 Apr 5, 2024
0.1.5 Sep 29, 2023
0.1.4 Jun 16, 2023
0.1.0 Jan 31, 2023

#180 in Compression

Download history 3126/week @ 2024-07-15 3197/week @ 2024-07-22 2596/week @ 2024-07-29 2777/week @ 2024-08-05 2924/week @ 2024-08-12 2899/week @ 2024-08-19 3657/week @ 2024-08-26 4566/week @ 2024-09-02 3404/week @ 2024-09-09 3563/week @ 2024-09-16 3365/week @ 2024-09-23 3463/week @ 2024-09-30 3271/week @ 2024-10-07 2996/week @ 2024-10-14 3012/week @ 2024-10-21 3081/week @ 2024-10-28

12,815 downloads per month
Used in 27 crates (2 directly)

Apache-2.0

160KB
4.5K SLoC

LZMA/LZMA2 codec ported from tukaani xz for java

Usage

lzma

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

    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_rust::*;

    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

~115KB