pub struct PluginRegistry { /* private fields */ }Expand description
Simple plugin registry that holds a list of plugins.
Implementations§
Source§impl PluginRegistry
impl PluginRegistry
Sourcepub fn register_box(&mut self, plugin: Box<dyn Plugin + Send + Sync>)
pub fn register_box(&mut self, plugin: Box<dyn Plugin + Send + Sync>)
Register a plugin that is already boxed.
Sourcepub fn iter(&self) -> impl Iterator<Item = &Box<dyn Plugin + Send + Sync>>
pub fn iter(&self) -> impl Iterator<Item = &Box<dyn Plugin + Send + Sync>>
Returns an iterator over the registered plugins.
Sourcepub fn load_from_dir<P: AsRef<Path>>(path: P) -> Result<Self, AgentError>
pub fn load_from_dir<P: AsRef<Path>>(path: P) -> Result<Self, AgentError>
Load plugins from a directory.
This implementation scans the given directory for shared library files
(.so on Linux, .dylib on macOS). Each library is expected to expose a
C‑compatible symbol named plugin_create with the signature:
unsafe extern "C" fn() -> *mut dyn PluginThe function should allocate a concrete type that implements Plugin and
return a raw pointer. The loader will convert the raw pointer into a
Box<dyn Plugin> and register it. The loaded library is deliberately
leaked (std::mem::forget) to keep it alive for the duration of the
program; a production implementation would store the Library handles
inside the registry to manage their lifetimes.