Struct twilight_command_parser::config::CommandParserConfig[][src]

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

Configuration for a Parser.

Implementations

Creates a fresh default configuration with no commands or prefixes.

Returns an iterator of immutable references to the commands.

Returns an iterator of mutable references to the commands.

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

Returns an iterator of immutable references to the prefixes.

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

Returns an iterator of mutable references to the prefixes.

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());

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);

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());

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

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Formats the value using the given formatter. Read more

Returns the “default value” for a type. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Performs the conversion.

Performs the conversion.

The resulting type after obtaining ownership.

Creates owned data from borrowed data, usually by cloning. Read more

🔬 This is a nightly-only experimental API. (toowned_clone_into)

recently added

Uses borrowed data to replace owned data, usually by cloning. Read more

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.