pub trait Action: Send + Sync {
    // Required methods
    fn check<'life0, 'async_trait>(
        &'life0 self,
        runtime: Runtime
    ) -> Pin<Box<dyn Future<Output = Result<bool, ActionError>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn perform<'life0, 'async_trait>(
        &'life0 self,
        runtime: Runtime
    ) -> Pin<Box<dyn Future<Output = Result<Option<ActionOutput>, ActionError>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn rollback<'life0, 'async_trait>(
        &'life0 self,
        runtime: Runtime
    ) -> Pin<Box<dyn Future<Output = Result<(), ActionError>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn display_name(&self) -> String;
}
Expand description

A measurable, reversible task.

Any Action can test its environment to see if it needs to run at all, and can undo any changes it has made. Any Action can also depend on other Actions, and the engine will ensure that all dependencies are run before the Action itself.

Required Methods§

source

fn check<'life0, 'async_trait>( &'life0 self, runtime: Runtime ) -> Pin<Box<dyn Future<Output = Result<bool, ActionError>> + Send + 'async_trait>>where Self: 'async_trait, 'life0: 'async_trait,

Check if the action needs to be run.

This method is called before the action is run, and can be used to check if the action needs to run at all. If this method returns false, the action has not run yet, and the engine will proceed to run it. If this method returns true, the action has already run, and the engine will skip it.

source

fn perform<'life0, 'async_trait>( &'life0 self, runtime: Runtime ) -> Pin<Box<dyn Future<Output = Result<Option<ActionOutput>, ActionError>> + Send + 'async_trait>>where Self: 'async_trait, 'life0: 'async_trait,

Run the action.

source

fn rollback<'life0, 'async_trait>( &'life0 self, runtime: Runtime ) -> Pin<Box<dyn Future<Output = Result<(), ActionError>> + Send + 'async_trait>>where Self: 'async_trait, 'life0: 'async_trait,

Undo the action.

This is not currently possible, and will not do anything. This will be usable in a future version of Barley.

source

fn display_name(&self) -> String

Get the display name of the action.

Implementors§