ddn.compressor.deflate
ddn.compressor.deflate
Provider for DEFLATE with zlib wrapper format (RFC 1950) for ddn.api.compressor. Uses the pure D zlib implementation from ddn.compressor.zlib. Registers as provider "ddn" for format "deflate_zlib".
This implements the most common DEFLATE format used in PNG, ZIP, HTTP, etc. The zlib wrapper adds a 2-byte header and 4-byte Adler-32 checksum.
- Supports both streaming and block compression.
- Fully DDoc-documented.
- All public functions and types have unittests.
Copyright
BSD-3-Clause
Module Initializers 1
shared static this
()Types 2
DEFLATE compressor using std.zlib/core.c.zlib.
Fields
private CompressionOptions _optsprivate OutputSink _sinkprivate bool _finishedprivate z_stream _zsprivate bool _dictSetprivate ulong _bytesInprivate ulong _bytesOutprivate int _windowBitsMethods
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 -> ZSYNCFLUSH - full -> ZFULLFLUSHvoid 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. Returns: true if accepted, false if not supported.bool isFinished() @property constReturns true if finish() has been called and the stream is closed for further writes.Constructors
this(CompressionOptions opts)Create a compressor with provided options.Destructors
~thisEnsure zlib stream is ended.DEFLATE decompressor using std.zlib/core.c.zlib.
Fields
private DecompressionOptions _optsprivate OutputSink _sinkprivate bool _finishedprivate z_stream _zsprivate bool _dictSetprivate ulong _bytesInprivate ulong _bytesOutprivate int _windowBitsMethods
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. Throws if finish() was already called or output sink is not set.void finish()Signal end-of-input; allows the decompressor to validate checksums and emit any trailing bytes.void reset()Reset the decompression stream to initial state (options retained).bool setDictionary(const(ubyte)[] dict)Set dictionary if supported. Returns: true if accepted, false if not supported.bool isFinished() @property constReturns true if finish() has been called and the stream is closed for further writes.Constructors
this(DecompressionOptions opts)Create a decompressor with provided options.Destructors
Functions 5
fn
Compressor makeDeflateStdZlibCompressor(CompressionOptions opts)Factory function that constructs a `DeflateStdZlibCompressor`.fn
Decompressor makeDeflateStdZlibDecompressor(DecompressionOptions opts)Factory function that constructs a `DeflateStdZlibDecompressor`.