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§
Sourcefn initialize(&mut self) -> Result<()>
fn initialize(&mut self) -> Result<()>
Initialize the plugin system.
Sourcefn load_plugin(&mut self, path: &Path) -> Result<()>
fn load_plugin(&mut self, path: &Path) -> Result<()>
Load a plugin from a file path.
Sourcefn run_hook(
&mut self,
event: HookEvent,
ctx: &PluginContext,
) -> Result<HookResult>
fn run_hook( &mut self, event: HookEvent, ctx: &PluginContext, ) -> Result<HookResult>
Run hooks for an event.
Sourcefn register_api(&mut self) -> Result<()>
fn register_api(&mut self) -> Result<()>
Register the hx API functions.
Sourcefn commands(&self) -> &HashMap<String, CustomCommand>
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".