PTWM
ptwm_core

ptwm_core::container

Container writer and reader orchestration.

ptwm_core::container

Container writer and reader orchestration.

rsmod

ptwm_core::container

crates/ptwm-core/src/container.rs:1
mod container

Container writer and reader orchestration.

rsfn

ptwm_core::container::build_extension_table

crates/ptwm-core/src/container.rs:167
pub fn build_extension_table(registry: &ChainRegistry, codecs: CodecSet<'_>, builtin_version: &str) -> Result<BuiltExtensionTable, PtwmCoreError>

Build the Extension Table and the serialized chain registry for a container. Chain ops are interned first (in registry order), then the plane codecs selected by `codecs`, in the order of [`crate::extension::builtin_entries`].

Built-in entries carry the ids and labels of `builtin_version` ([`crate::extension::LEGACY_BUILTIN_VERSION`] for new legacy files). The returned `codec_idx_map` is keyed by the current canonical ids whatever the version. The result is a pure function of `registry`, the codec set and the version, so a reader-side tool (the transcoder) can rebuild the same bytes.
rstype

ptwm_core::container::BuiltExtensionTable

crates/ptwm-core/src/container.rs:146
pub struct BuiltExtensionTable

Output of [`build_extension_table`].

rstype

ptwm_core::container::ChainRegistry

crates/ptwm-core/src/container.rs:51
pub struct ChainRegistry

In-memory chain registry section.

Wire format: ```text num_chains: u16 [chain_entry] × num_chains: chain_id: u16 (chain::wire::write_chain payload: num_nodes, num_edges, num_terminals, lens, nodes_bytes, edges_bytes, terminals_bytes) ```
rstype

ptwm_core::container::CodecSet

crates/ptwm-core/src/container.rs:137
pub enum CodecSet

Which plane codecs an Extension Table interns besides the chain ops.

rstype

ptwm_core::container::ContainerLayout

crates/ptwm-core/src/container.rs:335
pub enum ContainerLayout

On-disk layout of a container.

`Default` gives `Compact`, the layout of new multi-tensor writes ([`crate::compressor::CompressorOptions`]). [`ContainerWriter::new`] still writes `Legacy`; use [`ContainerWriter::with_layout`] to choose.
rstype

ptwm_core::container::ContainerReader

crates/ptwm-core/src/container.rs:1334
pub struct ContainerReader

Zero-copy reader for a `.ptwm` container backed by an in-memory byte slice.

rstype

ptwm_core::container::ContainerWriter

crates/ptwm-core/src/container.rs:424
pub struct ContainerWriter

Streaming writer for a `.ptwm` container.

rsfn

ptwm_core::container::encode_registry_for_table

crates/ptwm-core/src/container.rs:238
pub fn encode_registry_for_table(table_bytes: &[u8], registry: &ChainRegistry) -> Result<BuiltExtensionTable, PtwmCoreError>

Validate serialized Extension Table bytes and encode `registry` against them, for [`ContainerWriter::set_raw_extension_table`].

Checks: - `table_bytes` parse as one Extension Table with no trailing bytes and re-serialize to the same bytes; - no entry references an embedded WASM module; - every op of every registry chain is already in the table (built-in ids of other releases count once normalised). Registry ops resolve to the first entry with their id; `codec_idx_map` maps each built-in codec's current id to its first entry. The returned `table` is the table as parsed, without normalisation.
rsconst

ptwm_core::container::MAX_CHAIN_ID

crates/ptwm-core/src/container.rs:34
pub const MAX_CHAIN_ID

Largest registry chain id. A tensor record addresses a registry chain through the low 15 bits of `chain_ref`; the high bit marks an inline chain.

rsconst

ptwm_core::container::MAX_REGISTRY_CHAINS

crates/ptwm-core/src/container.rs:38
pub const MAX_REGISTRY_CHAINS

Largest number of chains a registry can hold: one per id in `0..=MAX_CHAIN_ID`.

rsfn

ptwm_core::container::read_extension_table

crates/ptwm-core/src/container.rs:1315
pub fn read_extension_table(buf: &[u8]) -> Result<ExtensionTable, PtwmCoreError>

Read the Extension Table of a container in either layout without opening the rest of it: no extension check, prelude, registry or index parse.

A legacy (`\x89PTWM` / `\x89PTWX`) file has its table region bounds-checked and its hash verified, and built-in ids written by other releases are mapped to the current ones (see [`crate::extension::normalize_builtin_ids`]). A compact (`\x89PTWC`) file has its EOF sentinel, sections and `meta_xxh64` checked, and its compact entries expanded to full entries. Any other magic is an error.
rstype

ptwm_core::container::RecordEncoder

crates/ptwm-core/src/container.rs:383
pub struct RecordEncoder

Serializes tensor records for one container writer's layout and tables.

[`ContainerWriter::record_encoder`] returns it so that callers can serialize records in parallel and append the bytes with [`ContainerWriter::append_serialized_tensor`].