Browse the docs

silk.compress.zstd_block.

Internal bounded zstd compressed-block decoding with retained entropy tables.

Details#

Callers supply literal, output, and circular history storage. A failed decode invalidates the state.

Import as BlockState with import silk.compress.zstd_block { BlockState }.

Public declarations: 3.

BlockReason#

silk
pub enum BlockReason

The invalid component of a compressed zstd block.

None#

silk
None

No compressed-block failure applies.

Literals#

silk
Literals

A literal header, tree, or stream is invalid.

Sequences#

silk
Sequences

A sequence header, table, or bitstream is invalid.

Offset#

silk
Offset

A match points outside the available window.

Output#

silk
Output

The decoded block exceeds the supplied output storage.

Implementation Debug for BlockReason#

silk
impl Debug for BlockReason

Operation debug#

silk
effect fn debug(self: &Self, formatter: &mut Formatter) -> () ! WriterError ? &mut Writer

Writes the name of the variant, such as None.

BlockError#

silk
pub struct BlockError

A compressed-block failure and its local compressed byte position.

Field reason#

silk
pub reason: BlockReason

The invalid component.

Field offset#

silk
pub offset: usize

The local compressed byte position.

Implementation Debug for BlockError#

silk
impl Debug for BlockError

Operation debug#

silk
effect fn debug(self: &Self, formatter: &mut Formatter) -> () ! WriterError ? &mut Writer

Writes the fields, as BlockError { reason: ..., offset: ... }.

BlockState#

silk
pub struct BlockState

Retained entropy tables and repeat offsets for one zstd frame.

Implementation BlockState#

silk
impl BlockState

Associated function make#

silk
pub effect fn make() -> BlockState ! OutOfMemoryError ? &mut Allocator

Allocates fresh entropy tables and sets the initial repeat offsets for one frame.

Details#

The state owns five exact allocations and releases them when dropped. Decode and reset do not allocate.

Method reset#

silk
pub fn reset(self: &mut Self) -> ()

Restores fresh entropy tables and repeat offsets before a new frame.

Associated function workspaceBytes#

silk
pub fn workspaceBytes() -> usize

Returns a conservative byte bound for tables and transient algorithm scratch on supported targets.

Details#

This bound excludes caller-owned compressed, literal, output, and history storage.

Method decode#

silk
pub fn decode(
    self: &mut Self,
    input: &[u8],
    literals: &mut [u8],
    output: &mut [u8],
    history: &[u8],
    historyPosition: usize,
    historyLength: usize,
    windowSize: usize,
  ) -> Result<usize, BlockError>

Decodes one complete compressed block into caller-owned storage without allocation.

Details#

Returns the initialized output length. historyPosition is the next circular write position. historyLength counts valid bytes from earlier blocks. windowSize bounds match distances.

Gotchas#

Failure can change tables and scratch bytes. Discard the frame state after 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