Skip to main content

Guest

Struct Guest 

Source
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>

Source

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.

Source

pub fn begin_frame(&mut self)

Record the start of a new frame.

Source

pub fn pending(&self) -> usize

Number of opcodes written since the last begin_frame.

Source

pub fn end_frame(&mut self)

End the frame: increments frameCount.

Source

pub fn frame_count(&self) -> u32

Total frames produced so far.

Source

pub fn create_node( &mut self, node_id: u32, component_type: u16, ) -> Result<(), RingError>

Source

pub fn delete_node(&mut self, node_id: u32) -> Result<(), RingError>

Source

pub fn insert_child( &mut self, parent: u32, child: u32, index: u32, ) -> Result<(), RingError>

Source

pub fn remove_child(&mut self, parent: u32, child: u32) -> Result<(), RingError>

Source

pub fn move_child( &mut self, parent: u32, child: u32, new_index: u32, ) -> Result<(), RingError>

Source

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.

Source

pub fn set_property( &mut self, node_id: u32, property_id: u16, value_type: u8, value: u32, ) -> Result<(), RingError>

Source

pub fn set_text(&mut self, node_id: u32, text: &str) -> Result<u32, RingError>

Set a node’s text content via the arena.

Source

pub fn set_attributed_text( &mut self, node_id: u32, text: &AttributedString, ) -> Result<u32, RingError>

Set a node’s text plus style runs and links via PARAMETER::SET_ATTRIBUTED_TEXT.

The payload is encoded (see crate::AttributedString::encode) into one length-prefixed arena entry. Returns that entry’s byte offset.

Source

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

Source

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.

Source

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.

Source

pub fn alloc(&mut self, bytes: &[u8]) -> Result<u32, ArenaError>

Allocate arbitrary bytes into the arena, returning the offset.

Source

pub fn alloc_str(&mut self, s: &str) -> Result<u32, ArenaError>

Allocate a string into the arena, returning the offset.

Source

pub fn reset(&mut self) -> Result<(), RingError>

Source

pub fn set_color_scheme(&mut self, mode: u32) -> Result<(), RingError>

Force the renderer-wide color scheme (META::SET_COLOR_SCHEME): 0 = platform-derived, 1 = light, 2 = dark (spec/TOKENS.md).

Source

pub fn reset_theme(&mut self) -> Result<(), RingError>

Clear every application design-token override (META::RESET_THEME).

Source

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.

Source

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.

Source

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

Source

pub fn event_arena_cursor(&self) -> u32

The host → guest event arena bump cursor (diagnostics/tests).

Source

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.

Auto Trait Implementations§

§

impl<'a> !UnwindSafe for Guest<'a>

§

impl<'a> Forget for Guest<'a>

§

impl<'a> Freeze for Guest<'a>

§

impl<'a> Move for Guest<'a>

§

impl<'a> RefUnwindSafe for Guest<'a>

§

impl<'a> Send for Guest<'a>

§

impl<'a> Sync for Guest<'a>

§

impl<'a> Unpin for Guest<'a>

§

impl<'a> UnsafeUnpin for Guest<'a>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.