Crates.io | lzma-rust2 |
lib.rs | lzma-rust2 |
version | 0.2.1 |
source | src |
created_at | 2025-02-24 08:02:40.95901+00 |
updated_at | 2025-05-01 11:43:16.240117+00 |
description | LZMA/LZMA2 codec ported from 'tukaani xz for java' |
homepage | https://github.com/hasenbanck/sevenz-rust2/tree/main/lzma-rust2 |
repository | https://github.com/hasenbanck/sevenz-rust2/tree/main/lzma-rust2 |
max_upload_size | |
id | 1567179 |
size | 162,507 |
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.
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[..]);
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[..]);