[][src]Crate smaz

This crate implements the smaz algorithm for compressing very short strings.

Smaz instead is not good for compressing general purpose data, but can compress text by 40-50% in the average case (works better with English), and is able to perform a bit of compression for HTML and urls as well. The important point is that Smaz is able to compress even strings of two or three bytes!

See original library by antirez for information on smaz and the algorithm itself.

Quick Start

extern crate smaz;

use smaz::{compress,decompress};

fn main() {
    let s = "my long string";

    let compressed = compress(&s.as_bytes());
    println!("bytes: {:?}", &compressed);

    let decompressed = decompress(&compressed);
    if let Ok(v) = decompressed {
        println!("bytes: {:?}", &v);
    }
}

Compression examples

  • This is a small string compressed by 50%
  • foobar compressed by 34%
  • the end compressed by 58%
  • not-a-g00d-Exampl333 enlarged by 15%
  • Smaz is a simple compression library compressed by 39%
  • Nothing is more difficult, and therefore more precious, than to be able to decide compressed by 49%
  • this is an example of what works very well with smaz compressed by 49%
  • 1000 numbers 2000 will 10 20 30 compress very little compressed by 10%
  • and now a few italian sentences: compressed by 41%
  • Nel mezzo del cammin di nostra vita, mi ritrovai in una selva oscura compressed by 33%
  • Mi illumino di immenso compressed by 37%
  • L'autore di questa libreria vive in Sicilia compressed by 28%
  • try it against urls compressed by 37%
  • http://google.com compressed by 59%
  • http://programming.reddit.com compressed by 52%

Structs

DecompressError

The error type for decompress operation.

Statics

CODEBOOK

Compression codebook, used for compression

Functions

compress

Returns compressed data as a vector of bytes.

decompress

Returns decompressed data as a vector of bytes.

Type Definitions

Result

A specialized Result type for decompress operation.