zeekstd 0.1.0

Rust implementation of the Zstandard Seekable Format.
Documentation

Zeekstd

Rust implementation of the Zstandard Seekable Format.

The seekable format splits compressed data into a series of independent "frames", each compressed individually, so that decompression of a section in the middle of an archive only requires zstd to decompress at most a frame's worth of extra data, instead of the entire archive.

Compression

Use the Compressor struct for streaming data compression.

use std::{fs::File, io};
use zeekstd::Compressor;

fn main() -> zeekstd::Result<()> {
    let mut input = File::open("foo")?;
    let output = File::create("foo.zst")?;
    let mut compressor = Compressor::new(output)?;
    io::copy(&mut input, &mut compressor)?;
    // End compression and write the seek table
    compressor.finish()?;

    Ok(())
}

Decompression

Streaming decompression can be achieved using the Decompressor struct.

use std::{fs::File, io::{self, BufReader}};
use zeekstd::Decompressor;

fn main() -> zeekstd::Result<()> {
    let input = File::open("seekable.zst")?;
    let mut output = File::create("data")?;
    let mut decompressor = Decompressor::new(BufReader::new(input))?;
    io::copy(&mut decompressor, &mut output)?;

    Ok(())
}

CLI

This repo also contains a CLI tool for the seekable format that is packaged in nixpkgs.

nix-shell -p zeekstd
zeekstd --help

License

  • The zstd C library is under a dual BSD/GPLv2 license.
  • Zeekstd is under a BSD 2-Clause License.