Skip to main content

Plugin

Trait Plugin 

Source
pub trait Plugin: Send + Sync {
    // Required methods
    fn name(&self) -> &str;
    fn commands(&self) -> Vec<CommandInfo>;
    fn handle(&self, ctx: CommandContext) -> BoxFuture<'_, Result<PluginResult>>;
}
Expand description

A plugin that handles one or more / commands.

Implement this trait and register it with PluginRegistry to add custom commands to a room broker. The broker dispatches matching Message::Command messages to the plugin’s handle method.

Required Methods§

Source

fn name(&self) -> &str

Unique identifier for this plugin (e.g. "stats", "help").

Source

fn commands(&self) -> Vec<CommandInfo>

Commands this plugin handles. Each entry drives /help output and TUI autocomplete.

Source

fn handle(&self, ctx: CommandContext) -> BoxFuture<'_, Result<PluginResult>>

Handle an invocation of one of this plugin’s commands.

Returns a boxed future for dyn compatibility (required because the registry stores Box<dyn Plugin>).

Implementors§