lzma-rust

Crates.iolzma-rust
lib.rslzma-rust
version0.1.7
sourcesrc
created_at2023-01-31 09:32:09.490128
updated_at2024-07-17 13:36:11.093991
descriptionLZMA/LZMA2 codec ported from 'tukaani xz for java'
homepagehttps://github.com/dyz1990/sevenz-rust/tree/main/lzma-rust
repositoryhttps://github.com/dyz1990/sevenz-rust/tree/main/lzma-rust
max_upload_size
id772551
size160,334
(dyz1990)

documentation

README

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[..]);

Commit count: 140

cargo fmt