Trait PluginLua

Source
pub trait PluginLua: Send + Sync {
    // Required methods
    fn name(&self) -> &str;
    fn on_load(&mut self) -> Result<(), Box<dyn Error>>;
    fn on_unload(&mut self) -> Result<(), Box<dyn Error>>;
    fn get_lua_functions(
        &self,
        lua: &Lua,
        name: &str,
    ) -> HashMap<String, Function>;
}
Expand description

Trait that all Lua plugins must implement.

Provides the required methods for plugin lifecycle management and Lua function registration.

Required Methods§

Source

fn name(&self) -> &str

Returns the name of the plugin.

Source

fn on_load(&mut self) -> Result<(), Box<dyn Error>>

Called when the plugin is loaded.

This method is used for initializing resources or performing setup tasks.

Source

fn on_unload(&mut self) -> Result<(), Box<dyn Error>>

Called when the plugin is unloaded.

This method allows the plugin to clean up resources before it is removed.

Source

fn get_lua_functions(&self, lua: &Lua, name: &str) -> HashMap<String, Function>

Returns a map of Lua functions to be registered with the Lua state.

Each function is associated with a name, allowing it to be called from Lua scripts.

Implementors§