#zlib #deflate #encoding #miniz

miniz_oxide

DEFLATE compression and decompression library rewritten in Rust based on miniz

20 releases

0.4.4 Feb 25, 2021
0.4.3 Oct 7, 2020
0.4.2 Sep 13, 2020
0.4.0 Jun 28, 2020
0.1.1 Oct 28, 2017

#6 in Compression

Download history 199708/week @ 2020-12-19 186534/week @ 2020-12-26 286387/week @ 2021-01-02 303028/week @ 2021-01-09 281547/week @ 2021-01-16 314824/week @ 2021-01-23 321524/week @ 2021-01-30 318294/week @ 2021-02-06 322021/week @ 2021-02-13 339043/week @ 2021-02-20 374171/week @ 2021-02-27 370633/week @ 2021-03-06 379124/week @ 2021-03-13 378063/week @ 2021-03-20 373167/week @ 2021-03-27 308935/week @ 2021-04-03

1,252,693 downloads per month
Used in 2,906 crates (21 directly)

MIT OR Zlib OR Apache-2.0

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