[−][src]Struct twilight_command_parser::CommandParserConfig
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]
&'b mut self,
name: impl Into<String>
) -> CommandBuilder<'b, 'a>
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]
&mut self,
prefix: impl Into<Cow<'a, str>>
) -> Option<Cow<'a, str>>
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]
fn clone(&self) -> CommandParserConfig<'a>
[src]
fn clone_from(&mut self, source: &Self)
1.0.0[src]
impl<'a> Debug for CommandParserConfig<'a>
[src]
impl<'a> Default for CommandParserConfig<'a>
[src]
fn default() -> 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]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
fn to_owned(&self) -> T
[src]
fn clone_into(&self, target: &mut T)
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,