updated plugin trait implementation

This commit is contained in:
michael-bailey 2022-04-06 22:49:44 +01:00
parent f2be134720
commit cd19788959
2 changed files with 24 additions and 3 deletions

View File

@ -1,3 +1,4 @@
use crate::plugin::plugin_details::PluginDetails;
use std::sync::Arc;
/// # GetPluginFn
@ -12,8 +13,8 @@ pub type GetPluginFn = fn() -> Arc<dyn 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 {
pub trait Plugin: Send + Sync {
fn details(&self) -> PluginDetails;
fn init(self: &Arc<Self>);
async fn run(self: &Arc<Self>);
fn init(&self);
async fn run(&self);
}

View File

@ -0,0 +1,20 @@
use crate::plugin::plugin_details::PluginDetails;
use std::sync::Arc;
/// # 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: Send + Sync {
fn details(&self) -> PluginDetails;
fn init(&self);
async fn run(&self);
}