Expand description
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 stringcompressed by 50%foobarcompressed by 34%the endcompressed by 58%not-a-g00d-Exampl333enlarged by 15%Smaz is a simple compression librarycompressed by 39%Nothing is more difficult, and therefore more precious, than to be able to decidecompressed by 49%this is an example of what works very well with smazcompressed by 49%1000 numbers 2000 will 10 20 30 compress very littlecompressed by 10%and now a few italian sentences:compressed by 41%Nel mezzo del cammin di nostra vita, mi ritrovai in una selva oscuracompressed by 33%Mi illumino di immensocompressed by 37%L'autore di questa libreria vive in Siciliacompressed by 28%try it against urlscompressed by 37%http://google.comcompressed by 59%http://programming.reddit.comcompressed by 52%
Structs§
- Decompress
Error - 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 Aliases§
- Result
- A specialized Result type for decompress operation.