ddn.compressor.zstd

ddn.compressor.zstd

Zstandard (ZSTD) compression/decompression provider built on ddn-lib-zstd.

This module implements the streaming Compressor and Decompressor interfaces from ddn.api.compressor and registers itself under:

  • Enum registry: CompressionFormat.ZSTD
  • String registry: formatId "zstd" with provider name "lib-zstd"

The implementation uses libzstd's streaming API (ZSTD_compressStream2 / ZSTD_decompressStream) for true incremental compression and decompression.

Provider name convention: vendor "lib", toString() returns "lib-zstd".

Module Initializers 1

shared static this()

Types 2

ZSTD compressor that implements ddn.api.compressor.Compressor using libzstd's streaming API (ZSTD_compressStream2).

Methods
CompressionOptions options() @property constReturn the options used to create this compressor.
void setOutputSink(OutputSink sink)Set the output sink delegate.
void setProgressCallback(ProgressCallback callback)Set the progress callback.
ulong bytesInTotal() @property constTotal uncompressed bytes consumed.
ulong bytesOutTotal() @property constTotal compressed bytes produced.
void write(const(ubyte)[] data)Feed uncompressed data into the stream.
void flush(FlushMode mode = FlushMode.SYNC)Flush pending output.
void finish()Finalize the stream.
void reset()Reset the compression context for reuse.
bool setDictionary(const(ubyte)[] dict)Set a compression dictionary.
bool isFinished() @property constReturns true if finish() has been called.
Constructors
this(CompressionOptions opts)Create a compressor with provided options.
Destructors
~thisRelease the ZSTD context.

ZSTD decompressor that implements ddn.api.compressor.Decompressor using libzstd's streaming API (ZSTD_decompressStream).

Supports concatenated zstd frames: when input contains multiple frames concatenated together, all frames are decompressed in sequence. Trailing bytes that do not form a valid zstd frame are rejected with a CompressionError.

Methods
DecompressionOptions options() @property constReturn the options used to create this decompressor.
void setOutputSink(OutputSink sink)Set the output sink delegate.
void setProgressCallback(ProgressCallback callback)Set the progress callback.
ulong bytesInTotal() @property constTotal compressed bytes consumed.
ulong bytesOutTotal() @property constTotal decompressed bytes produced.
void write(const(ubyte)[] data)Feed compressed data into the stream.
void finish()Finalize the stream.
void reset()Reset the decompression context for reuse.
bool setDictionary(const(ubyte)[] dict)Provide a dictionary if required.
bool isFinished() @property constReturns true if finish() has been called.
Constructors
this(DecompressionOptions opts)Create a decompressor with provided options.
Destructors
~thisRelease the ZSTD context.

Functions 2

fnCompressor makeZstdCompressor(CompressionOptions opts)Factory function that constructs a `ZstdCompressor`.
fnDecompressor makeZstdDecompressor(DecompressionOptions opts)Factory function that constructs a `ZstdDecompressor`.