Expand description
Native binary container for document bodies (PRD-1398, ADR-0063).
Encodes a named-field document (&[(&str, &Value)]) into a compact binary
container with a header offset table that enables O(1) access to any
top-level field value without decoding the entire document.
§Format — version 3
[0..4] magic = b"RDOC"
[4] version = 0x03
[5..7] num_fields : u16 LE (max 65 535 fields per document)
[7..] offset table : num_fields × [key_len: u16 LE, val_offset: u32 LE]
keys section : concatenated UTF-8 field name bytes (key_len[i] each)
values section: concatenated value_codec-encoded bytesval_offset is an absolute byte offset from byte 0 of the container,
allowing a single value to be decoded with decode_value_at_offset after
reading only the header — the rest of the payload stays untouched.
§Flag-dark
This codec is compiled and tested but not yet wired into any storage or query path. Behaviour cutover happens in a later PRD-1398 slice.
Enums§
- DocBody
Error - Errors produced by the document body codec.
Constants§
- MAGIC
- Magic bytes at the start of every document body container.
- VERSION
- Format version byte for the plain (inline-keys-only) container.
- VERSION_
DICT - Format version byte for the dictionary-aware container (PRD-1398).
Functions§
- decode
- Decode all fields from a document body container.
- decode_
value_ at_ offset - Decode a single value using its absolute byte offset within the container.
- decode_
with_ dictionary - Decode all fields from a dictionary-aware (v2) document body container.
- encode
- Encode
fieldsas a document body container, appending bytes toout. - encode_
with_ dictionary - Encode
fieldsas a dictionary-aware (v2) document body container. - field_
names - Return the top-level field names in encode order without decoding any value.
- parse_
dict_ header - Parse a v2 container header, returning
(num_fields, table)where each table entry is(key_kind, key_ref, val_offset). - parse_
header - Parse the container header and return
(num_fields, offset_table). - read_
field_ by_ name - Read a single field by name without decoding any other value.
Type Aliases§
- Dict
Entry - One parsed v2 offset-table entry:
(key_kind, key_ref, val_offset).