Skip to main content

Module container

Module container 

Source
Expand description

.vertc — the Veritate container: an at-rest file holding many messages for zero-copy random access, designed to be mmap-ped and read in place.

A Veritate message is already zero-copy over a &[u8], so a file of messages needs only enough structure to (a) find each record without scanning and (b) keep every record’s internal 8-byte fields aligned once the file is mapped. The container does exactly that and nothing more:

§Superseded

This module is superseded by crate::file (the .verit file) and is removed in 0.3.0. See ADR-0002.

A .vertc container is a record array: it has no schema section, so it is not interpretable without an out-of-band registry — the one property a file format exists to provide. .verit adds that section (each schema stored once, records hash-only), plus crash-safe appends, removal, and compaction. Migrate with FileBuilder.

┌─ header (32 B, 8-aligned) ─────────────────────────────────────────────┐
│ 0  "VRTC"        magic                                                   │
│ 4  u8  version=1                                                         │
│ 5  u8  flags=0                                                           │
│ 6  u16 reserved=0                                                        │
│ 8  u32 record_count                                                      │
│ 12 u32 reserved=0                                                        │
│ 16 u64 index_offset   (absolute offset of the index)                    │
│ 24 u64 file_len       (== total bytes; sanity)                          │
├─ records ───────────────────────────────────────────────────────────────┤
│ each message's raw bytes, in order, every record 8-byte aligned          │
├─ index (at index_offset, 8-aligned) ─────────────────────────────────────┤
│ record_count × { u64 offset, u64 len }   (offset absolute, len unpadded) │
└──────────────────────────────────────────────────────────────────────────┘

Because each record starts on an 8-byte boundary within the file and a memory map begins on a page boundary (a multiple of 8), every record’s start address is 8-aligned in memory, so the message’s own 8-aligned loads stay aligned — the point of the layout. The reader borrows the mapped bytes: Container::get returns a &[u8] sub-slice you hand straight to [Message::parse]. No mmap dependency lives here (the library stays zero-dep) — map the file with your platform’s facility, or std::fs::read it, and pass the &[u8].

Structs§

ContainerDeprecated
A read-only view over a .vertc container’s bytes (e.g. an mmap). Parsing validates the header and the whole index up front, so every later get is a bounds-free slice.
ContainerWriterDeprecated
Build a .vertc container from a sequence of Veritate messages. The output is a self-contained Vec<u8> you write to a file (and later mmap).

Constants§

CONTAINER_HEADER_LEN
Fixed header length, and the record alignment.
CONTAINER_MAGIC
Container file magic: “VRTC” + this reader/writer implements version 1.
CONTAINER_VERSION
Container format version this build reads and writes.