rust-lang / flate2-rs

DEFLATE, gzip, and zlib bindings for Rust
https://docs.rs/flate2
Apache License 2.0
895 stars 161 forks source link

Integrate with Zopfli #349

Open Pr0methean opened 1 year ago

Pr0methean commented 1 year ago

Zopfli, Google's implementation of a slow high-compression-ratio Deflate encoder, has a Rust port. (The interface is to call https://docs.rs/zopfli/latest/zopfli/fn.compress.html# with https://docs.rs/zopfli/latest/zopfli/enum.Format.html#variant.Deflate. The guts of the implementation are at https://docs.rs/zopfli/latest/src/zopfli/deflate.rs.html.)

It would be nice if we could enable Zopfli as another implementation option in flate2. I'd compile it by default in https://crates.io/crates/zip_next, but only use it when the specified Compression Level was 10 or more, unless it was the only enabled Deflate implementation.

joshtriplett commented 1 year ago

Normally, flate2 only supports a single backend. Supporting multiple backends would be a substantial change to the crate, and most crates wouldn't want a version of flate2 that only used zopfli.

I don't think this is something we should necessarily add as long as flate2 only supports a single backend. And I'm not sure multi-backend support makes sense other than for zopfli. Given that the zopfli crate's interface seems quite easy to use, I think it might make more sense for crates that want to support both zopfli and another backend to use the zopfli crate directly and use flate2 for the non-zopfli support.