[][src]Struct duckscript::types::command::Commands

pub struct Commands {
    pub commands: HashMap<String, CommandBox>,
    pub aliases: HashMap<String, String>,
}

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

Methods

impl Commands[src]

pub fn new() -> Commands[src]

Creates and returns a new instance.

pub fn set(&mut self, command: CommandBox) -> Result<(), ScriptError>[src]

Adds a new command definition. It will fail in case another command already defined the same name/aliases

pub fn get(&self, name: &str) -> Option<&CommandBox>[src]

Return the command based on the given command name/alias

pub fn exists(&self, name: &str) -> bool[src]

Return true if the command based on the given command name/alias exists

pub fn get_for_use(&mut self, name: &str) -> Option<CommandBox>[src]

Return the command based on the given command name/alias. It will also remove it in the process.

pub fn get_all_command_names(&self) -> Vec<String>[src]

Returns all the command names currently registered

pub fn remove(&mut self, name: &str) -> bool[src]

Removes the requested command.

Trait Implementations

impl Clone for Commands[src]

Auto Trait Implementations

impl !RefUnwindSafe for Commands

impl !Send for Commands

impl !Sync for Commands

impl Unpin for Commands

impl !UnwindSafe for Commands

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.