pub struct CommandRegistry { /* private fields */ }Expand description
Registry of slash commands.
Implementations§
Source§impl CommandRegistry
impl CommandRegistry
Sourcepub fn register(&mut self, cmd: Command) -> Result<(), AppError>
pub fn register(&mut self, cmd: Command) -> Result<(), AppError>
Register a command. Returns an error if the name is empty. Overwrites any existing command with the same name.
Sourcepub fn get(&self, name: &str) -> Option<&Command>
pub fn get(&self, name: &str) -> Option<&Command>
Look up a command by name (without the leading /).
Sourcepub fn list(&self) -> Vec<&Command>
pub fn list(&self) -> Vec<&Command>
Return all registered commands (sorted by name for deterministic output).
Sourcepub fn is_command(input: &str) -> bool
pub fn is_command(input: &str) -> bool
Check whether the input looks like a slash command.
Trait Implementations§
Auto Trait Implementations§
impl !RefUnwindSafe for CommandRegistry
impl !UnwindSafe for CommandRegistry
impl Freeze for CommandRegistry
impl Send for CommandRegistry
impl Sync for CommandRegistry
impl Unpin for CommandRegistry
impl UnsafeUnpin for CommandRegistry
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more