pub trait Mechanic {
// Required method
fn enabled(&self) -> bool;
// Provided methods
fn cmds(&self) -> Vec<Command> { ... }
fn perms(&self) -> HashSet<String> { ... }
fn events(&self, _context: &Context) { ... }
fn register(&self, context: &Context) { ... }
}Expand description
A trait representing a plugin mechanic that can be enabled or disabled.
Mechanics may optionally expose commands, permission nodes, and event handlers,
all registered with the server via Mechanic::register.
Required Methods§
Provided Methods§
Sourcefn cmds(&self) -> Vec<Command>
fn cmds(&self) -> Vec<Command>
Returns the commands provided by this mechanic.
Each [Command] returned here will be registered with the server when
Mechanic::register is called. Returns an empty vec by default.
Sourcefn perms(&self) -> HashSet<String>
fn perms(&self) -> HashSet<String>
Returns the permission nodes required by this mechanic.
Permissions are paired with commands by index when registering. If there are fewer permissions than commands, remaining commands are registered without a permission requirement. Returns an empty set by default.
Sourcefn events(&self, _context: &Context)
fn events(&self, _context: &Context)
Registers event handlers for this mechanic.
Override this to call [Context::register_event_handler] for each event
this mechanic handles. No-op by default.
Sourcefn register(&self, context: &Context)
fn register(&self, context: &Context)
Registers this mechanic’s event handlers and commands with the server.
Calls Mechanic::events, then registers each command from
Mechanic::cmds paired with its corresponding permission from Mechanic::perms
by index. Commands without a paired permission use an empty permission string.