#zlib #deflate #encoding #miniz

miniz_oxide

DEFLATE compression and decompression library rewritten in Rust based on miniz

18 releases

0.4.2 Sep 13, 2020
0.4.0 Jun 28, 2020
0.3.6 Feb 3, 2020
0.3.5 Oct 27, 2019
0.1.1 Oct 28, 2017

#4 in Compression

Download history 144727/week @ 2020-06-09 184738/week @ 2020-06-16 185956/week @ 2020-06-23 223853/week @ 2020-06-30 218896/week @ 2020-07-07 184387/week @ 2020-07-14 205242/week @ 2020-07-21 221483/week @ 2020-07-28 213335/week @ 2020-08-04 216413/week @ 2020-08-11 223495/week @ 2020-08-18 236223/week @ 2020-08-25 224698/week @ 2020-09-01 245416/week @ 2020-09-08 242705/week @ 2020-09-15 222873/week @ 2020-09-22

941,984 downloads per month
Used in 2,199 crates (18 directly)

MIT license

200KB
4K SLoC

miniz_oxide

A pure rust replacement for the miniz DEFLATE/zlib encoder/decoder. The main intention of this crate is to be used as a back-end for the flate2, but it can also be used on it's own. Using flate2 with the rust_backend feature provides an easy to use streaming API for miniz_oxide.

Requires at least rust 1.34.

Usage

Simple compression/decompression:


extern crate miniz_oxide;

use miniz_oxide::inflate::decompress_to_vec;
use miniz_oxide::deflate::compress_to_vec;

fn roundtrip(data: &[u8]) {
    let compressed = compress_to_vec(data, 6);
    let decompressed = decompress_to_vec(decompressed.as_slice()).expect("Failed to decompress!");
}


lib.rs:

A pure rust replacement for the miniz DEFLATE/zlib encoder/decoder. The plan for this crate is to be used as a back-end for the flate2 crate and eventually remove the need to depend on a C library.

Usage

Simple compression/decompression:


use miniz_oxide::inflate::decompress_to_vec;
use miniz_oxide::deflate::compress_to_vec;

fn roundtrip(data: &[u8]) {
    let compressed = compress_to_vec(data, 6);
    let decompressed = decompress_to_vec(compressed.as_slice()).expect("Failed to decompress!");
#   let _ = decompressed;
}

# roundtrip(b"Test_data test data lalalal blabla");

Dependencies

~180KB