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 apply(&self, env: Env, batch: String) -> Result<String>
pub fn apply(&self, env: Env, batch: String) -> Result<String>
Applies a chunk of inputs, in order, as Actor::apply of
xmachines-runtime: a JSON array of the contract’s inputs, or one input
object. Returns the step’s JSON; an empty chunk, [], gives the
current step. A refused chunk throws, and
leaves the actor as it was: a rejection, of an event the root failed
on or one to a run that is over, an error whose code is
WORKFLOW_REJECTED and whose rejected is { "message", "data"? },
after which the run goes on; a fault an error whose code is the
contract’s. A time or work input that fails ends the run in error
instead, a step like any other.
Sourcepub fn can(&self, env: Env, event: String) -> Result<bool>
pub fn can(&self, env: Env, event: String) -> Result<bool>
Whether the root would select a transition for event (JSON text)
now, as kit-workflow’s can: XState’s !isUnhandled(transition(...)).
Any transition counts, an empty one and one that rejects the event
among them. Guards run; no action
runs and nothing changes. A guard that throws throws.
Sourcepub fn persist(&self, env: Env) -> Result<String>
pub fn persist(&self, env: Env) -> Result<String>
The whole system (XState’s SystemSnapshot shape), for
Machine.restore.
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": ... }; always empty
unless the machine was loaded with observeSystemEmitted.
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.