Skip to main content

Module binary

Module binary 

Source
Expand description

Binary form of a frozen Model: its columns as they are in memory, so loading copies them back instead of replaying the builder (no hashing, no sorting, no index rebuild).

Layout, all integers little-endian:

magic "MODELBIN" · version u32
strings    bytes, offsets (u64 each)
languages  [string]
metamodel  [name, archetype u8, traits u64, fm3?, graphql_type?, graphql_root?]
kinds      [tag u8 (255: other + string)]
entities   [52-byte row]
props      [entity u32, map]
by_key, child_offsets, children                 [u32]
relations  [from u32, kind u16, to u32, provenance u8]
out_offsets, in_offsets, incoming, site_offsets [u32]
sites      [4 × u32] · site_flags [u8]

Every list is prefixed by its length (u64); a string is a length-prefixed UTF-8 byte list and ? an optional string (u8 0/1, then the string).

Reading checks every index and offset the views rely on, so a truncated or corrupted file is an io::ErrorKind::InvalidData error, never a panic. The format is versioned: a reader refuses any other version.

Constants§

MAGIC
First bytes of a binary model; enough to tell it from JSON.
VERSION
Format version written by Model::write_binary.

Functions§

is_binary
Whether prefix (the first bytes of a file) starts a binary model.