Crates.io | deflate |
lib.rs | deflate |
version | 1.0.0 |
source | src |
created_at | 2016-09-19 09:22:29.510935 |
updated_at | 2021-11-10 17:02:27.957683 |
description | A DEFLATE, zlib and gzip encoder written in Rust. |
homepage | https://github.com/image-rs/deflate-rs |
repository | https://github.com/image-rs/deflate-rs |
max_upload_size | |
id | 6543 |
size | 255,308 |
An implementation of a DEFLATE encoder in pure Rust. Not a direct port, but does take some inspiration from zlib, miniz and zopfli. The API is based on the one in the flate2 crate that contains bindings, zlib miniz_oxide, and miniz.
Deflate encoding with and without zlib and gzip metadata (zlib dictionaries are not supported) is supported. No unsafe code is used.
Encoding in gzip format requires enabling the 'gzip' feature.
This library is now mostly in maintenance mode, focus being on the Rust backend of flate2 instead.
The minimum required Rust version is 1.32.0 due to use of library functions for endinaness conversion (unit tests requires a newer version).
use deflate::deflate_bytes;
let data = b"Some data";
let compressed = deflate_bytes(&data);
use std::io::Write;
use deflate::Compression;
use deflate::write::ZlibEncoder;
let data = b"This is some test data";
let mut encoder = ZlibEncoder::new(Vec::new(), Compression::Default);
encoder.write_all(data).unwrap();
let compressed_data = encoder.finish().unwrap();
deflate is distributed under the terms of both the MIT and Apache 2.0 licences.
bitstream.rs is © @nwin and was released under both MIT and Apache 2.0
Some code in length_encode.rs has been ported from the miniz
library, which is public domain.
The test data (tests/pg11.txt) is borrowed from Project Gutenberg and is available under public domain, or the Project Gutenberg Licence