Skip to main content

workspace_bytes

Function workspace_bytes 

Source
pub fn workspace_bytes(
    max_window_size: u64,
) -> Result<usize, WorkspaceConfigError>
Available on crate feature caller-workspace only.
Expand description

Bytes of workspace a WorkspaceDecoder needs to decode frames whose window is at most max_window_size.

The figure covers every byte the decoder writes: the window with room for the block being decoded, the entropy tables, the literals, the staging for a block split across input chunks, and alignment slack, so any sub-slice of that length works whatever its address.

§Errors

WorkspaceConfigError::WindowLimitOutOfRange when max_window_size lies outside 1 KiB ..= MAX_DECODER_WINDOW_SIZE, and WorkspaceConfigError::SizeOverflow when the size does not fit in usize on this target.

§Examples

use structured_zstd::decoding::workspace::workspace_bytes;
let small = workspace_bytes(64 * 1024).unwrap();
let large = workspace_bytes(8 << 20).unwrap();
assert!(small < large);
assert!(workspace_bytes(100).is_err());