lz4CompressBlockWithDict

private fnubyte[] lz4CompressBlockWithDict(const(ubyte)[] src, int level, const(ubyte)[] dict)

Compress a single block of data using the LZ4 block format with dictionary.

This is the dictionary-aware version of lz4CompressBlock. When a dictionary is provided, it enables matches to reference data in the dictionary, improving compression for data similar to the dictionary.

The compression level controls both the hash table size and the matching strategy:

  • Level 0: Store-only mode. Returns null to signal uncompressed block.
  • Levels 1-6: Greedy matching with dictionary support.
  • Levels 7-9: HC (lazy) matching with dictionary support.

Parameters

srcInput bytes to compress.
levelCompression level (0-9). Default is 1 for fast compression.
dictOptional dictionary data (may be null or empty).

Returns

Newly allocated array containing the LZ4-compressed block,

or null if level is 0 (store-only mode).

Throws

CompressionError with ErrorCode.INVALID_INPUT if

src.length exceeds LZ4_MAX_INPUT_SIZE.