From 998c1d384dbd75c640a3e918f69a08a8db8603da Mon Sep 17 00:00:00 2001 From: ByteBaker <42913098+ByteBaker@users.noreply.github.com> Date: Mon, 23 Sep 2024 22:28:45 +0530 Subject: [PATCH] docs: correctly mention compression level - mention the difference in compression level range when using `zlib` vs `miniz` backends --- src/lib.rs | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/lib.rs b/src/lib.rs index d286ba2e..239f0ca5 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -192,6 +192,10 @@ impl Compression { /// /// The integer here is typically on a scale of 0-9 where 0 means "no /// compression" and 9 means "take as long as you'd like". + /// + /// It is worth noting that `flate2` supports both `zlib` and `miniz` backends for compression, + /// where `miniz` is enabled by default, and `zlib` can be enabled by the `zlib` feature. + /// The `zlib` backend supports levels 0-9, while the `miniz` backend supports levels 0-10. pub const fn new(level: u32) -> Compression { Compression(level) } @@ -208,12 +212,16 @@ impl Compression { } /// Optimize for the size of data being encoded. + /// + /// The maximum compression is always returned as 9 for consistency + /// with the `zlib` backend, but the `miniz` backend supports a + /// maximum compression level of 10, and is enabled by default. pub const fn best() -> Compression { Compression(9) } /// Returns an integer representing the compression level, typically on a - /// scale of 0-9 + /// scale of 0-9. With `miniz` backend, this can be 0-10. pub fn level(&self) -> u32 { self.0 }