Skip to main content

Module persistence

Module persistence 

Source
Expand description

Disk persistence and zero-copy mmap access for FibSidecarIndex.

This module provides a binary file format (FBS1) for serializing a FibSidecarIndex to disk and two loading modes:

  • load_from_file — fully owned reconstruction (reads everything into Vecs, decodes compact bytes to FibCodeV1).
  • load_mmap — zero-copy memory-mapped access. Compressed payloads stay in the mmap as &[u8] slices and are decoded on demand.

§File Format (FBS1)

[0..4]   magic: "FBS1"
[4]      version: u8 (1)
[5..9]   profile_json_len: u32
[9..9+L] profile_json: JSON-serialized FibQuantProfileV1
[9+L..13+L] gram_len: u32 (number of f32 values = N*N)
[13+L..13+L+G] gram_values: N*N f32 (little-endian, row-major)
[13+L+G..17+L+G] entry_count: u32
Per entry:
  id_len: u32 (little-endian)
  id_bytes: id_len bytes (postcard-serialized Id)
  code_len: u32 (little-endian)
  code_bytes: code_len bytes (FibCodeV1::to_compact_bytes)

Structs§

FibSidecarFileV1
On-disk file format for FibSidecarIndex.
MmapSidecarIndex
A memory-mapped sidecar index with zero-copy access to compressed payloads.

Constants§

FILE_MAGIC
Magic bytes: “FBS1” = Fib Sidecar v1.
FILE_VERSION
Current file format version.

Functions§

load_from_file
Load a FibSidecarIndex from a binary file (fully owned).
load_mmap
Load a sidecar index via memory-mapping (zero-copy).
save_to_file
Serialize a FibSidecarIndex to a binary file.