Expand description
Binary segment codec for the persistent index store (ADR-104).
Byte-for-byte port of services/index_format.py per
rust/spec/index-store-format.md §2. Fixed struct reads over a byte
buffer — no code-bearing deserialisation; every read is bounds-checked
and a segment’s declared payload length must match its file exactly, so
truncation or trailing garbage fails closed on open (a cache miss).
Structs§
- Index
Format Error - A segment is corrupt, truncated, wrong-magic, or wrong-version. The store treats this as a cache miss and rebuilds; it never escapes to a caller.
- Indexed
Segment - Reader over a
write_indexedpayload — random access by row index. - Reader
- Writer
Constants§
- SEGMENT_
FORMAT_ VERSION - The binary layout version (v4: tags tier, ADR-109).
- SEGMENT_
MAGIC - 8 magic bytes opening every segment file.
Functions§
- encode_
segment - Frame a payload as a segment file’s bytes: magic, version, length, payload.
- segment_
payload - Validate a mapped segment and return its payload slice (fail-closed).
- write_
indexed - Encode row blobs with a docid-indexed offset table for O(1) point access:
count(u32) | offsets(count × u64, relative to end of table) | rows.