[−][src]Enum twitch_irc::message::ServerMessage
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)
ClearChat(ClearChatMessage)
CLEARCHAT
message
ClearMsg(ClearMsgMessage)
CLEARMSG
message
GlobalUserState(GlobalUserStateMessage)
GLOBALUSERSTATE
message
HostTarget(HostTargetMessage)
HOSTTARGET
message
Join(JoinMessage)
JOIN
message
Notice(NoticeMessage)
NOTICE
message
Part(PartMessage)
PART
message
Ping(PingMessage)
PING
message
Pong(PongMessage)
PONG
message
Privmsg(PrivmsgMessage)
PRIVMSG
message
Reconnect(ReconnectMessage)
RECONNECT
message
RoomState(RoomStateMessage)
ROOMSTATE
message
UserNotice(UserNoticeMessage)
USERNOTICE
message
USERSTATE
message
Whisper(WhisperMessage)
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]
fn format_as_raw_irc(&self, f: &mut Formatter<'_>) -> Result
[src]
fn as_raw_irc(&self) -> String where
Self: Sized,
[src]
Self: Sized,
impl Clone for ServerMessage
[src]
fn clone(&self) -> ServerMessage
[src]
fn clone_from(&mut self, source: &Self)
1.0.0[src]
impl Debug for ServerMessage
[src]
impl From<ServerMessage> for IRCMessage
[src]
fn from(msg: ServerMessage) -> IRCMessage
[src]
impl TryFrom<IRCMessage> for ServerMessage
[src]
type Error = ServerMessageParseError
The type returned in the event of a conversion error.
fn try_from(
source: IRCMessage
) -> Result<ServerMessage, ServerMessageParseError>
[src]
source: IRCMessage
) -> Result<ServerMessage, ServerMessageParseError>
Auto Trait Implementations
impl RefUnwindSafe for ServerMessage
impl Send for ServerMessage
impl Sync for ServerMessage
impl Unpin for ServerMessage
impl UnwindSafe for ServerMessage
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,
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> Same<T> for T
type Output = T
Should always be Self
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
fn to_owned(&self) -> T
[src]
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.
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>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
V: MultiLane<T>,