[][src]Enum ellidri_tokens::Command

pub enum Command {
    Admin,
    Authenticate,
    Away,
    Cap,
    Info,
    Invite,
    Join,
    Kick,
    Kill,
    List,
    Lusers,
    Mode,
    Motd,
    Names,
    Nick,
    Notice,
    Oper,
    Part,
    Pass,
    Ping,
    Pong,
    PrivMsg,
    Quit,
    Rehash,
    SetName,
    TagMsg,
    Time,
    Topic,
    User,
    Version,
    Who,
    Whois,
    Reply(&'static str),
}

The list of known commands.

Unknown commands and replies are supported by Message directly, this enum just contains the supported commands.

Variants

Admin
Authenticate
Away
Cap
Info
Invite
Join
Kick
Kill
List
Lusers
Mode
Motd
Names
Nick
Notice
Oper
Part
Pass
Ping
Pong
PrivMsg
Quit
Rehash
SetName
TagMsg
Time
Topic
User
Version
Who
Whois
Reply(&'static str)

Methods

impl Command[src]

pub fn parse(s: &str) -> Option<Self>[src]

From a given command string, returns the corresponding command, or None otherwise.

It ignores the case of its argument.

Example

let join = Command::parse("join");
let join2 = Command::parse("JOIN");
let not_join = Command::parse("not_join");

assert_eq!(join, Some(Command::Join));
assert_eq!(join2, Some(Command::Join));
assert_eq!(not_join, None);

pub fn required_params(&self) -> usize[src]

Returns the number of required arguments for the command.

The command may accept more arguments.

Example

let privmsg = Command::parse("Privmsg").unwrap();
let topic = Command::parse("TOPIC").unwrap();

assert_eq!(privmsg.required_params(), 2);
assert_eq!(topic.required_params(), 1);

pub fn as_str(&self) -> &'static str[src]

Returns the command string. It is not the string that have been parsed.

Example

let quit = Command::parse("Quit").unwrap();

assert_eq!(quit.as_str(), "QUIT");

Trait Implementations

impl Clone for Command[src]

impl Copy for Command[src]

impl Debug for Command[src]

impl Display for Command[src]

impl From<&'static str> for Command[src]

fn from(reply: &'static str) -> Self[src]

&'static strs are converted to the Command::Reply variant.

This trait is used by Buffer to accept both Command and Reply when building messages.

impl PartialEq<Command> for Command[src]

impl StructuralPartialEq for Command[src]

Auto Trait Implementations

impl RefUnwindSafe for Command

impl Send for Command

impl Sync for Command

impl Unpin for Command

impl UnwindSafe for Command

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> ToString for T where
    T: Display + ?Sized
[src]

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.