Skip to content

A pure rust library for parsing and generating zchunk file

License

Notifications You must be signed in to change notification settings

yybit/zchunk-rs

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

crates.io docs.rs

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();

About

A pure rust library for parsing and generating zchunk file

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages