[−][src]Enum twilight_mention::parse::MentionType
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]
pub fn clone(&self) -> MentionType
[src]
pub fn clone_from(&mut self, source: &Self)
1.0.0[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.
pub fn parse(buf: &str) -> Result<Self, ParseMentionError<'_>> where
Self: Sized,
[src]
Self: Sized,
#[must_use = "you must use the iterator to lazily parse mentions"]pub fn iter(buf: &str) -> MentionIter<'_, Self>ⓘNotable traits for MentionIter<'a, T>
impl<'a, T: ParseMention + Debug> Iterator for MentionIter<'a, T> type Item = (T, usize, usize);
where
Self: Sized,
[src]
Notable traits for MentionIter<'a, T>
impl<'a, T: ParseMention + Debug> Iterator for MentionIter<'a, T> type Item = (T, usize, usize);
Self: Sized,
impl PartialEq<MentionType> for MentionType
[src]
pub fn eq(&self, other: &MentionType) -> bool
[src]
pub fn ne(&self, other: &MentionType) -> bool
[src]
impl StructuralEq for MentionType
[src]
impl StructuralPartialEq for MentionType
[src]
Auto Trait Implementations
impl RefUnwindSafe for MentionType
[src]
impl Send for MentionType
[src]
impl Sync for MentionType
[src]
impl Unpin for MentionType
[src]
impl UnwindSafe for MentionType
[src]
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,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T> Instrument for T
[src]
pub fn instrument(self, span: Span) -> Instrumented<Self>
[src]
pub fn in_current_span(self) -> Instrumented<Self>
[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.
pub fn to_owned(&self) -> T
[src]
pub fn clone_into(&self, target: &mut T)
[src]
impl<T> ToString for T where
T: Display + ?Sized,
[src]
T: Display + ?Sized,
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.
pub 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>,