pub struct Guest<'a> { /* private fields */ }Expand description
Producer side: the guest engine writing opcodes and arena data into shared linear memory. Owns the header, ring, and arena regions as disjoint slices.
Implementations§
Source§impl<'a> Guest<'a>
impl<'a> Guest<'a>
Sourcepub fn new(mem: &'a mut [u8], layout: &MemoryLayout) -> Self
pub fn new(mem: &'a mut [u8], layout: &MemoryLayout) -> Self
Create a guest view over the linear memory. init_memory MUST have been
called on the same memory beforehand.
Sourcepub fn begin_frame(&mut self)
pub fn begin_frame(&mut self)
Record the start of a new frame.
Sourcepub fn frame_count(&self) -> u32
pub fn frame_count(&self) -> u32
Total frames produced so far.
pub fn create_node( &mut self, node_id: u32, component_type: u16, ) -> Result<(), RingError>
pub fn delete_node(&mut self, node_id: u32) -> Result<(), RingError>
pub fn insert_child( &mut self, parent: u32, child: u32, index: u32, ) -> Result<(), RingError>
pub fn remove_child(&mut self, parent: u32, child: u32) -> Result<(), RingError>
pub fn move_child( &mut self, parent: u32, child: u32, new_index: u32, ) -> Result<(), RingError>
Sourcepub fn push_opcode(&mut self, op: Opcode) -> Result<(), RingError>
pub fn push_opcode(&mut self, op: Opcode) -> Result<(), RingError>
Push a caller-built raw opcode into the ring. This is the escape hatch for foreign hosts (C ABI / FFM) that construct the 16-byte opcode themselves and write it into the shared ring in place.
pub fn set_property( &mut self, node_id: u32, property_id: u16, value_type: u8, value: u32, ) -> Result<(), RingError>
Sourcepub fn set_text(&mut self, node_id: u32, text: &str) -> Result<u32, RingError>
pub fn set_text(&mut self, node_id: u32, text: &str) -> Result<u32, RingError>
Set a node’s text content via the arena.
Sourcepub fn set_date(
&mut self,
node_id: u32,
days: i32,
millis: u32,
) -> Result<(), RingError>
pub fn set_date( &mut self, node_id: u32, days: i32, millis: u32, ) -> Result<(), RingError>
Set a node’s date value via PARAMETER::SET_DATE (draft): days since the
epoch (I32, pre-1970 negative) and millis of day (U32, 0..86,400,000).
Sourcepub fn set_design_token(
&mut self,
path: &str,
value_type: u8,
value: u32,
) -> Result<u32, RingError>
pub fn set_design_token( &mut self, path: &str, value_type: u8, value: u32, ) -> Result<u32, RingError>
Override a design token globally via PARAMETER::SET_DESIGN_TOKEN:
path (arena string) → value of value_type. Applies everywhere the
renderer resolves tokens (spec/TOKENS.md). A dark.-prefixed path
overrides the dark variant. Returns the arena offset of the path.
Sourcepub fn set_design_token_string(
&mut self,
path: &str,
value: &str,
) -> Result<u32, RingError>
pub fn set_design_token_string( &mut self, path: &str, value: &str, ) -> Result<u32, RingError>
Override a design token with a STRING value via PARAMETER::SET_DESIGN_TOKEN
(spec/TOKENS.md): both the token path and the value are arena strings —
A = path ref, B = STRING value type, C = value ref. Returns the
arena offset of the path.
Sourcepub fn alloc(&mut self, bytes: &[u8]) -> Result<u32, ArenaError>
pub fn alloc(&mut self, bytes: &[u8]) -> Result<u32, ArenaError>
Allocate arbitrary bytes into the arena, returning the offset.
Sourcepub fn alloc_str(&mut self, s: &str) -> Result<u32, ArenaError>
pub fn alloc_str(&mut self, s: &str) -> Result<u32, ArenaError>
Allocate a string into the arena, returning the offset.
pub fn reset(&mut self) -> Result<(), RingError>
Sourcepub fn drain_events(&mut self) -> Vec<Event>
pub fn drain_events(&mut self) -> Vec<Event>
Drain all pending raw-input events written by the host into the event
ring, decoding each 16-byte EVENT opcode into a typed Event.
The guest (app/engine) polls this to receive renderer-reported inputs.
Sourcepub fn drain_event_opcodes(&mut self) -> Vec<Opcode>
pub fn drain_event_opcodes(&mut self) -> Vec<Opcode>
Drain raw EVENT-category opcodes from the host → guest event ring as
their 16-byte wire form (no decoding). Used by foreign hosts that want
the raw bytes.
Sourcepub fn drain_event_opcodes_max(&mut self, max: usize) -> Vec<Opcode>
pub fn drain_event_opcodes_max(&mut self, max: usize) -> Vec<Opcode>
Drain at most max raw EVENT-category opcodes, leaving the rest
pending for a later call (so a caller with a fixed-size buffer never
drops events it couldn’t copy).
Sourcepub fn event_arena_cursor(&self) -> u32
pub fn event_arena_cursor(&self) -> u32
The host → guest event arena bump cursor (diagnostics/tests).
Sourcepub fn push_event_opcode(&mut self, op: Opcode) -> Result<(), RingError>
pub fn push_event_opcode(&mut self, op: Opcode) -> Result<(), RingError>
Push a raw EVENT-category opcode into the host → guest event ring.
This is the host-side write (the renderer reporting an input). Exposed
here (guest can hold the ring too) so a C-ABI shim can inject raw event
opcodes without round-tripping through the typed Event enum.