pub struct Commands {
pub commands: HashMap<String, CommandBox>,
pub aliases: HashMap<String, String>,
}
Expand description
Holds and enables access to the runtime commands implementations
Fields§
§commands: HashMap<String, CommandBox>
mapping between command names to implementations
aliases: HashMap<String, String>
mapping between aliases to command names
Implementations§
Source§impl Commands
impl Commands
Sourcepub fn set(&mut self, command: CommandBox) -> Result<(), ScriptError>
pub fn set(&mut self, command: CommandBox) -> Result<(), ScriptError>
Adds a new command definition. It will fail in case another command already defined the same name/aliases
Sourcepub fn get(&self, name: &str) -> Option<&CommandBox>
pub fn get(&self, name: &str) -> Option<&CommandBox>
Return the command based on the given command name/alias
Sourcepub fn exists(&self, name: &str) -> bool
pub fn exists(&self, name: &str) -> bool
Return true if the command based on the given command name/alias exists
Sourcepub fn get_for_use(&mut self, name: &str) -> Option<CommandBox>
pub fn get_for_use(&mut self, name: &str) -> Option<CommandBox>
Return the command based on the given command name/alias. It will also remove it in the process.
Sourcepub fn get_all_command_names(&self) -> Vec<String>
pub fn get_all_command_names(&self) -> Vec<String>
Returns all the command names currently registered
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Commands
impl !RefUnwindSafe for Commands
impl !Send for Commands
impl !Sync for Commands
impl Unpin for Commands
impl !UnwindSafe for Commands
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