Skip to main content

ActPlugin

Trait ActPlugin 

Source
pub trait ActPlugin: Send + Sync {
    // Required method
    fn on_init<'life0, 'life1, 'async_trait>(
        &'life0 self,
        engine: &'life1 Engine,
    ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
}
Expand description

Act plugin trait

§Example

use acts::{ActPlugin, Result, Engine, Workflow};
#[derive(Clone)]
struct TestPlugin;

impl TestPlugin {
    fn new() -> Self {
        Self
    }
}

#[async_trait::async_trait]
impl ActPlugin for TestPlugin {
    async fn on_init(&self, engine: &Engine) -> Result<()> {
        println!("TestPlugin");
        // engine.register_module("name", module);
        engine.channel().on_start(|e| {});
        engine.channel().on_complete(|e| {});
        engine.channel().on_message(|e| {});
        Ok(())
    }
}

Required Methods§

Source

fn on_init<'life0, 'life1, 'async_trait>( &'life0 self, engine: &'life1 Engine, ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Implementors§