Skip to main content

TransitionAction

Trait TransitionAction 

Source
pub trait TransitionAction: Send + Sync {
    // Required method
    fn run_sync(&self, ctx: &mut TransitionContext) -> Result<(), ActionError>;

    // Provided methods
    fn is_sync(&self) -> bool { ... }
    fn run_async<'a>(
        &'a self,
        ctx: TransitionContext,
    ) -> Pin<Box<dyn Future<Output = Result<TransitionContext, ActionError>> + Send + 'a>> { ... }
}
Expand description

The action executed when a transition fires.

Actions can be sync or async. Sync actions execute inline during the firing phase for maximum performance. Async actions are dispatched to the runtime.

Required Methods§

Source

fn run_sync(&self, ctx: &mut TransitionContext) -> Result<(), ActionError>

Execute the action synchronously. Called when is_sync() returns true.

Provided Methods§

Source

fn is_sync(&self) -> bool

Returns true if this action can execute synchronously.

Source

fn run_async<'a>( &'a self, ctx: TransitionContext, ) -> Pin<Box<dyn Future<Output = Result<TransitionContext, ActionError>> + Send + 'a>>

Execute the action asynchronously. Default implementation calls run_sync.

Implementors§