pub trait Task:
TaskInfo
+ Send
+ Sync {
// Required method
fn execution_mode(&self) -> TaskExecutionMode;
// Provided methods
fn start(
&self,
host: &Host,
context: &BlockingTaskRuntimeContext,
) -> Result<HostTaskResult, TaskError> { ... }
fn start_async<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
host: &'life1 Host,
context: &'life2 TaskRuntimeContext,
) -> Pin<Box<dyn Future<Output = Result<HostTaskResult, TaskError>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait { ... }
fn sub_tasks(&self) -> Vec<Arc<dyn Task>> { ... }
}Expand description
Core task interface required for execution.
§Example
use genja_core::genja_task;
use genja_core::task::{Task, TaskRuntimeContext};
struct MyTask;
#[genja_task(name = "my_task", connection_plugin_name = "ssh")]
impl MyTask {
async fn start_async(
&self,
_host: &genja_core::inventory::Host,
_context: &TaskRuntimeContext,
) -> Result<genja_core::task::HostTaskResult, genja_core::task::TaskError> {
Ok(genja_core::task::HostTaskResult::passed(
genja_core::task::TaskSuccess::new(),
))
}
}Required Methods§
Sourcefn execution_mode(&self) -> TaskExecutionMode
fn execution_mode(&self) -> TaskExecutionMode
Declare how the runtime should execute this task.
Provided Methods§
Sourcefn start(
&self,
host: &Host,
context: &BlockingTaskRuntimeContext,
) -> Result<HostTaskResult, TaskError>
fn start( &self, host: &Host, context: &BlockingTaskRuntimeContext, ) -> Result<HostTaskResult, TaskError>
Start executing a blocking task with runtime execution context.
Sourcefn start_async<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
host: &'life1 Host,
context: &'life2 TaskRuntimeContext,
) -> Pin<Box<dyn Future<Output = Result<HostTaskResult, TaskError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
fn start_async<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
host: &'life1 Host,
context: &'life2 TaskRuntimeContext,
) -> Pin<Box<dyn Future<Output = Result<HostTaskResult, TaskError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Start executing an async task with runtime execution context.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".