Struct twitch_message::Emote
source · pub struct Emote<'a> {
pub id: Cow<'a, str>,
pub name: Cow<'a, str>,
pub byte_pos: (usize, usize),
}
Expand description
An emote attached to a message
Fields§
§id: Cow<'a, str>
The id
of the emote (e.g. 25
for Kappa
)
name: Cow<'a, str>
The name
of the emote (e.g. Kappa
)
byte_pos: (usize, usize)
The byte position of the emote (name) in the provided data
Implementations§
source§impl<'a> Emote<'a>
impl<'a> Emote<'a>
Parse the emotes from tags and associated data
use twitch_message::{Tags, Emote};
use std::borrow::Cow;
let tags = Tags::builder().add("emotes", "25:0-4,14-18").finish();
let data = "Kappa testing Kappa";
let expected = [
Emote { id: Cow::from("25"), name: Cow::from("Kappa"), byte_pos: (0, 5) },
Emote { id: Cow::from("25"), name: Cow::from("Kappa"), byte_pos: (14, 19) },
];
for (i, emote) in Emote::from_tags(&tags, data).enumerate() {
assert_eq!(expected[i], emote);
}
See also
Parsing from a string, such as from tags.get("emotes")
, you can use parse_emotes
Trait Implementations§
source§impl<'de, 'a> Deserialize<'de> for Emote<'a>
impl<'de, 'a> Deserialize<'de> for Emote<'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> Ord for Emote<'a>
impl<'a> Ord for Emote<'a>
source§impl<'a> PartialEq<Emote<'a>> for Emote<'a>
impl<'a> PartialEq<Emote<'a>> for Emote<'a>
source§impl<'a> PartialOrd<Emote<'a>> for Emote<'a>
impl<'a> PartialOrd<Emote<'a>> for Emote<'a>
1.0.0 · source§fn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
This method tests less than or equal to (for
self
and other
) and is used by the <=
operator. Read more