lzf-rust 0.1.0

Pure Rust LZF compression/decompression
Documentation
  • Coverage
  • 100%
    44 out of 44 items documented4 out of 6 items with examples
  • Size
  • Source code size: 68.86 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 4.87 MB This is the summed size of all files generated by rustdoc for all configured targets
  • Ø build duration
  • this release: 11s Average build duration of successful builds.
  • all releases: 11s Average build duration of successful builds in releases after 2024-10-23.
  • Links
  • Homepage
  • xorgy/lzf-rust
    0 0 0
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • xorgy

lzf-rust

Pure Rust LZF compression/decompression library.

lzf-rust supports raw LZF token streams, framed ZV block streams, and streaming adapters for both std and no_std + alloc environments.

Features

  • Safe Rust raw LZF encoder/decoder (liblzf compatible token format)
  • ZV block framing support compatible with the lzf utility stream format
  • std::io adapters: LzfReader and LzfWriter for framed streaming I/O
  • crate-level LzfRead/LzfWrite traits for no_std streaming
  • no_std support (with alloc)

Installation

[dependencies]
lzf-rust = "0.1"

no_std usage:

[dependencies]
lzf-rust = { version = "0.1", default-features = false, features = ["encoder"] }

Usage

Raw LZF roundtrip:

use lzf_rust::{compress, decompress, max_compressed_size};

let input = b"hello hello hello hello";
let mut compressed = vec![0u8; max_compressed_size(input.len())];
let n = compress(input, &mut compressed).unwrap();
compressed.truncate(n);

let mut decompressed = vec![0u8; input.len()];
let m = decompress(&compressed, &mut decompressed).unwrap();
assert_eq!(m, input.len());
assert_eq!(&decompressed, input);

Framed block API:

use lzf_rust::{decode_blocks, encode_blocks};

let input = b"hello framed world";
let framed = encode_blocks(input, 32 * 1024).unwrap();
let decoded = decode_blocks(&framed).unwrap();
assert_eq!(decoded, input);

Streaming API:

use lzf_rust::{LzfRead, LzfReader, encode_blocks};

let input = b"streaming example";
let framed = encode_blocks(input, 4096).unwrap();
let mut src: &[u8] = &framed;
let mut reader = LzfReader::new(&mut src);
let mut out = vec![0u8; input.len()];
reader.read_exact(&mut out).unwrap();
assert_eq!(out, input);

License

This crate uses file-level licensing:

  • src/raw/encoder.rs is derived from liblzf encoder logic and is licensed under BSD-2-Clause.
  • The from-scratch Rust implementation files are licensed under ISC.

License texts are provided in:

  • LICENSES/BSD-2-Clause-liblzf.txt
  • LICENSES/ISC.txt