Expand description
§verit — Exavian Veritate
The public umbrella crate. One serialization format that is all three
things at once — zero-copy, self-describing, and
schema-evolvable — with no unsafe, an opt-in amplification-DoS budget,
and one wire spec implemented byte-for-byte across six independent
implementations (Rust, Python, C++, Go, TypeScript, and a GnuCOBOL port).
Consumers depend only on verit. Everything real lives in the internal
verit_core engine; this crate is the single public seam that re-exports
it, so the engine can be split or rewritten from one edit point. The
internal crates (verit-core, verit-cli) must never be imported directly.
use verit::prelude::*;
let schema = SchemaBuilder::new()
.add_struct("Point", vec![(1, "x", Dt::F64), (2, "y", Dt::F64)])
.build("Point")?;
let bytes = encode(&schema, &Value::Struct(vec![
(1, Value::F64(1.5)), (2, Value::F64(-0.5)),
]), SchemaMode::Inline)?;
assert_eq!(dump_json(&bytes)?, r#"{"x":1.5,"y":-0.5}"#);The wire format is specified in docs/Architecture/VERIT - Wire Specification.md; the crate map is in VERIT - System Architecture.md.
Modules§
- codegen
- Rust code generation: compile a
Schemainto typed readers and writers. - container
.vertc— the Veritate container: an at-rest file holding many messages for zero-copy random access, designed to bemmap-ped and read in place.- derive
- Runtime support for
#[derive(Verit)]— the Rust peer of Python’s@veritdecorator. - dump
- The self-description proof: given message bytes and nothing else, recover the writer schema from the inline region and render every present field — with its human-readable name — as JSON.
- encode
- Encoder:
Schema+Valuetree → message bytes. - error
- file
.verit— the Veritate file: many messages in one self-contained,mmap-able, appendable file.- hash
- Content hashing for schema ids.
- idl
- The
.vscschema IDL — a small text front-end that compiles to aSchema. It invents no wire semantics: it drivesSchemaBuilder, so the result is exactly the same canonicalVSC1bytes (and 128-bit id) any other definition of the same schema produces. The IDL therefore cannot drift from the wire format — the id is the contract, and it is computed the same way regardless of how the schema was written. - layout
- Deterministic struct layout. Because the layout is a pure function of the schema, a schema id fully determines every byte offset — the schema acts as one shared “vtable” for every message that uses it, which is what makes per-message zero-copy access possible without per-object tables.
- message
- Zero-copy message access.
Message::parseonly reads the 24-byte header; nothing else is touched until a field is asked for, and every field read is a bounds-checked load straight out of the buffer through a precompiledResolverplan. Strings and byte fields are returned as&str/&[u8]borrowing the message buffer — no allocation, no copy. - prelude
- The common import surface for Exavian Veritate.
- registry
- Schema registry + distribution bundle for multi-service deployments.
- resolve
- Schema resolution: the piece that buys evolution without giving up
zero-copy. A
Resolveris built once per (writer schema, reader schema) pair and compiles, for every corresponding struct type, an access plan mapping each reader field ID to either a concrete byte slot in the writer’s layout (with an optional lossless widening) orAbsent. After that, reading any number of messages costs no per-message resolution work. - schema
- Schema model, builder, canonical binary encoding (“VSC1”), and content hashing. The canonical form sorts types by name, fields by ID, and enum variants by value, so one logical schema has exactly one byte encoding and therefore exactly one id.
- value
- Dynamic values for the write path. The prototype has no codegen; you build
a
Valuetree against a runtimecrate::Schemaand encode it. A struct value lists (field id, value) pairs — omitted fields are absent (their presence bit stays 0 and readers seeNone). - wire
- Public low-level wire primitives for generated code (see
crate::codegen). Everything here is bounds-checked andunsafe-free; generated readers/writers compose these with offsets computed at generation time from the deterministic layout algorithm.
Structs§
- Budget
- A per-read traversal budget — an opt-in guard against amplification-DoS
on untrusted messages (the wire spec §5.2). Veritate’s offsets are absolute and
may alias, so a small hostile message can point many fields at the same
large sub-object and make a naive full read do work super-linear in the
message’s own size. Memory safety (bounds, depth, allocation) always holds;
a
Budgetadditionally caps total work. - Container
Deprecated - A read-only view over a
.vertccontainer’s bytes (e.g. anmmap). Parsing validates the header and the whole index up front, so every latergetis a bounds-free slice. - Container
Writer Deprecated - Build a
.vertccontainer from a sequence of Veritate messages. The output is a self-containedVec<u8>you write to a file (and latermmap). - EnumDef
- Field
Def - File
Builder - Build a complete generation-1
.veritfile in memory. - File
Reader - A
.veritfile read into memory, owning its bytes. - File
View - A read-only, zero-copy view over a
.veritfile’s bytes (typically anmmap).openvalidates the header, footer, schema section, and every index entry up front, so each latergetis a bounds-free slice. - File
Writer - A
.veritfile open for reading and writing, mutated by crash-safe append-only commits. - Footer
- A parsed footer — the authoritative statement of a file’s committed state.
- List
Reader - Message
- Record
- One index entry: a record’s identity, where it lives, and which schema interprets it.
- Resolver
- Resolvers
- One
Resolverper distinct schema in a file, built once byFileView::resolvers. - Schema
- A validated schema: canonical type table, cached canonical bytes, content id, and precomputed struct layouts.
- Schema
Builder - Declaration order never matters:
buildsorts types by name and fields by ID before encoding, so equivalent declarations produce identical schema ids. - Schema
Registry - A content-addressed store of schemas, keyed by their 128-bit id.
- Struct
Def - Struct
Reader
Enums§
- Default
- A scalar custom default for a field: the value a reader synthesizes when
the field is absent (see
StructReader::get_or_default). v1 supports scalar defaults only; floats are stored as their bit patterns so the schema types stayEq. - Dt
- Draft type used in
SchemaBuilder: likeTypebut names other types by string instead of index (indices only exist after canonical sorting). - Error
- Ref
- A field value read from the buffer. Scalars are by value; strings, bytes,
structs, and lists borrow the message buffer (
'b). - Scalars
- A run of scalars held in its native Rust form.
- Schema
Mode - Struct
Mode - How a struct’s fields are stored.
- Type
- A field or element type.
Struct/Enumreference other types in the same schema by index into the canonically (name-)sorted type table. - TypeDef
- Value
Constants§
- FIRST_
RECORD_ ID - Record ids start at 1, so
0is available as “no record”. - OPT_
RECORD_ CRC optional_featuresbit 0 — the file carries a CRC-32 per record.- VERSION
- The crate version string, from
Cargo.toml.
Traits§
- Verit
Type - Implemented by every
#[derive(Verit)]type. All of it is generated; you never write an impl by hand. The provided methods (to_verit,from_verit,verit_schema_id) are the surface you actually call.
Functions§
- dump_
json - Decode a message using only its own bytes. Requires the message to have
been encoded with
crate::SchemaMode::Inline. - dump_
json_ with - Render a hash-only message using a writer schema supplied from outside
the message — a registry, or a
.veritfile’s schema section. Same output asdump_json; the difference is only where the schema came from. - encode