Expand description
.10d self-describing section table + tiered alignment + caller-buffered
writer (P0.2).
A .10d file is: the 64-byte super::header::Container10dHeader, then
(optionally) a section table — an array of SectionDescriptor rows —
then the section payloads, each aligned to its declared tier. The header’s
section_table_offset + section_count point at the table.
Canonical encoding (determinism). Sections are written in ascending
section_type order. Duplicate section_type values are rejected, so two
encodes of the same section set — even if the caller passes them in
permuted order — produce byte-identical output. This is the P0.2
“two encodes (incl. permuted section order) are byte-identical” gate.
Tiered alignment. Each section declares an AlignmentTier; the
writer inserts zero padding so every section start meets its tier. The
reader rejects any section whose start is misaligned, whose descriptor
overlaps another, whose byte_offset/byte_length is out of bounds, or
whose stride * element_count != byte_length (stride-inconsistent).
Per-section CRC-32C. Each descriptor carries a CRC-32C over its
payload bytes; the reader rejects a flipped bit. The CRC-32C routine here
is a local copy of the Castagnoli-reflected algorithm used in
q42/p64_weight.rs; P0.3 consolidates the two into a shared module and
delegates both call sites (the P0.3 acceptance gate verifies p64’s
checksums stay byte-identical after delegation).
Caller-buffered / zero-heap. encode_container takes a caller-
supplied &mut [u8] output buffer and returns the bytes written; it
allocates no Vec/String/Box on the hot path (the only allocation is
the canonical-order index sort, which uses a stack array — see
sort_indices_stack). parse_section_table returns a zero-copy
&[SectionDescriptor] view into the input bytes.
Structs§
- Section
Descriptor - One row of the section table — a self-describing section descriptor.
- Section
Input - A caller-supplied section input for
encode_container. The writer computesbyte_offset,crc32c, and the canonical order; the caller supplies the type, tier, stride/element_count (for array sections), and the payload bytes.
Enums§
- Alignment
Tier - Alignment tier for a section’s start offset. The tier determines the power-of-two alignment the writer enforces (and the reader verifies).
- Section
Table Error - Section-table encode/decode error.
- Section
Type - A section type tag. v1 defines the types the runtime actually fills;
future types are listed as
SpecReserved*and the writer rejects them (aSpecReserved*type in a v1 file is a forward-incompatibility signal, not a payload to read blindly).
Constants§
- SECTION_
DESCRIPTOR_ SIZE - Size of one
SectionDescriptorin bytes.
Functions§
- encode_
container - Encode a
.10dcontainer into a caller-supplied buffer. Zero-heap on the hot path (the only stack arrays are the index order and descriptor table, both fixed-size). Returns the number of bytes written. - parse_
section_ table - Parse the section table from a
.10dbyte slice. Returns a zero-copy&[SectionDescriptor]view into the input. Runs every P0.2 reader gate: pointer consistency, per-descriptor type/tier/reserved validation, tier alignment, in-bounds, overlap, stride consistency, and per-section CRC.