pub trait Automaton: Debug {
    fn initial_task(&self) -> Box<dyn Task>;

    fn initial_state(&self) -> State { ... }
    fn complete_task(&self) -> Box<dyn Task> { ... }
    fn execute<'life0, 'async_trait>(
        &'life0 self
    ) -> Pin<Box<dyn Future<Output = Result<State, Error>> + Send + 'async_trait>>
    where
        'life0: 'async_trait,
        Self: Sync + 'async_trait
, { ... } }
Expand description

Trait for automatons

Automatons execute a series of tasks. This trait defines the behavior that automatons must implement so that they can be executed inside a runtime.

Required Methods

Returns the first task in the automaton.

The initial task defines the entry point of the automaton. This task will be executed with the initial state.

Provided Methods

Returns the initial state for the execution.

Automatons can customize the state that is passed to the tasks. This can be useful to inject secrets or configuration on which tasks might depend. By default, an empty state is used.

Returns the task that is called after the completed transition.

When a tasks returns Transition::Complete to end the execution of the automaton, a final task is executed. This can be useful to perform any teardown actions, for example to remove resources that were created in a previous step. By default, a “noop” task is executed that performs no action.

Executes the automaton.

Automatons execute a series of tasks. When started, the automaton first initializes a new state. Then, it iterates over the list of tasks. It initializes and executes each task one by one until it either reaches the end of the list or a task returns Transition::Complete. In both instances, the task returned by the complete_task method is executed and the automaton shuts down.

Implementors