Skip to main content

Plugin

Trait Plugin 

Source
pub trait Plugin: Sized + 'static {
    // Provided methods
    fn install(self, env: &mut Environment) { ... }
    fn uninstall(self, env: &mut Environment) { ... }
}
Expand description

The Plugin trait defines the interface for components that can be installed into and removed from an Environment.

§Examples

use waterui_core::{plugin::Plugin, Environment};

struct MyPlugin;

impl Plugin for MyPlugin {
    // Plugins don't require any implementation-specific methods by default,
    // but you can override the `install` and `uninstall` methods if your plugin
    // needs custom installation or removal behavior.
    //
    // For example, a plugin might:
    // - Register event handlers
    // - Initialize resources
    // - Set up configurations
    // - Connect to external services
    //
    // The default implementation simply stores/removes the plugin
    // instance in the environment.
}

let mut env = Environment::new();
MyPlugin.install(&mut env);

Provided Methods§

Source

fn install(self, env: &mut Environment)

Installs this plugin into the provided environment.

This method adds the plugin instance to the environment’s storage, making it available for later retrieval.

§Arguments
  • env - A mutable reference to the environment
Source

fn uninstall(self, env: &mut Environment)

Removes this plugin from the provided environment.

§Arguments
  • env - A mutable reference to the environment

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§