Trait barley_runtime::Action
source · 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§
sourcefn 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<'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.
sourcefn 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 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.
sourcefn 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 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.
sourcefn 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 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.
sourcefn add_dep(&mut self, action: Arc<dyn Action>)
fn add_dep(&mut self, action: Arc<dyn Action>)
requires insteadAdd a dependency to the action.
sourcefn requires(&mut self, action: Arc<dyn Action>)
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.
sourcefn display_name(&self) -> String
fn display_name(&self) -> String
Get the display name of the action.