WindowBits

value class WindowBits

Log2 size of zlib's LZ77 sliding window. Pair with a CompressionAlgorithm to select the format (raw vs zlib vs gzip); this type only carries the size.

Construction is range-checked: only Default (algorithm default) or 9..15 are representable. zlib's deflateInit2 rejects 8 entirely (Z_STREAM_ERROR), so it is excluded here. Negative / offset / out-of-range values are unrepresentable — the platform applies the algorithm-appropriate sign for CompressionAlgorithm.Raw (negate) or CompressionAlgorithm.Gzip (+16) when invoking zlib.

Why a value class instead of Int: the previous windowBits: Int parameter conflated four overlapping namespaces (0 sentinel, positive log size, negated raw form, gzip-offset form) with no compile-time prevention of invalid combinations. Callers that intend a 9-bit raw window passed windowBits = 9 and silently got a zlib-format stream that the raw decompressor couldn't read. Modeling the size separately from the format eliminates that whole class of bug.

Types

Link copied to clipboard
object Companion

Properties

Link copied to clipboard