Browse the docs

silk.compress.lzma.

Decode complete LZMA-alone streams into caller-owned byte buffers.

When to use#

Use Lzma.decode for .lzma files with the 13-byte LZMA-alone header. Use silk.compress.lzma2.Lzma2 for raw LZMA2 chunks and silk.compress.xz.Xz for .xz files.

Details#

Decoding allocates probability tables through the ambient allocator. The output buffer also holds dictionary history. Both known-size streams and streams with end markers are accepted. Input must contain exactly one stream. There is no checksum; use an authenticated container when integrity is required. Discard output after a failure.

Import as Lzma with import silk.compress.lzma { Lzma }.

Public declarations: 1.

Lzma#

silk
pub struct Lzma

A complete-buffer LZMA-alone decoder with caller-selected resource limits.

Implementation Lzma#

silk
impl Lzma

Associated function decode#

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

Decodes one 13-byte-header LZMA-alone stream into the start of output.

Details#

Allocates probability tables with the ambient allocator and uses output for dictionary history. Known-size streams may omit the end marker; unknown-size streams must include it. Returns the consumed and written lengths. Trailing bytes are rejected. LZMA has no checksum.

Errors#

Fails with DecodeError for malformed or truncated data, trailing bytes, invalid distances, size mismatches, or exhausted input, output, dictionary, or workspace limits. Output is not verified on failure and must be discarded. Allocation failure raises OutOfMemoryError.

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