pub trait Action: Send + Sync {
// Required method
fn run<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
in_channels: &'life1 mut InChannels,
out_channels: &'life2 mut OutChannels,
env: Arc<EnvVar>,
) -> Pin<Box<dyn Future<Output = Output> + Send + 'async_trait>>
where 'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Self: 'async_trait;
}Expand description
Node specific behavior
Action stores the specific execution logic of a task.
§Example
An implementation of Action: HelloAction, having private
fields statement and repeat.
use std::sync::Arc;
use dagrs::{Action, EnvVar, Output, InChannels, OutChannels};
use async_trait::async_trait;
struct HelloAction{
statement: String,
repeat: usize,
}
#[async_trait]
impl Action for HelloAction{
async fn run(&self, _: &mut InChannels, _: &mut OutChannels, _: Arc<EnvVar>) -> Output{
for i in 0..self.repeat {
println!("{}",self.statement);
}
Output::empty()
}
}
let hello=HelloAction {
statement: "hello world!".to_string(),
repeat: 10
};
Required Methods§
fn run<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
in_channels: &'life1 mut InChannels,
out_channels: &'life2 mut OutChannels,
env: Arc<EnvVar>,
) -> Pin<Box<dyn Future<Output = Output> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Self: 'async_trait,
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".