Cargo Features
[dependencies]
flate2 = { version = "1.1.9", default-features = false, features = ["rust_backend", "zlib-rs", "miniz_oxide", "zlib", "zlib-default", "zlib-ng-compat", "zlib-ng", "cloudflare_zlib", "miniz-sys", "any_zlib", "any_c_zlib", "any_impl", "document-features"] }
- default = rust_backend
-
The default backend using pure Rust implementation via miniz_oxide.
This provides a safe, portable compression implementation without requiring a C compiler. - rust_backend default miniz-sys? = any_impl, miniz_oxide
-
User-Facing Backend Features
Choose one of these features to select the compression backend. Only one backend should be enabled at a time, or else one will see an unstable order which is currently
zlib-ng,zlib-rs,cloudflare_zlib,miniz_oxideand which may change at any time.Use the pure Rust
miniz_oxidebackend (default). This implementation uses only safe Rust code and doesn't require a C compiler. It provides good performance for most use cases while being completely portable.Note that this feature at some point may be switched to use
zlib-rsinstead. - zlib-rs = any_zlib
-
Use the zlib-rs backend, a pure Rust rewrite of zlib. This is the fastest backend overall, providing excellent performance with some
unsafecode. It does not require a C compiler but usesunsafeRust for optimization. zlib-rs uses its own crc32 implementation.Enables zlib-rs
this matches the default features, but we don't want to depend on the default features staying the same
- miniz_oxide rust_backend = any_impl
-
Use the pure Rust
miniz_oxidebackend.Enables crc32fast and miniz_oxide ^0.8.5
miniz_oxide:
This implementation uses only safe Rust code and doesn't require a C compiler.
It provides good performance for most use cases while being completely portable. - zlib zlib-ng-compat? = any_c_zlib, libz-sys
-
Use the system's installed zlib library.
This is useful when you need compatibility with other C code that uses zlib,
or when you want to use the system-provided zlib for consistency.Enables crc32fast
- zlib-default = any_c_zlib
-
Use the system's installed zlib library with default features enabled. Similar to
zlibbut enables additional features from libz-sys. - zlib-ng-compat = zlib
-
Use zlib-ng in zlib-compat mode via libz-sys. This provides zlib-ng's performance improvements while maintaining compatibility. Note: If any crate in your dependency graph uses stock zlib, you'll get stock zlib instead. For guaranteed zlib-ng, use the
zlib-ngfeature. When using this feature, if any crate in your dependency graph explicitly requests stock zlib, or uses libz-sys directly withoutdefault-features = false, you'll get stock zlib rather than zlib-ng. See the libz-sys README for details. To avoid that, use the"zlib-ng"feature instead. - zlib-ng = any_c_zlib, libz-ng-sys
-
Use the high-performance zlib-ng library directly.
This typically provides better performance than stock zlib and works even when other dependencies use zlib. Requires a C compiler.Enables crc32fast
- cloudflare_zlib = any_c_zlib, cloudflare-zlib-sys
-
Use Cloudflare's optimized zlib implementation.
This provides better performance than stock zlib on x86-64 (with SSE 4.2) and ARM64 (with NEON & CRC).
* ⚠ Does not support 32-bit CPUs and is incompatible with mingw.
* ⚠ May cause conflicts if other crates use different zlib versions.Enables crc32fast
- miniz-sys = rust_backend
-
Deprecated alias for
rust_backend, provided for backwards compatibility. Userust_backendinstead. - any_zlib any_c_zlib? zlib-rs? = any_impl
-
Internal Features
These features are used internally for backend selection and should not be enabled directly by users. They are documented here to aid with maintenance.
Internal: Marker feature indicating that any zlib-based C backend is enabled. This is automatically enabled by
zlib-rs,zlib,zlib-ng,zlib-ng-compat, andcloudflare_zlib. Do not enable this feature directly; instead, choose a specific backend feature. - any_c_zlib cloudflare_zlib? zlib? zlib-default? zlib-ng? = any_zlib
-
Internal: Marker feature indicating that any C based fully zlib compatible backend is enabled. This is automatically enabled by
zlib,zlib-ng,zlib-ng-compat, andcloudflare_zlib. Do not enable this feature directly; instead, choose a specific backend feature. - any_impl any_zlib? miniz_oxide? rust_backend
-
Internal: Marker feature indicating that any compression backend is enabled. This is automatically enabled by all backend features to ensure at least one implementation is available. Do not enable this feature directly; instead, choose a specific backend feature.
Features from optional dependencies
In crates that don't use the dep: syntax, optional dependencies automatically become Cargo features. These features may have been created by mistake, and this functionality may be removed in the future.
- libz-sys zlib? zlib-default? zlib-ng-compat?
- libz-ng-sys zlib-ng?
- cloudflare-zlib-sys cloudflare_zlib?
- document-features implicit feature
-
Enables document-features
document-features:
Extract documentation for the feature flags from comments in Cargo.toml