lzrw 0.1.0

Rust bindings for the LZRW family of lossless data-compression algorithms
docs.rs failed to build lzrw-0.1.0
Please check the build logs for more information.
See Builds for ideas on how to fix a failed build, or Metadata for how to configure docs.rs builds.
If you believe this is docs.rs' fault, open an issue.

lzrw

Crates.io License

Rust bindings for the LZRW family of lossless data-compression algorithms.

Originally written in C by Ross Williams in the early 1990s, the algorithms were designed to prioritize speed over compression ratio. This crate vendors the original C source and exposes all six original algorithms through a safe Rust API.

Supported Algorithms

Algorithm Description
LZRW1 Simplest variant, fast and minimal memory usage
LZRW1-A Optimized version of LZRW1
LZRW2 Adds adaptive encoding for improved ratios
LZRW3 Uses a hash table for faster matching
LZRW3-A Optimized version of LZRW3, best compression ratio of the family
LZRW5 LZW-based (dictionary, not sliding window), different than all other variants

Workspace Structure

  • lzrw - the public crate meant to provide a safe Rust API for the LZRW algorithms.
  • lzrw-sys - internal -sys crate. Compiles the vendored C code with cc.

Usage

Add the crate to your project:

[dependencies]
lzrw = "0.1.0"

Compress & Decompress

use lzrw::{self, LzrwAlgorithm};

fn main() {
    let input = b"Hello world! Hello world! Hello world!";

    // compress
    let compressed = lzrw::compress(
        LzrwAlgorithm::Lzrw3a,
        input,
    );

    println!("compressed {} -> {} bytes", input.len(), compressed.len());

    // decompress
    let decompressed = lzrw::decompress(
        LzrwAlgorithm::Lzrw3a,
        &compressed,
    );

    assert_eq!(&decompressed, input);
}

Choosing an Algorithm

All six variants share the same API, just swap the LzrwAlgorithm enum value:

LzrwAlgorithm::Lzrw1
LzrwAlgorithm::Lzrw1a
LzrwAlgorithm::Lzrw2
LzrwAlgorithm::Lzrw3
LzrwAlgorithm::Lzrw3a
LzrwAlgorithm::Lzrw5

Authors

This crate was developed and is maintained by Brandon "SaturnKai" Gardenhire.

The original LZRW source was released by Ross Williams into the public domain. The source has been slightly modified to be compiled on modern platforms, available in the lzrw-sys/lzrw/ directory.

License

MIT License, see LICENSE for more details.