pub struct PluginRegistry { /* private fields */ }Expand description
Registry for managing plugins
The registry allows you to register, retrieve, and execute plugins.
§Examples
use unistructgen_core::PluginRegistry;
let mut registry = PluginRegistry::new();
// Register plugins
// registry.register(Box::new(my_plugin)).unwrap();
// Get a plugin
// let plugin = registry.get("my_plugin");Implementations§
Source§impl PluginRegistry
impl PluginRegistry
Sourcepub fn get(&self, name: &str) -> Option<&dyn Plugin>
pub fn get(&self, name: &str) -> Option<&dyn Plugin>
Get a reference to a plugin by name
§Examples
use unistructgen_core::PluginRegistry;
let registry = PluginRegistry::new();
let plugin = registry.get("my_plugin");
assert!(plugin.is_none());Sourcepub fn get_mut(&mut self, name: &str) -> Option<&mut dyn Plugin>
pub fn get_mut(&mut self, name: &str) -> Option<&mut dyn Plugin>
Get a mutable reference to a plugin by name
Sourcepub fn plugin_names(&self) -> Vec<&str>
pub fn plugin_names(&self) -> Vec<&str>
Get all registered plugin names
§Examples
use unistructgen_core::PluginRegistry;
let registry = PluginRegistry::new();
let names = registry.plugin_names();
assert_eq!(names.len(), 0);Sourcepub fn has_plugin(&self, name: &str) -> bool
pub fn has_plugin(&self, name: &str) -> bool
Check if a plugin is registered
Sourcepub fn remove(&mut self, name: &str) -> Option<Box<dyn Plugin>>
pub fn remove(&mut self, name: &str) -> Option<Box<dyn Plugin>>
Remove a plugin by name
§Examples
use unistructgen_core::PluginRegistry;
let mut registry = PluginRegistry::new();
let removed = registry.remove("my_plugin");
assert!(removed.is_none());Sourcepub fn before_parse(&mut self, input: String) -> Result<String, PluginError>
pub fn before_parse(&mut self, input: String) -> Result<String, PluginError>
Execute before_parse on all plugins
Plugins are executed in the order they were registered.
Sourcepub fn after_parse(&mut self, module: IRModule) -> Result<IRModule, PluginError>
pub fn after_parse(&mut self, module: IRModule) -> Result<IRModule, PluginError>
Execute after_parse on all plugins
Plugins are executed in the order they were registered.
Sourcepub fn after_generate(&mut self, code: String) -> Result<String, PluginError>
pub fn after_generate(&mut self, code: String) -> Result<String, PluginError>
Execute after_generate on all plugins
Plugins are executed in the order they were registered.
Sourcepub fn shutdown(&mut self) -> Result<(), PluginError>
pub fn shutdown(&mut self) -> Result<(), PluginError>
Shutdown all plugins
Trait Implementations§
Source§impl Default for PluginRegistry
impl Default for PluginRegistry
Auto Trait Implementations§
impl Freeze for PluginRegistry
impl !RefUnwindSafe for PluginRegistry
impl Send for PluginRegistry
impl Sync for PluginRegistry
impl Unpin for PluginRegistry
impl UnsafeUnpin for PluginRegistry
impl !UnwindSafe for PluginRegistry
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