pub struct Runtime { /* private fields */ }Expand description
A renderer’s surfaces, headless.
Implementations§
Source§impl Runtime
impl Runtime
Sourcepub fn new(
catalogs: impl IntoIterator<Item = Catalog>,
) -> Result<Self, CompileError>
pub fn new( catalogs: impl IntoIterator<Item = Catalog>, ) -> Result<Self, CompileError>
A runtime for a renderer that supports catalogs.
Sourcepub fn set_rules(&mut self, rules: Rules)
pub fn set_rules(&mut self, rules: Rules)
The completeness rules batches are applied under from now on (see
crate::Rules; strict by default).
Sourcepub fn register(
&mut self,
name: impl Into<String>,
def: FunctionDef,
function: LocalFunction,
)
pub fn register( &mut self, name: impl Into<String>, def: FunctionDef, function: LocalFunction, )
Implement a function on the renderer (see Evaluator::register).
Sourcepub fn surface_ids(&self) -> impl Iterator<Item = &str>
pub fn surface_ids(&self) -> impl Iterator<Item = &str>
The surfaces, by id.
Sourcepub fn data_model(&self, surface_id: &str) -> Option<&Value>
pub fn data_model(&self, surface_id: &str) -> Option<&Value>
A surface’s data model.
Sourcepub fn components(
&self,
surface_id: &str,
) -> Option<impl Iterator<Item = &Value>>
pub fn components( &self, surface_id: &str, ) -> Option<impl Iterator<Item = &Value>>
A surface’s components as the agent sent them (the latest of each id).
Sourcepub fn surface_metadata(&self, surface_id: &str) -> Option<&Value>
pub fn surface_metadata(&self, surface_id: &str) -> Option<&Value>
A surface’s metadata from createSurface (its extensions).
Sourcepub fn sends_data_model(&self, surface_id: &str) -> bool
pub fn sends_data_model(&self, surface_id: &str) -> bool
Whether the surface asked for its data model with every message.
Sourcepub fn snapshot(&self) -> Vec<Value>
pub fn snapshot(&self) -> Vec<Value>
Each surface as the one createSurface message that draws it as it is
now: its catalog, sendDataModel when set, its components (the latest of
each id, by id), and its data model. A renderer that reopens, or joins
late, can be brought up to date with these alone, in surface id order.
Sourcepub fn capabilities(&self, inline: bool) -> Value
pub fn capabilities(&self, inline: bool) -> Value
The renderer’s capabilities (renderer_capabilities.json): the ids of
its catalogs and, with inline, the catalog documents themselves.
Sourcepub fn renderer_data_model(&self) -> Option<Value>
pub fn renderer_data_model(&self) -> Option<Value>
The renderer data model to send with a message (renderer_data_model.json):
the surfaces that set sendDataModel, or None if none did.
Sourcepub fn apply(&mut self, messages: &[Value]) -> Report
pub fn apply(&mut self, messages: &[Value]) -> Report
Validate and apply a batch, all or nothing. See the module docs.
Sourcepub fn tree(&self, surface_id: &str) -> Option<Node>
pub fn tree(&self, surface_id: &str) -> Option<Node>
Resolve a surface for drawing, from its root (None when the
surface does not exist or has no root yet).
Sourcepub fn node(&self, surface_id: &str, component_id: &str) -> Option<Node>
pub fn node(&self, surface_id: &str, component_id: &str) -> Option<Node>
Resolve one component at the root data context, whether or not it is
reachable from root.
Sourcepub fn input(
&mut self,
surface_id: &str,
path: &str,
value: Value,
) -> Result<(), DataError>
pub fn input( &mut self, surface_id: &str, path: &str, value: Value, ) -> Result<(), DataError>
Write what the user entered at an absolute data model path (two-way binding): the input component’s bound path, resolved against its node’s data context.
Sourcepub fn dispatch(
&mut self,
action: &Value,
gesture: &Gesture,
) -> Result<Dispatch, ActionError>
pub fn dispatch( &mut self, action: &Value, gesture: &Gesture, ) -> Result<Dispatch, ActionError>
Run an action (a component’s action property, as sent) for a
gesture: an event becomes the action message to send, with its context
resolved; a function call runs locally, its data writes applied and its
other effects returned.