pub struct Message<'a> {
pub raw: Cow<'a, str>,
pub tags: Tags<'a>,
pub prefix: Prefix<'a>,
pub kind: MessageKind<'a>,
pub args: Vec<Cow<'a, str>>,
pub data: Option<Cow<'a, str>>,
}
Expand description
A twitch chat message.
See parse
Fields§
§raw: Cow<'a, str>
The raw underlying string
Metadata embedded in the message
prefix: Prefix<'a>
IRC-styled prefix
kind: MessageKind<'a>
The kind of message
args: Vec<Cow<'a, str>>
Arguments for the message kind
data: Option<Cow<'a, str>>
Data attached to the message
Implementations§
Source§impl<'a> Message<'a>where
'static: 'a,
impl<'a> Message<'a>where
'static: 'a,
Sourcepub fn as_typed_message<T>(&self) -> Option<T>where
T: TypedMessageMarker<'a>,
pub fn as_typed_message<T>(&self) -> Option<T>where
T: TypedMessageMarker<'a>,
Convert this message to a typed message.
§Examples
use twitch_message::messages::*;
let data = ":museun!museun@museun PRIVMSG #museun :hello world\r\n";
let message = twitch_message::parse(data)?.message;
let privmsg = message.as_typed_message::<Privmsg>().expect("invalid message");
Sourcepub fn as_enum(&self) -> TwitchMessage<'a>
pub fn as_enum(&self) -> TwitchMessage<'a>
Get this type as an enumeration of all possible types
Source§impl Message<'static>
impl Message<'static>
Sourcepub fn into_typed_message<T>(
self,
) -> Result<<T as IntoStatic>::Output, Message<'static>>
pub fn into_typed_message<T>( self, ) -> Result<<T as IntoStatic>::Output, Message<'static>>
Convert this message into an owned typed message.
§Examples
use twitch_message::messages::*;
let data = ":museun!museun@museun PRIVMSG #museun :hello world\r\n";
let message = twitch_message::parse(data)?.message;
let privmsg = message.into_typed_message::<Privmsg>().expect("invalid message");
Sourcepub fn into_enum(self) -> TwitchMessage<'static>
pub fn into_enum(self) -> TwitchMessage<'static>
Convert this type into an enumeration of all possible types
Trait Implementations§
Source§impl<'de, 'a> Deserialize<'de> for Message<'a>
impl<'de, 'a> Deserialize<'de> for Message<'a>
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Source§impl<'a, 'b: 'a> From<&'b Message<'a>> for TwitchMessage<'a>
impl<'a, 'b: 'a> From<&'b Message<'a>> for TwitchMessage<'a>
Source§impl<'a> From<Message<'a>> for TwitchMessage<'a>
impl<'a> From<Message<'a>> for TwitchMessage<'a>
Source§impl<'a> IntoStatic for Message<'a>where
'static: 'a,
impl<'a> IntoStatic for Message<'a>where
'static: 'a,
Source§fn into_static(self) -> Self::Output
fn into_static(self) -> Self::Output
This method casts
self
between Self<'a>
and Self<'static>
.Source§impl<'a, 'b> TryFrom<&'b Message<'a>> for Capability<'a>
impl<'a, 'b> TryFrom<&'b Message<'a>> for Capability<'a>
Source§impl<'a, 'b> TryFrom<&'b Message<'a>> for GlobalUserState<'a>
impl<'a, 'b> TryFrom<&'b Message<'a>> for GlobalUserState<'a>
Source§impl<'a, 'b> TryFrom<&'b Message<'a>> for HostTarget<'a>
impl<'a, 'b> TryFrom<&'b Message<'a>> for HostTarget<'a>
Source§impl<'a, 'b> TryFrom<&'b Message<'a>> for UserNotice<'a>
impl<'a, 'b> TryFrom<&'b Message<'a>> for UserNotice<'a>
Source§impl<'a> TryFrom<Message<'a>> for Capability<'a>
impl<'a> TryFrom<Message<'a>> for Capability<'a>
Source§impl<'a> TryFrom<Message<'a>> for GlobalUserState<'a>
impl<'a> TryFrom<Message<'a>> for GlobalUserState<'a>
Source§impl<'a> TryFrom<Message<'a>> for HostTarget<'a>
impl<'a> TryFrom<Message<'a>> for HostTarget<'a>
Source§impl<'a> TryFrom<Message<'a>> for UserNotice<'a>
impl<'a> TryFrom<Message<'a>> for UserNotice<'a>
impl<'a> Eq for Message<'a>
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> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more