use miniz_oxide::deflate::compress_to_vec;
use miniz_oxide::inflate::decompress_to_vec;
fn roundtrip(data: &[u8]) {
// Compress the input
let compressed = compress_to_vec(data, 6);
// Decompress the compressed input
let decompressed = decompress_to_vec(compressed.as_slice()).expect("Failed to decompress!");
// Check roundtrip succeeded
assert_eq!(data, decompressed);
}
fn main() {
roundtrip("Hello, world!".as_bytes());
}
These simple functions will do everything in one go and are thus not recommended for use cases where the input size may be large or unknown, for that use case consider using miniz_oxide via flate2 or the low-level streaming functions instead.