Browse the docs

silk.compress.xz.

Decode XZ containers and verify their blocks, index, and footer.

When to use#

Use Xz.decode for .xz files containing a single LZMA2 filter per block.

Details#

Supports concatenated streams, stream padding, multiple blocks, optional block sizes, and none, CRC-32, CRC-64, or SHA-256 checks. Other filter chains are rejected. The caller supplies output storage; probability tables allocate through the ambient allocator. Index records are checked by scanning the already-validated block framing again, without allocating an index.

Import as Xz with import silk.compress.xz { Xz }.

Public declarations: 1.

Xz#

silk
pub struct Xz

A complete-buffer XZ decoder for blocks with a single LZMA2 filter.

Implementation Xz#

silk
impl Xz

Associated function decode#

silk
pub effect fn decode(input: &[u8], output: &mut [u8], limits: DecodeLimits) -> Decoded
    ! OutOfMemoryError | DecodeError
    ? &mut Allocator

Decodes complete XZ streams into the start of output and verifies container integrity.

Details#

Accepts concatenated streams separated by multiples of four zero padding bytes. Each block must use a single LZMA2 filter. Verifies header, block, index, and footer checksums; optional block sizes; exact index records; and matching stream flags. Supports none, CRC-32, CRC-64, and SHA-256 block checks. Probability tables allocate with the ambient allocator. The output buffer holds dictionary history. Limits apply across all streams in the input.

Errors#

DecodeError reports malformed or truncated data, invalid sizes or distances, checksum mismatches, unsupported filters or checks, and input/output/dictionary/workspace limits. Discard output after failure. OutOfMemoryError reports probability-table allocation failure.

Category: Data formats.

Profiles: aarch64-apple-darwin, aarch64-unknown-linux-gnu, aarch64-unknown-linux-gnu-no-libc, x86_64-unknown-linux-gnu, x86_64-unknown-linux-gnu-no-libc, wasm32-unknown-unknown, wasm32-wasip1, wasm32-wasip2.

View the source of this page