[−][src]Struct ellidri_tokens::Tag
A message tag.
Message tagging is an addition of an IRCv3 specification. Refer to the following page for more details on message tags: https://ircv3.net/specs/extensions/message-tags.
Fields
key: &'a str
The key of the tag.
value: Option<&'a str>
The value of the tag, or None
when the tag has no value.
Methods
impl<'a> Tag<'a>
[src]
pub fn parse(buf: &'a str) -> Self
[src]
Parse a message tag.
Example
let tag = Tag::parse("label=123456"); assert_eq!(tag.key, "label"); assert_eq!(tag.value, Some("123456"));
pub fn is_client(&self) -> bool
[src]
Whether the tag is a client-only tag.
Example
let msgid = Tag::parse("msgid=42"); let reply = Tag::parse("+example.pizza/beer"); assert_eq!(msgid.is_client(), false); assert_eq!(reply.is_client(), true);
pub fn unescape_value(&self) -> String
[src]
Returns the unescaped version of the tag's value.
Tag escaping is defined here: https://ircv3.net/specs/extensions/message-tags.html (look for "Escaping values").
Example
let label = Tag::parse(r"label=Newline:\s\nBackslash-n:\s\\n"); assert_eq!(&label.unescape_value(), "Newline: \nBackslash-n: \\n");
pub fn unescape_value_into(&self, buf: &mut String)
[src]
Appends the unescaped value of the tag to the given String.
If the string is already allocated and has enough space, then this function will not
allocate. It is therefore preferable to use it if you already have a String
. See
Tag::unescape_value
for doc about tag escaping.
Trait Implementations
impl<'a> Clone for Tag<'a>
[src]
impl<'a> Debug for Tag<'a>
[src]
impl<'a> PartialEq<Tag<'a>> for Tag<'a>
[src]
impl<'a> StructuralPartialEq for Tag<'a>
[src]
Auto Trait Implementations
impl<'a> RefUnwindSafe for Tag<'a>
impl<'a> Send for Tag<'a>
impl<'a> Sync for Tag<'a>
impl<'a> Unpin for Tag<'a>
impl<'a> UnwindSafe for Tag<'a>
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> 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>,