dst.lz4DecompressBlock
private fn
size_t lz4DecompressBlock(const(ubyte)[] src, ubyte[] dst)Decompress a single LZ4 block into a caller‑provided buffer.
The function implements the standard LZ4 block format:
- Read a token byte.
- Extract literal length from the high nibble, extending it with
trailing bytes of value 255 as needed.
- Copy that many literal bytes from the input to the output.
- If the input is exhausted, stop (final literals).
- Otherwise, read a 16‑bit little‑endian offset and a match length
from the low nibble of the token (extended by 255‑valued bytes as for literals) plus LZ4_MIN_MATCH.
- Copy
matchLenbytes from the already‑produced output, at distance
offset.
- Repeat from step 1 until the input buffer is exhausted.
The implementation performs strict bounds checks and never writes past dst.length or reads past src.length.
Parameters
src | LZ4 block to decode. |
dst | Destination buffer; must be large enough to hold the decompressed data. |
Returns
Number of bytes written to
Throws
-
CompressionError with ErrorCode.TRUNCATED if the input block
ends prematurely (e.g. while reading literals, offset, or length extensions).
CompressionErrorwithErrorCode.DATA_ERRORif an invalid
offset or other structural inconsistency is encountered.