pub struct SimplePlugin {
pub load_count: usize,
pub unload_count: usize,
pub activate_count: usize,
pub deactivate_count: usize,
/* private fields */
}Expand description
A basic Plugin implementation useful for testing.
Tracks how many times each lifecycle hook has been called.
Fields§
§load_count: usizeNumber of times on_load has been called.
unload_count: usizeNumber of times on_unload has been called.
activate_count: usizeNumber of times on_activate has been called.
deactivate_count: usizeNumber of times on_deactivate has been called.
Implementations§
Source§impl SimplePlugin
impl SimplePlugin
Sourcepub fn new(name: impl Into<String>, version: impl Into<String>) -> Self
pub fn new(name: impl Into<String>, version: impl Into<String>) -> Self
Create a new simple plugin with the given name and version.
Sourcepub fn with_capability(self, cap: PluginCapability) -> Self
pub fn with_capability(self, cap: PluginCapability) -> Self
Add a capability.
Sourcepub fn with_dependency(self, dep: impl Into<String>) -> Self
pub fn with_dependency(self, dep: impl Into<String>) -> Self
Add a dependency.
Set the author.
Sourcepub fn with_description(self, desc: impl Into<String>) -> Self
pub fn with_description(self, desc: impl Into<String>) -> Self
Set the description.
Trait Implementations§
Source§impl Plugin for SimplePlugin
impl Plugin for SimplePlugin
Source§fn metadata(&self) -> &PluginMetadata
fn metadata(&self) -> &PluginMetadata
Returns a reference to the plugin’s metadata.
Source§fn on_load(&mut self) -> Result<()>
fn on_load(&mut self) -> Result<()>
Called when the plugin is loaded. Perform one-time initialisation here.
Source§fn on_unload(&mut self) -> Result<()>
fn on_unload(&mut self) -> Result<()>
Called when the plugin is being unloaded. Clean up resources here.
Source§fn on_activate(&mut self) -> Result<()>
fn on_activate(&mut self) -> Result<()>
Called when the plugin transitions to the active state.
Source§fn on_deactivate(&mut self) -> Result<()>
fn on_deactivate(&mut self) -> Result<()>
Called when the plugin transitions from active to deactivated.
Auto Trait Implementations§
impl Freeze for SimplePlugin
impl RefUnwindSafe for SimplePlugin
impl Send for SimplePlugin
impl Sync for SimplePlugin
impl Unpin for SimplePlugin
impl UnsafeUnpin for SimplePlugin
impl UnwindSafe for SimplePlugin
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