Manager

Trait Manager 

Source
pub trait Manager<'a, O: Send + Sync, I: Info>: Send + Sync {
    // Required methods
    fn format(&self) -> &'static str;
    fn register_plugin(
        &mut self,
        _context: RegisterPluginContext<'_>,
    ) -> ManagerResult<I>;

    // Provided methods
    fn register_manager(&mut self) -> ManagerResult<()> { ... }
    fn unregister_manager(&mut self) -> ManagerResult<()> { ... }
    fn unregister_plugin(
        &mut self,
        _plugin: &Plugin<'a, O, I>,
    ) -> ManagerResult<()> { ... }
    fn load_plugin(
        &mut self,
        _context: LoadPluginContext<'a, '_, O, I>,
        _api: Api<O, I>,
    ) -> ManagerResult<()> { ... }
    fn unload_plugin(&mut self, _plugin: &Plugin<'a, O, I>) -> ManagerResult<()> { ... }
}
Expand description

Trait for implementing custom plugin managers.

A plugin manager is responsible for handling plugins of a specific format (e.g., Lua, Rust, WASM). It provides the interface between the Plux engine and the actual plugin execution environment.

§Type Parameters

  • 'a - Lifetime parameter for references within the manager
  • O - Output type for plugin functions (must implement Send + Sync)
  • I - Plugin information type (must implement Info trait)

§Example

use plux_rs::{Manager, LoadPluginContext, RegisterPluginContext, Api, Plugin, StdInfo, utils::ManagerResult, function::FunctionOutput};

struct MyManager;

impl<'a> Manager<'a, FunctionOutput, StdInfo> for MyManager {
    fn format(&self) -> &'static str {
        "my_format"
    }

    fn register_plugin(&mut self, context: RegisterPluginContext) -> ManagerResult<StdInfo> {
        // Implementation for registering a plugin
        Ok(StdInfo {
            depends: vec![],
            optional_depends: vec![],
        })
    }
}

Required Methods§

Source

fn format(&self) -> &'static str

Returns the file format/extension this manager handles (e.g., “lua”, “rs”, “wasm”).

This format is used to identify which manager should handle a particular plugin file.

Source

fn register_plugin( &mut self, _context: RegisterPluginContext<'_>, ) -> ManagerResult<I>

Registers a plugin with this manager.

This method is called when a plugin file matching this manager’s format is discovered. The manager should validate the plugin and return information about it.

§Parameters
  • context - Context containing plugin path and bundle information
§Returns

Returns ManagerResult<I> containing plugin information on success.

Provided Methods§

Source

fn register_manager(&mut self) -> ManagerResult<()>

Called when the manager is registered with the loader.

This is the place to perform any initialization required by the manager. Default implementation does nothing and returns Ok(()).

§Returns

Returns ManagerResult<()> indicating success or failure of manager registration.

Source

fn unregister_manager(&mut self) -> ManagerResult<()>

Called when the manager is unregistered from the loader.

This is the place to perform any cleanup required by the manager. Default implementation does nothing and returns Ok(()).

§Returns

Returns ManagerResult<()> indicating success or failure of manager unregistration.

Source

fn unregister_plugin(&mut self, _plugin: &Plugin<'a, O, I>) -> ManagerResult<()>

Unregisters a plugin from this manager.

This method is called when a plugin is being removed from the system. Default implementation does nothing and returns Ok(()).

§Parameters
  • plugin - Reference to the plugin being unregistered
§Returns

Returns ManagerResult<()> indicating success or failure of plugin unregistration.

Source

fn load_plugin( &mut self, _context: LoadPluginContext<'a, '_, O, I>, _api: Api<O, I>, ) -> ManagerResult<()>

Loads a plugin into the execution environment.

This method is called after plugin registration and is responsible for making the plugin available for execution. This typically involves loading the plugin code, registering functions, and setting up the execution context.

Default implementation does nothing and returns Ok(()).

§Parameters
  • context - Context containing plugin and loader information
  • api - API interface for interacting with the host application
§Returns

Returns ManagerResult<()> indicating success or failure of plugin loading.

Source

fn unload_plugin(&mut self, _plugin: &Plugin<'a, O, I>) -> ManagerResult<()>

Unloads a plugin from the execution environment.

This method is called when a plugin is being unloaded. It should clean up any resources associated with the plugin.

Default implementation does nothing and returns Ok(()).

§Parameters
  • plugin - Reference to the plugin being unloaded
§Returns

Returns ManagerResult<()> indicating success or failure of plugin unloading.

Trait Implementations§

Source§

impl<'a, O, OO, I, II> PartialEq<Box<dyn Manager<'a, O, I>>> for dyn Manager<'a, OO, II>
where O: Send + Sync, OO: Send + Sync, I: Info, II: Info,

Source§

fn eq(&self, other: &Box<dyn Manager<'a, O, I>>) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<'a, O, OO, I, II> PartialEq<dyn Manager<'a, OO, II>> for Box<dyn Manager<'a, O, I>>
where O: Send + Sync, OO: Send + Sync, I: Info, II: Info,

Source§

fn eq(&self, other: &dyn Manager<'a, OO, II>) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<'a, O: Send + Sync, I: Info> PartialEq for dyn Manager<'a, O, I>

Source§

fn eq(&self, other: &Self) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.

Implementors§