#deflate #zlib #miniz #encoding

miniz_oxide_c_api

DEFLATE compression and decompression API designed to be Rust drop-in replacement for miniz

11 releases

0.3.0 Nov 11, 2021
0.2.5 Mar 1, 2020
0.2.4 Oct 1, 2019
0.2.3 Jul 22, 2019
0.1.1 Oct 28, 2017

#741 in Compression

Download history 1601/week @ 2024-06-17 1595/week @ 2024-06-24 354/week @ 2024-07-01 831/week @ 2024-07-08 2071/week @ 2024-07-15 1677/week @ 2024-07-22 1399/week @ 2024-07-29 1314/week @ 2024-08-05 2213/week @ 2024-08-12 1508/week @ 2024-08-19 1750/week @ 2024-08-26 1741/week @ 2024-09-02 1379/week @ 2024-09-09 1418/week @ 2024-09-16 1780/week @ 2024-09-23 1356/week @ 2024-09-30

6,166 downloads per month

MIT license

615KB
10K SLoC

Rust 5.5K SLoC // 0.1% comments C 4K SLoC // 0.4% comments

Main library Crates.ioDocs

C API Crates.ioDocs

miniz_oxide

Pure rust Rust replacement for the miniz deflate/zlib encoder/decoder using no unsafe code.

This project is organized into a C API shell and a rust crate. The Rust crate is found in the miniz_oxide subdirectory.

miniz_oxide 0.5.x Requires at least rust 1.40.0, 0.3.x requires at least rust 0.36.0.

For a friendlier streaming API using readers and writers, flate2 can be used, which can use miniz_oxide as a rust-only back-end.

miniz_oxide_C_API

The C API is intented to replicate the api exported from miniz, and in turn also part of zlib. The C header is generated using cbindgen. The current implementation has not seen a lot of testing outside of automated test, is a bit weak in ddocumentation and should be seen as experimental.

The data structures do not share the exact same layout that is specified in miniz.h (from the original miniz), and should thus be allocated via the included functions.

API documentation

TODO

Testing

$ cargo test
$ ./test.sh

Benches

$ cargo bench --features=benching

or to compare to miniz

$ ./travis-after-success.sh

Including in C/C++ projects

Link against the libminiz_oxide_c_api.a generated by build.sh. The generated header that can be used miniz.h (using the original miniz headers may or may not work), which currently also uses miniz_extra_defs.h for some static definitions.

Cargo-fuzz testing

Install fuzzer:

$ cargo install cargo-fuzz

Run fuzzer:

$ ./run_fuzz.sh

License

This library (excluding the miniz C code used for tests) is licensed under the MIT license. The library is based on the miniz C library, of which the parts used are dual-licensed under the MIT license and also the unlicense. The parts of miniz that are not covered by the unlicense is some Zip64 code which is only MIT licensed. This and other Zip functionality in miniz is not part of the miniz_oxidde and miniz_oxide_c_api rust libraries.

Dependencies

~86–370KB