[][src]Enum twilight_mention::parse::MentionType

#[non_exhaustive]pub enum MentionType {
    Channel(ChannelId),
    Emoji(EmojiId),
    Role(RoleId),
    User(UserId),
}

Any type of mention.

Contains variants for every possible kind of mention. Can be used with ParseMention and iterated over just like any other mention.

Examples

Parse any type of mention out of a string:

use twilight_mention::parse::{MentionType, ParseMention};
use twilight_model::id::{ChannelId, RoleId, UserId};

assert_eq!(MentionType::Channel(ChannelId(123)), MentionType::parse("<#123>")?);
assert_eq!(MentionType::Role(RoleId(123)), MentionType::parse("<@&123>")?);
assert_eq!(MentionType::User(UserId(123)), MentionType::parse("<@!123>")?);

Iterate over all types of mentions in a buffer:

use twilight_mention::parse::{MentionType, ParseMention};
use twilight_model::id::{ChannelId, EmojiId, RoleId, UserId};

let buf = "channel <#12> emoji <:name:34> role <@&56> user <@78>";

let mut iter = MentionType::iter(buf);
assert!(matches!(iter.next(), Some((MentionType::Channel(ChannelId(12)), _, _))));
assert!(matches!(iter.next(), Some((MentionType::Emoji(EmojiId(34)), _, _))));
assert!(matches!(iter.next(), Some((MentionType::Role(RoleId(56)), _, _))));
assert!(matches!(iter.next(), Some((MentionType::User(UserId(78)), _, _))));
assert!(iter.next().is_none());

Variants (Non-exhaustive)

Non-exhaustive enums could have additional variants added in future. Therefore, when matching against variants of non-exhaustive enums, an extra wildcard arm must be added to account for any future variants.
Channel(ChannelId)

Channel mention.

Emoji(EmojiId)

Emoji mention.

Role(RoleId)

Role mention.

User(UserId)

User mention.

Trait Implementations

impl Clone for MentionType[src]

impl Copy for MentionType[src]

impl Debug for MentionType[src]

impl Display for MentionType[src]

impl Eq for MentionType[src]

impl ParseMention for MentionType[src]

pub const SIGILS: &'static [&'static str][src]

Sigils for any type of mention.

Contains all of the sigils of every other type of mention.

impl PartialEq<MentionType> for MentionType[src]

impl StructuralEq for MentionType[src]

impl StructuralPartialEq for MentionType[src]

Auto Trait Implementations

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> Instrument 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> ToString for T where
    T: Display + ?Sized
[src]

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.