GitHunt
TC

TCA166/generic_compression

A simple library providing generic implementations of common compression algorithms

generic_compression

Rust
Crates.io Version
docs.rs
License

A simple Rust library and repository providing generic implementation of
compression algorithms. Instead of providing end-to-end compression for byte
arrays, this library provides a set of generic algorithms, that encode and
decode data into logical representations of compressed data. So for example, for
the lz77 algorithm, if you provide a byte array, instead of outputting a
compressed byte array, this library outputs a vector of triples.

This means, that this library will not be ideal for the most common use cases,
however, if you wish to roll your own compression algorithm, out of prebuilt
algorithms this library is perfect for you. It is also a good way to learn
about compression algorithms, as the code is simple and easy to read.

Library Features

  • lz77: An implementation of the
    LZ77 compression
    algorithm.
  • lz78: An implementation of the
    LZ78 compression
    algorithm.
  • lzw: An implementation of the
    LZW compression algorithm.
  • MTF: An implementation of the
    Move-to-Front
    transform.
  • BWT: An implementation of the
    Burrows-Wheeler Transform
    transform.
  • Huffman Encoding: An implementation of the
    Huffman coding algorithm.
  • Arithmetic Encoding: An implementation of the
    Arithmetic coding
    algorithm.
  • Serde support: The intermediate compressed data structures are serializable
    and deserializable using the serde library using the serde feature.

Command Line Utility

This package also provides a command line utility that utilizes the library
to provide a simple interface for compressing and decompressing files using the
lz77, lz78 and lzw algorithms. The command line utility is not the main
feature of this package, but it is a nice addition for testing and playing
around with how parameters affect the compression ratio and speed of the
algorithms.

Languages

Rust100.0%

Contributors

GNU General Public License v3.0
Created April 19, 2025
Updated March 3, 2026
TCA166/generic_compression | GitHunt