[][src]Enum twitch_irc::message::ServerMessage

#[non_exhaustive]pub enum ServerMessage {
    ClearChat(ClearChatMessage),
    ClearMsg(ClearMsgMessage),
    GlobalUserState(GlobalUserStateMessage),
    HostTarget(HostTargetMessage),
    Join(JoinMessage),
    Notice(NoticeMessage),
    Part(PartMessage),
    Ping(PingMessage),
    Pong(PongMessage),
    Privmsg(PrivmsgMessage),
    Reconnect(ReconnectMessage),
    RoomState(RoomStateMessage),
    UserNotice(UserNoticeMessage),
    UserState(UserStateMessage),
    Whisper(WhisperMessage),
    // some variants omitted
}

An IRCMessage that has been parsed into a more concrete type based on its command.

This type is non-exhausive, because more types of commands exist and can be added.

If you wish to (manually) parse a type of command that is not already parsed by this library, use IRCMessage::from to convert the ServerMessage back to an IRCMessage, then check the message's command and perform your parsing.

There is intentionally no generic Unparsed variant here. If there was, and the library added parsing for the command you were trying to catch by matching against the Unparsed variant, your code would be broken without any compiler error.

Examples

use twitch_irc::message::{IRCMessage, ServerMessage};
use std::convert::TryFrom;

let irc_message = IRCMessage::parse(":tmi.twitch.tv PING").unwrap();
let server_message = ServerMessage::try_from(irc_message).unwrap();

match server_message {
    // match against known types first
    ServerMessage::Ping { .. } => println!("Got pinged!"),
    rest => {
        // can do manual parsing here
        let irc_message = IRCMessage::from(rest);
        if irc_message.command == "CUSTOMCMD" {
             // ...
        }
    }
}

Variants (Non-exhaustive)

Non-exhaustive enums could have additional variants added in future. Therefore, when matching against variants of non-exhaustive enums, an extra wildcard arm must be added to account for any future variants.
ClearChat(ClearChatMessage)

CLEARCHAT message

ClearMsg(ClearMsgMessage)

CLEARMSG message

GlobalUserState(GlobalUserStateMessage)

GLOBALUSERSTATE message

HostTarget(HostTargetMessage)

HOSTTARGET message

JOIN message

NOTICE message

PART message

PING message

PONG message

PRIVMSG message

Reconnect(ReconnectMessage)

RECONNECT message

RoomState(RoomStateMessage)

ROOMSTATE message

UserNotice(UserNoticeMessage)

USERNOTICE message

UserState(UserStateMessage)

USERSTATE message

WHISPER message

Implementations

impl ServerMessage[src]

pub fn source(&self) -> &IRCMessage[src]

Get a reference to the IRCMessage this ServerMessage was parsed from.

Trait Implementations

impl AsRawIRC for ServerMessage[src]

impl Clone for ServerMessage[src]

impl Debug for ServerMessage[src]

impl From<ServerMessage> for IRCMessage[src]

impl TryFrom<IRCMessage> for ServerMessage[src]

type Error = ServerMessageParseError

The type returned in the event of a conversion error.

Auto Trait Implementations

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> Same<T> for T

type Output = T

Should always be Self

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

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.

impl<V, T> VZip<V> for T where
    V: MultiLane<T>,