[−][src]Struct twilight_command_parser::config::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) -> Commands<'_>ⓘNotable traits for Commands<'a>
impl<'a> Iterator for Commands<'a> type Item = &'a CaseSensitivity;
[src]
Notable traits for Commands<'a>
impl<'a> Iterator for Commands<'a> type Item = &'a CaseSensitivity;
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]
Notable traits for CommandsMut<'a>
impl<'a> Iterator for CommandsMut<'a> type Item = &'a mut CaseSensitivity;
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<'_>ⓘ
[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]
Notable traits for PrefixesMut<'a>
impl<'a> Iterator for PrefixesMut<'a> type Item = &'a mut Cow<'a, str>;
Returns an iterator of mutable references to the prefixes.
pub fn add_command(
&mut self,
name: impl Into<String>,
case_sensitive: bool
) -> bool
[src]
&mut self,
name: impl Into<String>,
case_sensitive: bool
) -> bool
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]
&mut self,
prefix: impl Into<Cow<'a, str>>
) -> Option<Cow<'a, str>>
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]
pub fn clone(&self) -> CommandParserConfig<'a>
[src]
pub 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]
pub fn default() -> CommandParserConfig<'a>
[src]
Auto Trait Implementations
impl<'a> RefUnwindSafe for CommandParserConfig<'a>
[src]
impl<'a> Send for CommandParserConfig<'a>
[src]
impl<'a> Sync for CommandParserConfig<'a>
[src]
impl<'a> Unpin for CommandParserConfig<'a>
[src]
impl<'a> UnwindSafe for CommandParserConfig<'a>
[src]
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,
pub 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.
pub fn to_owned(&self) -> T
[src]
pub 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.
pub 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>,