#deprecated #data #original #lib-lzf

deprecated lzf

DEPRECATED! An implementation of LZF, a very small data compression algorithm

12 releases (1 stable)

1.0.0 Nov 6, 2022
0.3.2 Nov 6, 2022
0.3.1 Sep 27, 2015
0.2.3 Apr 3, 2015
0.1.0 Nov 22, 2014

#97 in #original

Download history 408/week @ 2023-12-12 430/week @ 2023-12-19 182/week @ 2023-12-26 222/week @ 2024-01-02 242/week @ 2024-01-09 295/week @ 2024-01-16 194/week @ 2024-01-23 303/week @ 2024-01-30 68/week @ 2024-02-06 95/week @ 2024-02-13 228/week @ 2024-02-20 208/week @ 2024-02-27 124/week @ 2024-03-05 163/week @ 2024-03-12 187/week @ 2024-03-19 135/week @ 2024-03-26

632 downloads per month
Used in 11 crates (8 directly)

BSD-3-Clause

23KB
425 lines

LZF - a very small data compression library


DEPRECATED


LibLZF is a super small and fast compression library, originally written by Marc Lehmann. It's written in C and consists of only 4 files. And this is the rewrite in Rust.

Instead of rewriting the whole thing in Rust, I used Rust's Foreign Function Interface and wrote a wrapper. The whole Rust code is under 50 lines (yes, there is more test code than actual implementation code). And it is super easy to use, though I'm not happy with the current interface.

I sat down and tried to understand the original C code and then rewrote it in (mostly) safe Rust code. And the best thing: it's still super fast (on some basic benchmarks it's nearly as fast as the original code). It now consists of roughly 200 lines of code, which is probably around the same as the original implementation.

Build

cargo build --release

Usage

fn main() {
  let data = "foobar";

  let compressed = lzf::compress(data.as_bytes()).unwrap();

  let decompressed = lzf::decompress(&compressed, data.len()).unwrap();
}

Tests

Run tests with:

cargo test

Run benchmarks with:

cargo bench

Contribute

If you find bugs or want to help otherwise, please open an issue.
This is my first released library in Rust and I'm still learning. So if there are better ways to do things in Rust, I'm happy to hear about it.

License

BSD. See LICENSE.
liblzf is BSD as well. See lzf.h.

No runtime deps