pub trait Plugin: Send + Sync {
// Required methods
fn name(&self) -> &str;
fn handle(&self, ctx: CommandContext) -> BoxFuture<'_, Result<PluginResult>>;
// Provided methods
fn commands(&self) -> Vec<CommandInfo> { ... }
fn on_user_join(&self, _user: &str) { ... }
fn on_user_leave(&self, _user: &str) { ... }
}Expand description
A plugin that handles one or more / commands and/or reacts to room
lifecycle events.
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, and calls on_user_join /
on_user_leave when users enter or leave.
Only name and handle are required.
All other methods have no-op / empty-vec defaults so that adding new
lifecycle hooks in future releases does not break existing plugins.
Required Methods§
Sourcefn handle(&self, ctx: CommandContext) -> BoxFuture<'_, Result<PluginResult>>
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>).
Provided Methods§
Sourcefn commands(&self) -> Vec<CommandInfo>
fn commands(&self) -> Vec<CommandInfo>
Commands this plugin handles. Each entry drives /help output
and TUI autocomplete.
Defaults to an empty vec for plugins that only use lifecycle hooks and do not register any commands.
Sourcefn on_user_join(&self, _user: &str)
fn on_user_join(&self, _user: &str)
Called after a user joins the room. The default is a no-op.
Invoked synchronously during the join broadcast path. Implementations must not block — spawn a task if async work is needed.
Sourcefn on_user_leave(&self, _user: &str)
fn on_user_leave(&self, _user: &str)
Called after a user leaves the room. The default is a no-op.
Invoked synchronously during the leave broadcast path. Implementations must not block — spawn a task if async work is needed.