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#
pub enum BlockReasonThe invalid component of a compressed zstd block.
None#
NoneNo compressed-block failure applies.
Literals#
LiteralsA literal header, tree, or stream is invalid.
Sequences#
SequencesA sequence header, table, or bitstream is invalid.
Offset#
OffsetA match points outside the available window.
Output#
OutputThe decoded block exceeds the supplied output storage.
Implementation Debug for BlockReason#
impl Debug for BlockReasonOperation debug#
effect fn debug(self: &Self, formatter: &mut Formatter) -> () ! WriterError ? &mut WriterWrites the name of the variant, such as None.
BlockError#
pub struct BlockErrorA compressed-block failure and its local compressed byte position.
Field reason#
pub reason: BlockReasonThe invalid component.
Field offset#
pub offset: usizeThe local compressed byte position.
Implementation Debug for BlockError#
impl Debug for BlockErrorOperation debug#
effect fn debug(self: &Self, formatter: &mut Formatter) -> () ! WriterError ? &mut WriterWrites the fields, as BlockError { reason: ..., offset: ... }.
BlockState#
pub struct BlockStateRetained entropy tables and repeat offsets for one zstd frame.
Implementation BlockState#
impl BlockStateAssociated function make#
pub effect fn make() -> BlockState ! OutOfMemoryError ? &mut AllocatorAllocates 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#
pub fn reset(self: &mut Self) -> ()Restores fresh entropy tables and repeat offsets before a new frame.
Associated function workspaceBytes#
pub fn workspaceBytes() -> usizeReturns 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#
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.