extension
ptwm_core::extension::compact_table
Compact Extension Table, used by the compact container (\x89PTWC).
ptwm_core::extension::compact_table
Compact Extension Table, used by the compact container (\x89PTWC).
ptwm_core::extension::compact_table
crates/ptwm-core/src/extension/compact_table.rs:1mod compact_tableCompact Extension Table, used by the compact container (`\x89PTWC`).
The legacy table stores every entry in full: id, label, kind, ABI,
capabilities and attestation, about 125 bytes per built-in. A built-in
entry is fully determined by its name and the crate version, so the
compact table stores a built-in as a tag and a wire id or name, and
stores third-party entries in full:
```text
count varint at most 65536 and at most (table bytes) / 2
entry × count:
tag u8
0x01 OpId wire id (varint) built-in transform
0x02 CodecId wire id (varint) built-in plane codec
0x03 name_len varint (1..=255), then the name
built-in without a wire id
0x7F len varint, then one legacy table entry of exactly len
bytes third-party entry
```
The reader expands tags 0x01-0x03 to the built-in entry of the reader's
own version ([`builtin_registry`]), so dispatch, trust and the
missing-flavor check see the same entries as for a legacy file, and a
compact file does not depend on the version that wrote it.
Each entry has one encoding:
- a built-in with an op or codec wire id must use tag 0x01 or 0x02; tag
0x03 is only for built-ins without one;
- a codec id without a built-in entry (`huffman_nibble`) is rejected;
- a 0x7F entry must not carry a built-in id, of this version or (by its
label) of another one, must re-serialize to the same bytes, and must
not reference embedded WASM;
- unknown tags, ids and names are rejected, and so are duplicate ids.
The writer refuses entries it cannot store this way: a built-in id whose
other fields differ from the built-in entry, or a built-in of another
release.
ptwm_core::extension::compact_table::classify
crates/ptwm-core/src/extension/compact_table.rs:89pub fn classify(entry: &ExtensionTableEntry) -> Result<CompactEntry<'_>, PtwmCoreError>Decide how `entry` is stored, or fail when the compact table cannot store it.
ptwm_core::extension::compact_table::compact_table_bytes
crates/ptwm-core/src/extension/compact_table.rs:162pub fn compact_table_bytes(table: &ExtensionTable) -> Result<Vec<u8>, PtwmCoreError>Serialize `table` in the compact layout.
ptwm_core::extension::compact_table::CompactEntry
crates/ptwm-core/src/extension/compact_table.rs:65pub enum CompactEntryHow [`write_compact_table`] stores one entry.
ptwm_core::extension::compact_table::MAX_COMPACT_ENTRIES
crates/ptwm-core/src/extension/compact_table.rs:59pub const MAX_COMPACT_ENTRIESLargest entry count: table indices are `u16`.
ptwm_core::extension::compact_table::read_compact_table
crates/ptwm-core/src/extension/compact_table.rs:242pub fn read_compact_table(buf: &[u8]) -> Result<ExtensionTable, PtwmCoreError>Parse a compact table that fills `buf` exactly.
ptwm_core::extension::compact_table::TAG_CODEC
crates/ptwm-core/src/extension/compact_table.rs:52pub const TAG_CODECBuilt-in plane codec, stored by `CodecId` wire id.
ptwm_core::extension::compact_table::TAG_FULL
crates/ptwm-core/src/extension/compact_table.rs:56pub const TAG_FULLThird-party entry, stored in the legacy entry layout.
ptwm_core::extension::compact_table::TAG_NAMED
crates/ptwm-core/src/extension/compact_table.rs:54pub const TAG_NAMEDBuilt-in without a wire id, stored by name.
ptwm_core::extension::compact_table::TAG_OP
crates/ptwm-core/src/extension/compact_table.rs:50pub const TAG_OPBuilt-in transform, stored by `OpId` wire id.
ptwm_core::extension::compact_table::write_compact_table
crates/ptwm-core/src/extension/compact_table.rs:123pub fn write_compact_table(table: &ExtensionTable, out: &mut Vec<u8>) -> Result<(), PtwmCoreError>Append the compact encoding of `table` to `out`. On error `out` is left unchanged.