2 unstable releases
0.2.0 | Dec 28, 2023 |
---|---|
0.1.0 | Dec 27, 2023 |
#460 in Compression
46KB
1K
SLoC
zchunk-rs
A pure rust library for parsing and generating zchunk file
Example
- Compress
use std::fs::File;
use tempfile::Builder;
use zchunk::Encoder;
let input = File::open("test.txt").unwrap();
let output = File::create("test.txt.zck").unwrap();
let temp = Builder::new()
.prefix("zchunk-temp-")
.tempfile_in("tmp/")
.unwrap();
let mut encoder = Encoder::new(input, temp).unwrap();
encoder.prepare_chunks().unwrap();
encoder.compress_to(output).unwrap();
- Decompress
use std::{fs::File, io::BufReader};
use zchunk::Decoder;
let input = File::open("test.txt.zck").unwrap();
let mut output = File::create("test.txt").unwrap();
let mut decoder = Decoder::new(BufReader::new(input)).unwrap();
decoder.decompress_to(&mut output).unwrap();
- Sync
use zchunk::Decoder;
let mut source_decoder = Decoder::new(&mut source_reader).unwrap();
let mut cache_decoder = Decoder::new(&mut cache_reader).unwrap();
source_decoder.sync_to(cache_decoder, &mut writer).unwrap();
Dependencies
~4MB
~80K SLoC