Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Examples

The recipes below include complete programs and round-trip assertions. Examples use the default std, compression, and decompression features unless stated otherwise. The documentation workflow compiles and runs their Rust code against the current checkout.

TaskRecipeFeatures / extra dependency
Choose graphs and compose codec nodesGraphs · CodecsDefault; per-codec features
Preserve typed and multiple inputsStructured dataDefault
Set the level, format version and checksumsEncoder settingsDefault
Write into a slice or uninitialized memoryOutput buffersDefault
Decode untrusted input with limitsSet limits for untrusted inputDefault
Read a frame header without decodingFrame metadataDefault
Compress and decompress bytesFirst round tripDefault
Reuse codec and destination memoryReuse the workspaceDefault
Write a raw stream incrementallyStream through WriteDefault
Drive a raw or framed encoder with tiny buffersSans I/O compressionDefault; framed for frames
Decode arriving chunks and resource eventsSans I/O decompressionDefault; framed for frames
Read or write raw, parallel, and framed streamsRead / Write I/ODefault; framed for frames
Use scoped CPU workersCompressing a sliceDefault
Reuse a Rayon thread poolRunning tasks with RayonDefault + rayon
Stream through parallel workersReader and writer adaptersDefault
Package compressed and stored resourcesOne container, two resourcesframed
Add resource names and write incrementallyWrite resources and metadataframed
Read just the selected resourceIndexed resource readsframed

Run from the repository

Initialize the C reference submodule used by development builds:

git submodule update --init --recursive
cargo run --release --example compress

The parallel example uses caller-owned scoped threads, reuses its compressor and verifies every assembled frame:

cargo run --release --example parallel

For a parallel batch, all taken tasks must run or be dropped before finalization. For a streaming adapter, keep workers running while the adapter blocks. Finish ordinary/parallel writers and the enclosing framed container explicitly. Framed resource commands accept complete input rather than resource writer guards.

Verify the documented recipes

python3 scripts/docs.py test-examples

This creates a temporary Cargo consumer under target/, depends on the local crate with framed enabled and on Rayon, and runs each fenced Rust program from all user-guide chapters, including graphs, codecs, typed inputs, dictionaries, parallel, framing and Sans I/O. It does not exercise the codec with --all-features, because that would also enable no_std and remove the std APIs these recipes demonstrate.