Skip to main content

ExprArgs

Struct ExprArgs 

Source
pub struct ExprArgs<'a, C, E> {
    pub context: &'a C,
    pub event: &'a Ev<E>,
    pub params: Option<&'a Value>,
    pub input: Option<&'a Value>,
    /* private fields */
}
Expand description

What an expression sees (XState’s evaluator scope): the context as the actions before it left it, the event, the params of the named JSON action or guard it is part of, and the active configuration.

Fields§

§context: &'a C§event: &'a Ev<E>§params: Option<&'a Value>

The resolved params of the enclosing named action or guard defined in the JSON (actions / guards at the root), if any.

§input: Option<&'a Value>

The state input (XState’s state input) of the state whose action, output or invoke this is, or of a transition’s source state.

Implementations§

Source§

impl<C: Serialize, E: EventType> ExprArgs<'_, C, E>

Source

pub fn scope_json(&self) -> Result<Value, String>

XState’s evaluator scope as JSON, for evaluators in other runtimes: { "context", "event", "input"?, "params"?, "self", "parent"?, "children"? } (actor references as { "@actor", "incarnation" }).

Source§

impl<C, E> ExprArgs<'_, C, E>

Source

pub fn children(&self) -> &IndexMap<String, ActorRef, FixedState>

The actor’s children by id (XState’s children).

Source

pub fn self_ref(&self) -> ActorRef

The actor itself (XState’s self).

Source

pub fn parent_ref(&self) -> Option<ActorRef>

The actor’s parent (XState’s self._parent); None for the root.

Source

pub fn fail(&self, message: impl Into<String>)

Fails the step with message once the expression returns, as an exception thrown by XState’s evaluator does (the first failure wins).

Source

pub fn in_state(&self, id: &str) -> bool

Whether the state with this id (with or without a leading #) is active, like snapshot.matches('#id').

Source

pub fn enq(&self) -> Option<&Enq<'_>>

XState’s enq, for expressions that are actions or transitions (in other places XState’s scope has none).

Auto Trait Implementations§

§

impl<'a, C, E> !RefUnwindSafe for ExprArgs<'a, C, E>

§

impl<'a, C, E> !Send for ExprArgs<'a, C, E>

§

impl<'a, C, E> !Sync for ExprArgs<'a, C, E>

§

impl<'a, C, E> !UnwindSafe for ExprArgs<'a, C, E>

§

impl<'a, C, E> Forget for ExprArgs<'a, C, E>

§

impl<'a, C, E> Freeze for ExprArgs<'a, C, E>
where &'a C: Freeze, &'a Ev<E>: Freeze, &'a Value: Freeze, &'a Machine<C, E>: Freeze, &'a [u32]: Freeze, &'a Enq<'a>: Freeze, &'a IndexMap<String, ActorRef, BuildHasherDefault<DefaultHasher>>: Freeze, &'a dyn SelfRefs: Freeze, &'a RefCell<Option<String>>: Freeze,

§

impl<'a, C, E> Move for ExprArgs<'a, C, E>

§

impl<'a, C, E> Unpin for ExprArgs<'a, C, E>
where &'a C: Unpin, &'a Ev<E>: Unpin, &'a Value: Unpin, &'a Machine<C, E>: Unpin, &'a [u32]: Unpin, &'a Enq<'a>: Unpin, &'a IndexMap<String, ActorRef, BuildHasherDefault<DefaultHasher>>: Unpin, &'a dyn SelfRefs: Unpin, &'a RefCell<Option<String>>: Unpin,

§

impl<'a, C, E> UnsafeUnpin for ExprArgs<'a, C, E>

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