[][src]Struct ellidri_tokens::Tag

pub struct Tag<'a> {
    pub key: &'a str,
    pub value: Option<&'a str>,
}

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]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.