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§
Sourcefn run_sync(&self, ctx: &mut TransitionContext) -> Result<(), ActionError>
fn run_sync(&self, ctx: &mut TransitionContext) -> Result<(), ActionError>
Execute the action synchronously. Called when is_sync() returns true.
Provided Methods§
Sourcefn run_async<'a>(
&'a self,
ctx: TransitionContext,
) -> Pin<Box<dyn Future<Output = Result<TransitionContext, ActionError>> + Send + 'a>>
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.