Skip to main content

Actor

Struct Actor 

Source
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

Source

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.

Source

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.

Source

pub fn persist(&self, env: Env) -> Result<String>

The whole system (XState’s SystemSnapshot shape), for Machine.restore.

Source

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.

Source

pub fn take_logs(&self, env: Env) -> Result<Vec<String>>

Argument lists of the root’s @xstate.log actions since the last call.

Source

pub fn stop(&self, env: Env) -> Result<()>

Stops the root and its children.

Trait Implementations§

Source§

impl FromNapiMutRef for Actor

Source§

unsafe fn from_napi_mut_ref( env: napi_env, napi_val: napi_value, ) -> Result<&'static mut Self>

This function called to convert napi values to native rust values Read more
Source§

impl FromNapiRef for Actor

Source§

unsafe fn from_napi_ref( env: napi_env, napi_val: napi_value, ) -> Result<&'static Self>

This function called to convert napi values to native rust values Read more
Source§

impl JavaScriptClassExt for Actor

Source§

fn into_instance<'scope>( self, env: &'scope Env, ) -> Result<ClassInstance<'scope, Self>>

Source§

fn into_reference(self, env: Env) -> Result<Reference<Self>>

Source§

fn instance_of<'env, V: JsValue<'env>>(env: &Env, value: &V) -> Result<bool>

Source§

impl ObjectFinalize for Actor

Source§

fn finalize(self, env: Env) -> Result<(), Error>

Source§

impl ToNapiValue for Actor

Source§

unsafe fn to_napi_value(env: napi_env, val: Actor) -> Result<napi_value>

This function called to convert rust values to napi values Read more
Source§

fn into_unknown(self, env: &Env) -> Result<Unknown<'_>, Error>

Source§

impl TypeName for Actor

Source§

impl TypeName for &Actor

Source§

impl TypeName for &mut Actor

Source§

impl TypeTag for Actor

Source§

fn type_tag() -> napi_type_tag

Returns this class’s stable per-type tag. The derive computes it from the class’s content identity string (crate@version::module_path::ClassName), which is fixed for a given class, so repeated calls return the same tag.
Source§

impl ValidateNapiValue for &Actor

Source§

unsafe fn validate(env: napi_env, napi_val: napi_value) -> Result<napi_value>

This function called to validate whether napi value passed to rust is valid type. Read more
Source§

impl ValidateNapiValue for &mut Actor

Source§

unsafe fn validate(env: napi_env, napi_val: napi_value) -> Result<napi_value>

This function called to validate whether napi value passed to rust is valid type. Read more

Auto Trait Implementations§

§

impl !Freeze for Actor

§

impl !RefUnwindSafe for Actor

§

impl !Sync for Actor

§

impl !UnwindSafe for Actor

§

impl Forget for Actor

§

impl Move for Actor

§

impl Send for Actor

§

impl Unpin for Actor
where Arc<Machine<Value, Value>>: Unpin, Arc<dyn Logic>: Unpin, *const u8 is !null: Unpin, Arc<Vec<(String, Arc<dyn Logic>)>>: Unpin, &'static str: Unpin, String: Unpin, Arc<str>: Unpin, Box<str>: Unpin, Box<Value>: Unpin, Box<dyn AnySnapshot>: Unpin, Arc<dyn Fn() -> Result<(), String> + Sync + Send>: Unpin, Box<SystemError>: Unpin, Box<Scratch>: Unpin, Box<Vec<(ActorRef, Value)>>: Unpin,

§

impl UnsafeUnpin for Actor

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> JsValuesTupleIntoVec for T
where T: ToNapiValue,

Source§

impl<T> MaybeTypeTag for T
where T: TypeTag,

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.