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 start( env: Env, definition: String, options: String, now: f64, implementations: Option<Object<'_>>, ) -> Result<Self>

Loads definition (MachineJSON) and starts it at now.

Source

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.

Source

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.

Source

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>.

Source

pub fn advance(&self, env: Env, now: f64) -> Result<()>

Fires every timer due at or before now.

Source

pub fn next_deadline(&self, env: Env) -> Result<Option<f64>>

When the next timer is due.

Source

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

The root’s snapshot: { "status", "value", "context", "output"?, "error"? }.

Source

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

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

Source

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

Events the root emitted since the last call, oldest first.

Source

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.

Source

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

Stops collecting them and drops those not taken.

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": ... }.

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 pending_effects(&self, env: Env) -> Result<Vec<String>>

External work waiting for the host (XState’s external effect data).

Source

pub fn resolve_effect( &self, env: Env, id: String, event: Option<String>, ) -> Result<()>

Completes a pending effect, optionally with a result event.

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.