updated plagin interface

This commit is contained in:
michael-bailey 2022-04-05 06:54:43 +01:00
parent 4f8b4ba13c
commit 80bd281cd8
1 changed files with 15 additions and 4 deletions

View File

@ -1,8 +1,19 @@
use std::sync::Arc;
type CreatePluginFn = dyn Fn() -> Arc<dyn Plugin>;
/// # GetPluginFn
/// This defines the type for getting the plugin struct from a
pub type GetPluginFn = fn() -> Arc<dyn Plugin>;
/// # Plugin
/// This trait defines an interface for plugins to implement.
///
/// ## Methods
/// - details: This returns the details about the plugin.
/// - init: This defines the initialisation routine for the.
/// - run: defines a routine to be ran like a thread.
#[async_trait::async_trait]
pub trait Plugin {
fn name(&self) -> String;
fn init(&self);
}
fn details(&self) -> PluginDetails;
fn init(self: &Arc<Self>);
async fn run(self: &Arc<Self>);
}