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

Serialization

A built index can be serialized to bytes and reloaded, so you can construct once and cache the result rather than rebuilding on every run.

Rust

let bytes = index.to_bytes()?;              // Vec<u8>
let restored = FmIndex::from_bytes(&bytes)?; // FmIndex

BidirFmIndex exposes the same pair. The serialized form records the alphabet’s serialization tag, so a reloaded index keeps the matching semantics it was built with (see Custom Alphabets).

Sequence ids are stable

The headers are stored in build order, so a SeqId means the same reference before and after a round trip — you can record ids against a serialized index and reuse them on reload. (The header -> id map is derived from the header list rather than stored, so from_bytes rebuilds it; this is invisible to callers.)

Ids are only meaningful within one index. A differently-built index — sequences added, removed, or reordered — renumbers them; match on headers when crossing that boundary.

JavaScript / TypeScript

const bytes = handle.to_bytes();             // Uint8Array
const restored = FmIndexHandle.from_bytes(bytes);

Trusting input

Deserialization reconstructs an index from a byte buffer. Treat from_bytes input as you would any deserialized data — only load payloads you produced or otherwise trust. See the project security policy for the threat model.