All Projects → rust-lang → Flate2 Rs

rust-lang / Flate2 Rs

Licence: other
DEFLATE, gzip, and zlib bindings for Rust

Programming Languages

c
50402 projects - #5 most used programming language

Labels

Projects that are alternatives of or similar to Flate2 Rs

Uzlib
Radically unbloated DEFLATE/zlib/gzip compression/decompression library. Can decompress any gzip/zlib data, and offers simplified compressor which produces gzip-compatible output, while requiring much less resources (and providing less compression ratio of course).
Stars: ✭ 168 (-56.92%)
Mutual labels:  zlib, gzip
Libz.jl
Fast, flexible zlib bindings.
Stars: ✭ 26 (-93.33%)
Mutual labels:  gzip, zlib
Datacompression
Swift libcompression wrapper as an extension for the Data type (GZIP, ZLIB, LZFSE, LZMA, LZ4, deflate, RFC-1950, RFC-1951, RFC-1952)
Stars: ✭ 191 (-51.03%)
Mutual labels:  zlib, gzip
Zippy
Pure Nim implementation of deflate, zlib, gzip and zip.
Stars: ✭ 88 (-77.44%)
Mutual labels:  zlib, gzip
zlib
Compression and decompression in the gzip and zlib formats
Stars: ✭ 32 (-91.79%)
Mutual labels:  gzip, zlib
Swcompression
A Swift framework for working with compression, archives and containers.
Stars: ✭ 110 (-71.79%)
Mutual labels:  zlib, gzip
em inflate
Fast, small, in-memory inflate (zlib, deflate and gzip decompression)
Stars: ✭ 59 (-84.87%)
Mutual labels:  gzip, zlib
Turbobench
Compression Benchmark
Stars: ✭ 211 (-45.9%)
Mutual labels:  zlib, gzip
zlib
Pure javascript implementation of Zlib nodejs core module.The zlib module provides compression functionality implemented using Gzip and Deflate/Inflate.
Stars: ✭ 14 (-96.41%)
Mutual labels:  gzip, zlib
power-gzip
POWER9 gzip engine documentation and code samples
Stars: ✭ 16 (-95.9%)
Mutual labels:  gzip, zlib
Denoflate
WebAssembly powered Deflate/Gzip/Zlib compression for Deno, written in Rust
Stars: ✭ 80 (-79.49%)
Mutual labels:  zlib, gzip
python-isal
Faster zlib and gzip compatible compression and decompression by providing python bindings for the isa-l library.
Stars: ✭ 21 (-94.62%)
Mutual labels:  gzip, zlib
Universal Zopfli Js
JavaScript binding to Zopfli with WebAssembly.
Stars: ✭ 70 (-82.05%)
Mutual labels:  zlib, gzip
Libflate
A Rust implementation of DEFLATE algorithm and related formats (ZLIB, GZIP)
Stars: ✭ 125 (-67.95%)
Mutual labels:  zlib, gzip
Tinf
Tiny inflate library (inflate, gzip, zlib)
Stars: ✭ 57 (-85.38%)
Mutual labels:  zlib, gzip
zzlib
zlib-compressed file depacking library in Lua
Stars: ✭ 44 (-88.72%)
Mutual labels:  gzip, zlib
deflate-rs
An implementation of a DEFLATE encoder in rust
Stars: ✭ 47 (-87.95%)
Mutual labels:  gzip, zlib
Gzipswift
Swift framework that enables gzip/gunzip Data using zlib
Stars: ✭ 356 (-8.72%)
Mutual labels:  zlib, gzip
pugz
Truly parallel gzip decompression
Stars: ✭ 96 (-75.38%)
Mutual labels:  gzip
Archiver
Easily create & extract archives, and compress & decompress files of various formats
Stars: ✭ 3,373 (+764.87%)
Mutual labels:  gzip

flate2

Crates.io Documentation

A streaming compression/decompression library DEFLATE-based streams in Rust.

This crate by default uses the miniz_oxide crate, a port of miniz.c to pure Rust. This crate also supports other backends, such as the widely available zlib library or the high-performance zlib-ng library.

Supported formats:

  • deflate
  • zlib
  • gzip
# Cargo.toml
[dependencies]
flate2 = "1.0"

Compression

use std::io::prelude::*;
use flate2::Compression;
use flate2::write::ZlibEncoder;

fn main() {
    let mut e = ZlibEncoder::new(Vec::new(), Compression::default());
    e.write_all(b"foo");
    e.write_all(b"bar");
    let compressed_bytes = e.finish();
}

Decompression

use std::io::prelude::*;
use flate2::read::GzDecoder;

fn main() {
    let mut d = GzDecoder::new("...".as_bytes());
    let mut s = String::new();
    d.read_to_string(&mut s).unwrap();
    println!("{}", s);
}

Backends

The default miniz_oxide backend has the advantage of being pure Rust, but if you're already using zlib with another C library, for example, you can use that for Rust code as well:

[dependencies]
flate2 = { version = "1.0.17", features = ["zlib"], default-features = false }

This supports either the high-performance zlib-ng backend (in zlib-compat mode) or the use of a shared system zlib library. To explicitly opt into the fast zlib-ng backend, use:

[dependencies]
flate2 = { version = "1.0.17", features = ["zlib-ng-compat"], default-features = false }

Note that if any crate in your dependency graph explicitly requests stock zlib, or uses libz-sys directly without default-features = false, you'll get stock zlib rather than zlib-ng. See the libz-sys README for details.

For compatibility with previous versions of flate2, the cloudflare optimized version of zlib is available, via the cloudflare_zlib feature. It's not as fast as zlib-ng, but it's faster than stock zlib. It requires a x86-64 CPU with SSE 4.2 or ARM64 with NEON & CRC. It does not support 32-bit CPUs at all and is incompatible with mingw. For more information check the crate documentation. Note that cloudflare_zlib will cause breakage if any other crate in your crate graph uses another version of zlib/libz.

For compatibility with previous versions of flate2, the C version of miniz.c is still available, using the feature miniz-sys.

License

This project is licensed under either of

at your option.

Contribution

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in this project by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].