ddn.compressor.gzip
ddn.compressor.gzip
Rock-solid GZIP compression/decompression provider built on ddn.compressor.zlib (pure D implementation)
This module implements the streaming Compressor and Decompressor interfaces from ddn.api.compressor and registers itself under:
- Enum registry:
CompressionFormat.gzip - String registry: formatId "gzip" with provider name "ddn"
The implementation uses zlib's deflate/inflate with appropriate window bits to produce/consume GZIP containers. No external packages are required.
CompressionProvider name convention: "ddn" (short name, toString() returns "ddn-gzip").
Copyright
Module Initializers 1
()Types 2
GZIP compressor that implements ddn.api.compressor.Compressor using zlib's deflate with GZIP container (via deflateInit2 and windowBits = 16 + window size).
void setOutputSink(OutputSink sink)Set the output sink delegate that will receive produced compressed chunks.void setProgressCallback(ProgressCallback callback)Set an optional progress callback.void write(const(ubyte)[] data)Feed more uncompressed data. Throws if finish() was already called or output sink is not set.void flush(FlushMode mode = FlushMode.SYNC)Flush pending output according to the provided `FlushMode`. - sync -> Z_SYNC_FLUSH - full -> Z_FULL_FLUSHvoid finish()Finalize the stream and emit trailer. No further writes are allowed afterwards.void reset()Reset the compression stream to initial state (options retained).bool setDictionary(const(ubyte)[] dict)Set dictionary if supported. For gzip container this usually returns false.bool isFinished() @property constReturns true if finish() has been called and the stream is closed for further writes.this(CompressionOptions opts)Create a compressor with provided options.~thisEnsure zlib stream is ended.GZIP decompressor that implements ddn.api.compressor.Decompressor using zlib's inflate with auto header detection (windowBits = 15 + 32).
A multi-member stream decodes fully: after one member's end the next one's header is read where it starts (a concatenated cat a.gz b.gz). Trailing all-zero padding after the last member is tolerated (Python's rule); any other trailing byte, or a nonzero byte inside the padding, is DATA_ERROR.
void setOutputSink(OutputSink sink)Set the output sink delegate that will receive produced decompressed chunks.void setProgressCallback(ProgressCallback callback)Set an optional progress callback.void write(const(ubyte)[] data)Feed more compressed data into the stream.void finish()Finish the stream; validates that end-of-stream was reached, otherwise throws `truncated`.void reset()Reset the decompression stream to initial state.bool setDictionary(const(ubyte)[] dict)Provide a dictionary if requested by the compressed stream.bool isFinished() @property constReturns true if finish() has been called and the stream is closed for further writes.this(DecompressionOptions opts)Create a decompressor with provided options.~thisEnsure zlib stream is ended.Functions 2
Compressor makeGzipCompressor(CompressionOptions opts)Factory function that constructs a `GzipCompressor`.Decompressor makeGzipDecompressor(DecompressionOptions opts)Factory function that constructs a `GzipDecompressor`.