Struct twitch_message::messages::Message
source · 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>>where
Self: 'static,
T: TypedMessageMarker<'static>,
<T as TryFrom<Self>>::Error: Into<Self>,
pub fn into_typed_message<T>(
self
) -> Result<<T as IntoStatic>::Output, Message<'static>>where
Self: 'static,
T: TypedMessageMarker<'static>,
<T as TryFrom<Self>>::Error: Into<Self>,
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,
§type Output = Message<'static>
type Output = Message<'static>
Output of
IntoStatic::into_static
. Read moresource§fn into_static(self) -> Self::Output
fn into_static(self) -> Self::Output
This method casts
self
between Self<'a>
and Self<'static>
.