pub trait Action: Send + Sync {
    // Required methods
    fn check<'life0, 'async_trait>(
        &'life0 self,
        ctx: Arc<RwLock<Context>>
    ) -> Pin<Box<dyn Future<Output = Result<bool>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn check_deps<'life0, 'async_trait>(
        &'life0 self,
        ctx: Arc<RwLock<Context>>
    ) -> Pin<Box<dyn Future<Output = Result<bool>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn perform<'life0, 'async_trait>(
        &'life0 self,
        ctx: Arc<RwLock<Context>>
    ) -> Pin<Box<dyn Future<Output = Result<Option<ActionOutput>>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn rollback<'life0, 'async_trait>(
        &'life0 self,
        ctx: Arc<RwLock<Context>>
    ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn id(&self) -> Id;
    fn add_dep(&mut self, action: Arc<dyn Action>);
    fn requires(&mut self, action: Arc<dyn Action>);
    fn display_name(&self) -> String;
    fn deps(&self) -> Vec<Arc<dyn Action>>;
}
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, ctx: Arc<RwLock<Context>> ) -> Pin<Box<dyn Future<Output = Result<bool>> + 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 check_deps<'life0, 'async_trait>( &'life0 self, ctx: Arc<RwLock<Context>> ) -> Pin<Box<dyn Future<Output = Result<bool>> + Send + 'async_trait>>where Self: 'async_trait, 'life0: 'async_trait,

Check if the action’s dependencies need to be run.

This method is called internally, and should not be called directly. It is used to check if any of the action’s dependencies need to be run.

source

fn perform<'life0, 'async_trait>( &'life0 self, ctx: Arc<RwLock<Context>> ) -> Pin<Box<dyn Future<Output = Result<Option<ActionOutput>>> + Send + 'async_trait>>where Self: 'async_trait, 'life0: 'async_trait,

Run the action.

source

fn rollback<'life0, 'async_trait>( &'life0 self, ctx: Arc<RwLock<Context>> ) -> Pin<Box<dyn Future<Output = Result<()>> + 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 id(&self) -> Id

Get the action’s ID.

source

fn add_dep(&mut self, action: Arc<dyn Action>)

👎Deprecated since 0.2.0: Use requires instead

Add a dependency to the action.

source

fn requires(&mut self, action: Arc<dyn Action>)

Add a direct dependency to the action.

This action will not run until the dependency has been run. This behavior is 100% guaranteed by the engine.

source

fn display_name(&self) -> String

Get the display name of the action.

source

fn deps(&self) -> Vec<Arc<dyn Action>>

Get a list of dependencies.

This method is used internally, and should not be called directly. Dependencies are automatically handled by the engine.

Implementors§