[−][src]Struct twitchchat::twitch::Tags
Tags are IRCv3 message tags. Twitch uses them extensively.
Methods
impl<'a> Tags<&'a str>
[src]
impl<T: StringMarker> Tags<T>
[src]
pub fn get<K: ?Sized>(&self, key: &K) -> Option<&T> where
K: Borrow<str>,
[src]
K: Borrow<str>,
Tries to get the tag for this key
pub fn get_parsed<K: ?Sized, E>(&self, key: &K) -> Option<E> where
K: Borrow<str>,
E: FromStr,
[src]
K: Borrow<str>,
E: FromStr,
Tries to get the tag as a parsable [FromStr
] type.
This returns None if it cannot parse, or cannot find the tag
let input = "@foo=42;color=#1E90FF"; let tags = Tags::parse(input).unwrap(); // 'foo' can be parsed as a usize let answer: usize = tags.get_parsed("foo").unwrap(); assert_eq!(answer, 42); // 'foo' can be parsed a String (this shows how to use this with a 'turbofish') assert_eq!( tags.get_parsed::<_, String>("foo").unwrap(), "42".to_string() ); // 'foo' cannot be parsed as a bool assert!(tags.get_parsed::<_, bool>("foo").is_none()); // a non-std type with a FromStr impl let color: Color = tags.get_parsed("color").unwrap(); assert_eq!(color.rgb, RGB(0x1E, 0x90, 0xFF));
pub fn get_as_bool<K: ?Sized>(&self, key: &K) -> bool where
K: Borrow<str>,
[src]
K: Borrow<str>,
Tries to get the tag as a bool.
If it wasn't found it'll return false
let input = "@foo=42;ok=true;nope=false"; let tags = Tags::parse(input).unwrap(); // 'foo' is not a bool assert!(!tags.get_as_bool("foo")); // 'ok' is a bool and is true assert!(tags.get_as_bool("ok")); // 'nope' is a bool but its false assert!(!tags.get_as_bool("nope"));
pub fn iter(&self) -> impl Iterator<Item = (&T, &T)> + '_
[src]
Get an iterator over the key,value pairs in the tags
pub fn keys(&self) -> impl Iterator<Item = &T> + '_
[src]
Get an iterator over the keys in the tags
pub fn values(&self) -> impl Iterator<Item = &T> + '_
[src]
Get an iterator over the values in the tags
impl<T> Tags<T> where
T: StringMarker,
[src]
T: StringMarker,
pub fn into_inner(self) -> HashMap<T, T>
[src]
Take ownership of the inner HashMap
Trait Implementations
impl<T: StringMarker> Clone for Tags<T>
[src]
fn clone(&self) -> Self
[src]
fn clone_from(&mut self, source: &Self)
1.0.0[src]
impl<'a, T> Conversion<'a> for Tags<T> where
T: StringMarker + Conversion<'a>,
<T as Conversion<'a>>::Borrowed: StringMarker,
<T as Conversion<'a>>::Owned: StringMarker,
[src]
T: StringMarker + Conversion<'a>,
<T as Conversion<'a>>::Borrowed: StringMarker,
<T as Conversion<'a>>::Owned: StringMarker,
type Borrowed = Tags<T::Borrowed>
The borrowed type
type Owned = Tags<T::Owned>
The owned type
fn as_borrowed(&'a self) -> Self::Borrowed
[src]
fn as_owned(&self) -> Self::Owned
[src]
impl<T: StringMarker> Debug for Tags<T>
[src]
impl<T: StringMarker> Default for Tags<T>
[src]
impl<'de, T: StringMarker> Deserialize<'de> for Tags<T> where
T: Deserialize<'de>,
[src]
T: Deserialize<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error> where
__D: Deserializer<'de>,
[src]
__D: Deserializer<'de>,
impl<T: PartialEq + StringMarker> PartialEq<Tags<T>> for Tags<T>
[src]
impl<T: StringMarker> Serialize for Tags<T> where
T: Serialize,
[src]
T: Serialize,
fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error> where
__S: Serializer,
[src]
__S: Serializer,
impl<T: StringMarker> StructuralPartialEq for Tags<T>
[src]
Auto Trait Implementations
impl<T> RefUnwindSafe for Tags<T> where
T: RefUnwindSafe,
T: RefUnwindSafe,
impl<T> Send for Tags<T> where
T: Send,
T: Send,
impl<T> Sync for Tags<T> where
T: Sync,
T: Sync,
impl<T> Unpin for Tags<T> where
T: Unpin,
T: Unpin,
impl<T> UnwindSafe for Tags<T> where
T: UnwindSafe,
T: UnwindSafe,
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> DeserializeOwned for T where
T: Deserialize<'de>,
[src]
T: Deserialize<'de>,
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
fn to_owned(&self) -> T
[src]
fn clone_into(&self, target: &mut T)
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,