Trait pircolate::command::Command
[−]
[src]
pub trait Command<'a> { fn name() -> &'static str; fn parse(arguments: ArgumentIter<'a>) -> Option<Self> where Self: Sized; fn try_match(command: &str, arguments: ArgumentIter<'a>) -> Option<Self> where Self: Sized { ... } }
The Command
trait is a trait that's implemented by types wishing to provide command
parsing capability for usage with the Message::command
method.
Required Methods
fn name() -> &'static str
Provides the name of the command to be matched. Examples include PRIVMSG
or PING
.
fn parse(arguments: ArgumentIter<'a>) -> Option<Self> where Self: Sized
This method takes in an iterator of arguments associated with a Message
and attempts
to parse the arguments into a matched Command
. If no match is found, None is returned.
Provided Methods
fn try_match(command: &str, arguments: ArgumentIter<'a>) -> Option<Self> where Self: Sized
A default implementation that takes in the given command name and arguments and attempts to match
the command and parse the arguments into a strongly typed representation. If there is no match
or the parse fails, it returns None
.