Skip to main content

PluginSystem

Trait PluginSystem 

Source
pub trait PluginSystem {
    // Required methods
    fn initialize(&mut self) -> Result<()>;
    fn load_plugin(&mut self, path: &Path) -> Result<()>;
    fn run_hook(
        &mut self,
        event: HookEvent,
        ctx: &PluginContext,
    ) -> Result<HookResult>;
    fn run_command(&mut self, name: &str, args: &[String]) -> Result<i32>;
    fn register_api(&mut self) -> Result<()>;
    fn commands(&self) -> &HashMap<String, CustomCommand>;
}
Expand description

Trait for plugin system implementations.

This abstraction allows for potential future alternative runtimes while providing a consistent interface.

Required Methods§

Source

fn initialize(&mut self) -> Result<()>

Initialize the plugin system.

Source

fn load_plugin(&mut self, path: &Path) -> Result<()>

Load a plugin from a file path.

Source

fn run_hook( &mut self, event: HookEvent, ctx: &PluginContext, ) -> Result<HookResult>

Run hooks for an event.

Source

fn run_command(&mut self, name: &str, args: &[String]) -> Result<i32>

Run a custom command.

Source

fn register_api(&mut self) -> Result<()>

Register the hx API functions.

Source

fn commands(&self) -> &HashMap<String, CustomCommand>

Get registered custom commands.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§