Expand description
Document codec (L4) — per-document header + postcard payload.
See docs/format.md § Document records for the authoritative
byte-by-byte specification. This module is the reference
implementation.
The codec sits between the typed Document API (this module) and
the B+tree (L3): every stored value in a collection’s primary
B-tree is the byte string produced by encode, and every
Db::get decodes through decode. The catalog (L5) supplies
the collection_id that the per-document header pins; the
catalog itself stores CollectionDescriptors through this same
codec (M5 issue #38).
§Power-of-ten posture
- Rule 5. Encode and decode are runtime boundaries: every
header field is validated explicitly before any
postcardcall touches caller-controlled bytes. CRC32C, collection-id, and version-range checks are the three layers of defense indecode. - Rule 7. No
unwrap/expecton any error-bearing path; postcard errors propagate via the?operator intoError::Codec. - Rule 9. Hot-path dispatch is static — all codec calls are
monomorphised over
T: Document. Nodynanywhere in this module.
Re-exports§
pub use crate::codec::dynamic::Dynamic;pub use crate::codec::header::DocumentHeader;pub use crate::codec::header::DOC_HEADER_SIZE;pub use crate::codec::header::MAX_INLINE_DOC;pub use crate::codec::migrate::Migrate;pub use crate::codec::schema::DynamicSchema;pub use crate::codec::schema::EnumVariantSchema;pub use crate::codec::schema::Schema;pub use crate::codec::schema::MAX_SCHEMA_DEPTH;
Modules§
- dynamic
Dynamic— reflective value tree for schema migration.- header
- Per-document record header — encode / decode.
- migrate
- Schema-evolution trait —
Migrate. - schema
DynamicSchema— declarative description of a postcard-encoded payload’s shape.
Traits§
- Document
- The trait every user document type implements.