Browse the docs

silk.compress.lzma2.

Decode complete raw LZMA2 streams into caller-owned byte buffers.

When to use#

Use Lzma2.decode when a surrounding protocol supplies the dictionary size. For .xz files, use silk.compress.xz.Xz, which reads the dictionary size and verifies the container.

Details#

Supports stored and range-coded chunks, dictionary resets, property changes, and state reuse. Input must contain exactly one stream including its zero end byte. Raw LZMA2 has no checksum. The output buffer holds dictionary history. Probability tables use the ambient allocator.

Import as Lzma2 with import silk.compress.lzma2 { Lzma2 }.

Public declarations: 1.

Lzma2#

silk
pub struct Lzma2

A complete-buffer raw LZMA2 decoder with caller-selected dictionary and resource limits.

Implementation Lzma2#

silk
impl Lzma2

Associated function decode#

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

Decodes one raw LZMA2 stream into the start of output, with the supplied dictionary size.

Details#

dictionaryBytes must be between 4096 and 4294967295. The output buffer holds history; only probability tables allocate. Stored and compressed chunks, all reset modes, and property changes are supported. The zero end byte is mandatory, and trailing bytes are rejected. Raw LZMA2 has no checksum. Returns the consumed and written lengths.

Errors#

DecodeError reports invalid properties, chunk sequences, ranges, distances, sizes, truncated or trailing input, and resource limits. Discard output on failure. OutOfMemoryError reports failure to allocate probability tables through the ambient allocator.

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