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> PartialOrd for Emote<'a>
impl<'a> PartialOrd for Emote<'a>
impl<'a> Eq for Emote<'a>
impl<'a> StructuralPartialEq for Emote<'a>
Auto Trait Implementations§
impl<'a> Freeze for Emote<'a>
impl<'a> RefUnwindSafe for Emote<'a>
impl<'a> Send for Emote<'a>
impl<'a> Sync for Emote<'a>
impl<'a> Unpin for Emote<'a>
impl<'a> UnwindSafe for Emote<'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