pub struct Actor { /* private fields */ }Expand description
A running machine and its invoked children (the WIT actor resource).
Callbacks run while the actor is borrowed: one that calls back into the
same actor gets an error.
Implementations§
Source§impl Actor
impl Actor
Sourcepub fn start(
env: Env,
definition: String,
options: String,
now: f64,
implementations: Option<Object<'_>>,
) -> Result<Self>
pub fn start( env: Env, definition: String, options: String, now: f64, implementations: Option<Object<'_>>, ) -> Result<Self>
Loads definition (MachineJSON) and starts it at now.
Sourcepub fn restore(
env: Env,
definition: String,
options: String,
snapshot: String,
implementations: Option<Object<'_>>,
) -> Result<Self>
pub fn restore( env: Env, definition: String, options: String, snapshot: String, implementations: Option<Object<'_>>, ) -> Result<Self>
Restores an actor from persist output with children, maxSteps
and observeSystemEmitted from the options; input and id are in
the snapshot and are an error here. Runs no actions.
Sourcepub fn send(&self, env: Env, event: String, now: f64) -> Result<()>
pub fn send(&self, env: Env, event: String, now: f64) -> Result<()>
Sends an event ({ "type": ..., ... }) to the root at now. When time
moved forward, due timers fire first.
Sourcepub fn send_to(
&self,
env: Env,
address: String,
event: String,
now: f64,
) -> Result<()>
pub fn send_to( &self, env: Env, address: String, event: String, now: f64, ) -> Result<()>
Sends an event to any actor in the system by address: the root’s is its
id, an invoked child’s is <parent address>/<invoke id>.
Sourcepub fn advance(&self, env: Env, now: f64) -> Result<()>
pub fn advance(&self, env: Env, now: f64) -> Result<()>
Fires every timer due at or before now.
Sourcepub fn snapshot(&self, env: Env) -> Result<String>
pub fn snapshot(&self, env: Env) -> Result<String>
The root’s snapshot: { "status", "value", "context", "output"?, "error"? }.
Sourcepub fn persist(&self, env: Env) -> Result<String>
pub fn persist(&self, env: Env) -> Result<String>
The whole system (XState’s SystemSnapshot shape), for restore.
Sourcepub fn take_emitted(&self, env: Env) -> Result<Vec<String>>
pub fn take_emitted(&self, env: Env) -> Result<Vec<String>>
Events the root emitted since the last call, oldest first.
Sourcepub fn observe_system_emitted(&self, env: Env) -> Result<()>
pub fn observe_system_emitted(&self, env: Env) -> Result<()>
Collects the events every actor in the system emits from now on, as
XState’s system.onEmitted.
Sourcepub fn unobserve_system_emitted(&self, env: Env) -> Result<()>
pub fn unobserve_system_emitted(&self, env: Env) -> Result<()>
Stops collecting them and drops those not taken.
Sourcepub fn take_system_emitted(&self, env: Env) -> Result<Vec<String>>
pub fn take_system_emitted(&self, env: Env) -> Result<Vec<String>>
Events every actor emitted since the last call, oldest first, as
{ "actor": { "@actor", "incarnation" }, "event": ... }.
Sourcepub fn take_logs(&self, env: Env) -> Result<Vec<String>>
pub fn take_logs(&self, env: Env) -> Result<Vec<String>>
Argument lists of the root’s @xstate.log actions since the last call.
Sourcepub fn pending_effects(&self, env: Env) -> Result<Vec<String>>
pub fn pending_effects(&self, env: Env) -> Result<Vec<String>>
External work waiting for the host (XState’s external effect data).
Trait Implementations§
Source§impl FromNapiMutRef for Actor
impl FromNapiMutRef for Actor
Source§unsafe fn from_napi_mut_ref(
env: napi_env,
napi_val: napi_value,
) -> Result<&'static mut Self>
unsafe fn from_napi_mut_ref( env: napi_env, napi_val: napi_value, ) -> Result<&'static mut Self>
Source§impl FromNapiRef for Actor
impl FromNapiRef for Actor
Source§unsafe fn from_napi_ref(
env: napi_env,
napi_val: napi_value,
) -> Result<&'static Self>
unsafe fn from_napi_ref( env: napi_env, napi_val: napi_value, ) -> Result<&'static Self>
Source§impl JavaScriptClassExt for Actor
impl JavaScriptClassExt for Actor
fn into_instance<'scope>( self, env: &'scope Env, ) -> Result<ClassInstance<'scope, Self>>
fn into_reference(self, env: Env) -> Result<Reference<Self>>
fn instance_of<'env, V: JsValue<'env>>(env: &Env, value: &V) -> Result<bool>
Source§impl ToNapiValue for Actor
impl ToNapiValue for Actor
Source§unsafe fn to_napi_value(env: napi_env, val: Actor) -> Result<napi_value>
unsafe fn to_napi_value(env: napi_env, val: Actor) -> Result<napi_value>
fn into_unknown(self, env: &Env) -> Result<Unknown<'_>, Error>
Source§impl TypeTag for Actor
impl TypeTag for Actor
Source§fn type_tag() -> napi_type_tag
fn type_tag() -> napi_type_tag
crate@version::module_path::ClassName),
which is fixed for a given class, so repeated calls return the same tag.