pub struct SlotData { /* private fields */ }Expand description
Dense Vec indexed by slot_id — the bridge between Rust page handlers and the IR walker.
Handlers create a SlotData, populate it with values (title, user name, nav items, etc.), then the walker reads slot values when it encounters DYN_TEXT, DYN_ATTR, SHOW_IF, LIST opcodes.
Implementations§
Source§impl SlotData
impl SlotData
Sourcepub fn new(capacity: usize) -> Self
pub fn new(capacity: usize) -> Self
Create a new SlotData with capacity Null-initialized slots.
Sourcepub fn set(&mut self, slot_id: u16, value: SlotValue)
pub fn set(&mut self, slot_id: u16, value: SlotValue)
Set a slot value. No-op if slot_id is out of bounds.
Sourcepub fn get(&self, slot_id: u16) -> &SlotValue
pub fn get(&self, slot_id: u16) -> &SlotValue
Get a reference to a slot value. Returns &Null if out of bounds.
Sourcepub fn get_text(&self, slot_id: u16) -> Option<&str>
pub fn get_text(&self, slot_id: u16) -> Option<&str>
Get the text content of a slot. Returns Some(&str) if Text, None otherwise.
Sourcepub fn from_json(json_str: &str, module: &IrModule) -> Result<Self, IrError>
pub fn from_json(json_str: &str, module: &IrModule) -> Result<Self, IrError>
Create SlotData from a named-key JSON string, resolving names to slot IDs via the module’s string table and slot table.
The JSON must be an object (e.g., {"title": "Hello", "count": 42}).
Each key is resolved against the slot table: the slot entry’s name_str_idx
is looked up in the string table to find the slot name. If it matches a JSON
key, the JSON value is converted to a SlotValue and stored at that slot_id.
Unknown JSON keys (not in the slot table) are silently ignored. Starts from slot table defaults so missing keys retain their defaults.
Sourcepub fn new_from_defaults(table: &SlotTable) -> Self
pub fn new_from_defaults(table: &SlotTable) -> Self
Create SlotData pre-populated from the IR slot table defaults. Server-sourced slots with no default -> Null. Client-sourced slots with defaults -> parsed from default_bytes.