PTWM
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).

rsmod

ptwm_core::extension::compact_table

crates/ptwm-core/src/extension/compact_table.rs:1
mod compact_table

Compact 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.
rsfn

ptwm_core::extension::compact_table::classify

crates/ptwm-core/src/extension/compact_table.rs:89
pub fn classify(entry: &ExtensionTableEntry) -> Result<CompactEntry<'_>, PtwmCoreError>

Decide how `entry` is stored, or fail when the compact table cannot store it.

rsfn

ptwm_core::extension::compact_table::compact_table_bytes

crates/ptwm-core/src/extension/compact_table.rs:162
pub fn compact_table_bytes(table: &ExtensionTable) -> Result<Vec<u8>, PtwmCoreError>

Serialize `table` in the compact layout.

rstype

ptwm_core::extension::compact_table::CompactEntry

crates/ptwm-core/src/extension/compact_table.rs:65
pub enum CompactEntry

How [`write_compact_table`] stores one entry.

rsconst

ptwm_core::extension::compact_table::MAX_COMPACT_ENTRIES

crates/ptwm-core/src/extension/compact_table.rs:59
pub const MAX_COMPACT_ENTRIES

Largest entry count: table indices are `u16`.

rsfn

ptwm_core::extension::compact_table::read_compact_table

crates/ptwm-core/src/extension/compact_table.rs:242
pub fn read_compact_table(buf: &[u8]) -> Result<ExtensionTable, PtwmCoreError>

Parse a compact table that fills `buf` exactly.

rsconst

ptwm_core::extension::compact_table::TAG_CODEC

crates/ptwm-core/src/extension/compact_table.rs:52
pub const TAG_CODEC

Built-in plane codec, stored by `CodecId` wire id.

rsconst

ptwm_core::extension::compact_table::TAG_FULL

crates/ptwm-core/src/extension/compact_table.rs:56
pub const TAG_FULL

Third-party entry, stored in the legacy entry layout.

rsconst

ptwm_core::extension::compact_table::TAG_NAMED

crates/ptwm-core/src/extension/compact_table.rs:54
pub const TAG_NAMED

Built-in without a wire id, stored by name.

rsconst

ptwm_core::extension::compact_table::TAG_OP

crates/ptwm-core/src/extension/compact_table.rs:50
pub const TAG_OP

Built-in transform, stored by `OpId` wire id.

rsfn

ptwm_core::extension::compact_table::write_compact_table

crates/ptwm-core/src/extension/compact_table.rs:123
pub 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.