[][src]Struct twilight_command_parser::CommandParserConfig

pub struct CommandParserConfig<'a> { /* fields omitted */ }

Configuration for a Parser.

Implementations

impl<'a> CommandParserConfig<'a>[src]

pub fn new() -> Self[src]

Creates a fresh default configuration with no commands or prefixes.

pub fn commands(&self) -> &HashSet<CaseSensitivity>[src]

Returns an immutable reference to the commands.

pub fn commands_mut(&mut self) -> &mut HashSet<CaseSensitivity>[src]

Returns a mutable reference to the commands.

Use the add_command and remove_command methods for an easier way to manage commands.

pub fn prefixes(&self) -> &HashMap<Cow<str>, Cow<str>>[src]

Returns an immutable reference to the prefixes.

Use the add_prefix and remove_prefix methods for an easier way to manage prefixes.

pub fn prefixes_mut(&mut self) -> &mut HashMap<Cow<'a, str>, Cow<'a, str>>[src]

Returns a mutable reference to the prefixes.

pub fn command<'b>(
    &'b mut self,
    name: impl Into<String>
) -> CommandBuilder<'b, 'a>
[src]

Returns a CommandBuilder which can be used to add a command to the list of commands.

Examples

use twilight_command_parser::CommandParserConfig;

let mut config = CommandParserConfig::new();
config.command("ping").add();
assert_eq!(1, config.commands().len());

pub fn remove_command(&mut self, command: impl AsRef<str>)[src]

Removes a command from the list of commands.

Any commands that would match the command provided are removed.

Examples

use twilight_command_parser::CommandParserConfig;

let mut config = CommandParserConfig::new();
config.command("ping").case_sensitive().add();
config.command("PING").add();
assert_eq!(2, config.commands().len());

// Now remove it and verify that there are no commands.
config.remove_command("ping");
assert!(config.commands().is_empty());

pub fn add_prefix(&mut self, prefix: impl Into<Cow<'a, str>>)[src]

Adds a prefix to the list of prefixes.

Examples

use twilight_command_parser::CommandParserConfig;

let mut config = CommandParserConfig::new();
config.add_prefix("!");
assert_eq!(1, config.prefixes().len());

pub fn remove_prefix(
    &mut self,
    prefix: impl Into<Cow<'a, str>>
) -> Option<Cow<'a, str>>
[src]

Removes a prefix from the list of prefixes.

Examples

use twilight_command_parser::CommandParserConfig;

let mut config = CommandParserConfig::new();
config.add_prefix("!");
config.add_prefix("~");
assert_eq!(2, config.prefixes().len());

// Now remove one and verify that there is only 1 prefix.
config.remove_prefix("!");
assert_eq!(1, config.prefixes().len());

Trait Implementations

impl<'a> Clone for CommandParserConfig<'a>[src]

impl<'a> Debug for CommandParserConfig<'a>[src]

impl<'a> Default for CommandParserConfig<'a>[src]

Auto Trait Implementations

impl<'a> RefUnwindSafe for CommandParserConfig<'a>

impl<'a> Send for CommandParserConfig<'a>

impl<'a> Sync for CommandParserConfig<'a>

impl<'a> Unpin for CommandParserConfig<'a>

impl<'a> UnwindSafe for CommandParserConfig<'a>

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.