[][src]Struct twilight_command_parser::config::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) -> Commands<'_>

Notable traits for Commands<'a>

impl<'a> Iterator for Commands<'a> type Item = &'a CaseSensitivity;
[src]

Returns an iterator of immutable references to the commands.

pub fn commands_mut(&mut self) -> CommandsMut<'_>

Notable traits for CommandsMut<'a>

impl<'a> Iterator for CommandsMut<'a> type Item = &'a mut CaseSensitivity;
[src]

Returns an iterator of mutable references to the commands.

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

pub fn prefixes(&self) -> Prefixes<'_>

Notable traits for Prefixes<'a>

impl<'a> Iterator for Prefixes<'a> type Item = &'a Cow<'a, str>;
[src]

Returns an iterator of immutable references to the prefixes.

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

pub fn prefixes_mut(&'a mut self) -> PrefixesMut<'a>

Notable traits for PrefixesMut<'a>

impl<'a> Iterator for PrefixesMut<'a> type Item = &'a mut Cow<'a, str>;
[src]

Returns an iterator of mutable references to the prefixes.

pub fn add_command(
    &mut self,
    name: impl Into<String>,
    case_sensitive: bool
) -> bool
[src]

Add a command to the list of commands.

Examples

Add a case-sensitive "ping" command:

use twilight_command_parser::CommandParserConfig;

let mut config = CommandParserConfig::new();
config.add_command("ping", true);
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.add_command("ping", true);
config.add_command("PING", false);
assert_eq!(2, config.commands().len());

// Now remove it and verify that there are no commands.
config.remove_command("ping");
assert_eq!(config.commands().len(), 0);

pub fn add_prefix(&mut self, prefix: impl Into<Cow<'a, str>>) -> bool[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.

Returns whether a prefix with the name was removed.

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

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.