ddn.compressor.lzma
ddn.compressor.lzma
LZMA/XZ compression/decompression provider built on ddn-lib-lzma.
This module implements the streaming Compressor and Decompressor interfaces from ddn.api.compressor and registers itself under:
- Enum registry:
CompressionFormat.XZ - String registry: formatId "xz" with provider name "lib-xz"
The implementation uses liblzma's streaming API (lzma_easy_encoder / lzma_stream_decoder / lzma_code) for true incremental compression and decompression. The produced .xz streams are fully interoperable with the system xz command-line tool.
Provider name convention: vendor "lib", toString() returns "lib-xz".
Copyright
Module Initializers 1
()Types 2
LZMA/XZ compressor that implements ddn.api.compressor.Compressor using liblzma's streaming API (lzma_easy_encoder + lzma_code).
private CompressionOptions _optsprivate OutputSink _sinkprivate bool _finishedprivate lzma_stream _strmprivate ubyte[] _outBufprivate ulong _bytesInprivate ulong _bytesOutprivate lzma_ret _lastCodevoid setOutputSink(OutputSink sink)Set the output sink delegate.void setProgressCallback(ProgressCallback callback)Set the progress callback.void write(const(ubyte)[] data)Feed uncompressed data into the stream.void finish()Finalize the stream.void reset()Reset the compression context for reuse.void applyEncoder()Apply all stored compression parameters by (re-)initialising the encoder.size_t drainEncoder(lzma_action action)Run `lzma_code` with the given action and copy produced bytes to `outBuf`.bool setDictionary(const(ubyte)[] dict)Set a compression dictionary.this(CompressionOptions opts)Create a compressor with provided options.LZMA/XZ decompressor that implements ddn.api.compressor.Decompressor using liblzma's streaming API (lzma_stream_decoder + lzma_code).
Supports concatenated .xz streams: when input contains multiple streams concatenated together, all streams are decompressed in sequence. Trailing bytes that do not form a valid .xz stream are rejected with a CompressionError.
private DecompressionOptions _optsprivate OutputSink _sinkprivate bool _finishedprivate lzma_stream _strmprivate ubyte[] _outBufprivate ulong _bytesInprivate ulong _bytesOutprivate bool _streamEndSeenvoid setOutputSink(OutputSink sink)Set the output sink delegate.void setProgressCallback(ProgressCallback callback)Set the progress callback.void write(const(ubyte)[] data)Feed compressed data into the stream.void finish()Finalize the stream.void reset()Reset the decompression context for reuse.void applyDecoder()Apply all stored decompression parameters by (re-)initialising the decoder.bool setDictionary(const(ubyte)[] dict)Provide a dictionary if required.this(DecompressionOptions opts)Create a decompressor with provided options.Functions 6
int toLzmaLevel(CompressionOptions opts)Map `CompressionLevel` / `numericLevel` to an LZMA preset (0..9).ErrorCode classifyLzmaError(lzma_ret rc)Map an `lzma_ret` to the most appropriate `ErrorCode`.void throwLzmaError(lzma_ret rc, string context)Throw a `CompressionError` classified from an `lzma_ret` return code.Compressor makeLzmaCompressor(CompressionOptions opts)Factory function that constructs a `LzmaCompressor`.Decompressor makeLzmaDecompressor(DecompressionOptions opts)Factory function that constructs a `LzmaDecompressor`.