Enum Message

Source
pub enum Message<'a> {
Show 19 variants Ping, Pong, CapReq { req: &'a str, }, CapAck { req: &'a str, }, Pass { pass: &'a str, }, Nick { nick: &'a str, }, Join { chan: &'a str, }, Part { chan: &'a str, }, Privmsg { tags: Option<Tags<'a>>, chan: &'a str, msg: &'a str, }, Clearchat { tags: Option<Tags<'a>>, chan: &'a str, usr: Option<&'a str>, }, Clearmsg { tags: Option<Tags<'a>>, chan: &'a str, msg: &'a str, }, HosttargetStart { host: &'a str, chan: &'a str, view: Option<u32>, }, HosttargetEnd { host: &'a str, view: Option<u32>, }, Notice { tags: Option<Tags<'a>>, chan: &'a str, msg: &'a str, }, Reconnect, Roomstate { tags: Option<Tags<'a>>, chan: &'a str, }, Usernotice { tags: Option<Tags<'a>>, chan: &'a str, msg: &'a str, }, Userstate { tags: Option<Tags<'a>>, chan: &'a str, }, GlobalUserstate { tags: Option<Tags<'a>>, },
}
Expand description

Possible types of TMI messages. Unrecognized messages are handled by the associated [parse] function.

Tags are always treated as Optional even on messages that require them. Actually, tags validation should be done by the user code.

Consider changing simple enum structs to enum tuples.

Variants§

§

Ping

Represents a ping request message. PING :<endpoint>

§

Pong

Represents a pong response message. PONG :<endpoint>

§

CapReq

Represents a capability request message. CAP REQ :<capability>

Fields

§req: &'a str
§

CapAck

Represents a capability acknowledgement message. :<endpoint> CAP * ACK :<capability>

Fields

§req: &'a str
§

Pass

Represents a password authentication message. PASS <password> PASS oauth:<token> (using Twitch OAuth tokens)

Fields

§pass: &'a str
§

Nick

Represents a nickname authentication message. NICK <user>

Fields

§nick: &'a str
§

Join

Represents a join command message. JOIN #<channel>

Fields

§chan: &'a str
§

Part

Represents a part command message. PART #<channel>

Fields

§chan: &'a str
§

Privmsg

Represents a privmsg command message. [@<tags>] PRIVMSG #<channel> :<message>

Fields

§tags: Option<Tags<'a>>
§chan: &'a str
§msg: &'a str
§

Clearchat

Represents a clearchat command message. [@<tags>] :<endpoint> CLEARCHAT #<channel> [:<user>]

Fields

§tags: Option<Tags<'a>>
§chan: &'a str
§usr: Option<&'a str>
§

Clearmsg

Represents a clearmsg command message. [@<tags>] :<endpoint> CLEARMSG #<channel> [:<message>]

Fields

§tags: Option<Tags<'a>>
§chan: &'a str
§msg: &'a str
§

HosttargetStart

Represents a hosttarget start message. :<endpoint> HOSTTARGET #<host> :<channel> [<viewers>]

Fields

§host: &'a str
§chan: &'a str
§view: Option<u32>
§

HosttargetEnd

Represents a hosttarget end message. :<endpoint> HOSTTARGET #<host> :- [<viewers>]

Fields

§host: &'a str
§view: Option<u32>
§

Notice

Represents a notice message. [@<tags>] :<endpoint> NOTICE #<channel> :<message>

Fields

§tags: Option<Tags<'a>>
§chan: &'a str
§msg: &'a str
§

Reconnect

Represents a reconnect request message. RECONNECT

§

Roomstate

Represents a roomstate message. [@<tags>] :<endpoint> ROOMSTATE #<channel>

Fields

§tags: Option<Tags<'a>>
§chan: &'a str
§

Usernotice

Represents a usernotice message. [@<tags>] :<endpoint> USERNOTICE #<channel> :<message>

Fields

§tags: Option<Tags<'a>>
§chan: &'a str
§msg: &'a str
§

Userstate

Represents a userstate message. [@<tags>] :<endpoint> USERSTATE #<channel>

Fields

§tags: Option<Tags<'a>>
§chan: &'a str
§

GlobalUserstate

Represents a global userstate message. [@<tags>] :<endpoint> GLOBALUSERSTATE

Fields

§tags: Option<Tags<'a>>

Implementations§

Source§

impl<'a> Message<'a>

Source

pub fn parse(msg: &'a str) -> Result<Message<'_>>

Parses a [& str] slice and returns a Message if successful, otherwise an [io::Error].

§Examples
let s = ":tmi.twitch.tv CLEARCHAT #dallas :ronni";
let msg = tmi_parser::Message::parse(s);

Trait Implementations§

Source§

impl<'a> Debug for Message<'a>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<'a> PartialEq for Message<'a>

Source§

fn eq(&self, other: &Message<'a>) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<'a> StructuralPartialEq for Message<'a>

Auto Trait Implementations§

§

impl<'a> Freeze for Message<'a>

§

impl<'a> RefUnwindSafe for Message<'a>

§

impl<'a> Send for Message<'a>

§

impl<'a> Sync for Message<'a>

§

impl<'a> Unpin for Message<'a>

§

impl<'a> UnwindSafe for Message<'a>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.