pub struct PluginFactoryRegistry { /* private fields */ }Expand description
Registry of plugin factories keyed by kind name.
The host populates this before calling PluginManager::from_config().
Each factory knows how to create plugins of a specific kind.
§Examples
ⓘ
let mut factories = PluginFactoryRegistry::new();
factories.register("builtin/rate_limit", Box::new(RateLimiterFactory));
factories.register("builtin/identity", Box::new(IdentityFactory));
let manager = PluginManager::from_config(path, &factories)?;Implementations§
Source§impl PluginFactoryRegistry
impl PluginFactoryRegistry
Sourcepub fn register(
&mut self,
kind: impl Into<String>,
factory: Box<dyn PluginFactory>,
)
pub fn register( &mut self, kind: impl Into<String>, factory: Box<dyn PluginFactory>, )
Register a factory for a given kind name.
Registration is last-writer-wins: re-registering an existing kind
overrides it (this is intentional — a host can swap a builtin’s impl).
Because silent override is a footgun, a warning is logged when an
existing registration is replaced.
Sourcepub fn get(&self, kind: &str) -> Option<&dyn PluginFactory>
pub fn get(&self, kind: &str) -> Option<&dyn PluginFactory>
Look up a factory by kind name.
Trait Implementations§
Auto Trait Implementations§
impl !RefUnwindSafe for PluginFactoryRegistry
impl !UnwindSafe for PluginFactoryRegistry
impl Freeze for PluginFactoryRegistry
impl Send for PluginFactoryRegistry
impl Sync for PluginFactoryRegistry
impl Unpin for PluginFactoryRegistry
impl UnsafeUnpin for PluginFactoryRegistry
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more