pub trait ScriptContext {
// Required methods
fn get(&self, name: &str) -> Option<ScriptValue>;
fn set(&mut self, name: &str, value: ScriptValue);
fn array_push(&mut self, name: &str, value: ScriptValue);
fn array_clear(&mut self, name: &str);
// Provided method
fn entity(&self, entity_id: &str, name: &str) -> Option<ScriptValue> { ... }
}Expand description
Backend-agnostic facade exposing the reactive property store to
script hosts. Mirrors QML’s QQmlContext::setContextProperty /
contextProperty() shape: scripts read + write through a thin layer
the host keeps internally so callers don’t have to thread an
Engine or a per-backend Dynamic type through.
Concrete impls own the underlying signal store. The trait is intentionally small:
every method maps to one host-side write so backends can rebuild
their internal mirror without re-implementing scalar/array policy
on top of Dynamic.
Required Methods§
Sourcefn get(&self, name: &str) -> Option<ScriptValue>
fn get(&self, name: &str) -> Option<ScriptValue>
Read a named scalar / structured property. None => the property
has never been written.
Sourcefn set(&mut self, name: &str, value: ScriptValue)
fn set(&mut self, name: &str, value: ScriptValue)
Write a named scalar / structured property. The backend mirrors
the write into its native value type and queues a stringified
SetSignal for the ECS-side Signals resource.
Sourcefn array_push(&mut self, name: &str, value: ScriptValue)
fn array_push(&mut self, name: &str, value: ScriptValue)
Append value onto the named array property. Lazy-initialises
the array if absent. Drives <for each="<name>"> reconciliation.
Sourcefn array_clear(&mut self, name: &str)
fn array_clear(&mut self, name: &str)
Clear the named array property (set to empty).