Enum serenity::model::channel::ReactionType[][src]

#[non_exhaustive]
pub enum ReactionType {
    Custom {
        animated: bool,
        id: EmojiId,
        name: Option<String>,
    },
    Unicode(String),
}
Expand description

The type of a Reaction sent.

Variants (Non-exhaustive)

This enum is marked as 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.
Custom
Expand description

A reaction with a Guilds custom Emoji, which is unique to the guild.

Show fields

Fields of Custom

animated: bool
Expand description

Whether the emoji is animated.

id: EmojiId
Expand description

The Id of the custom Emoji.

name: Option<String>
Expand description

The name of the custom emoji. This is primarily used for decoration and distinguishing the emoji client-side.

Unicode(String)
Expand description

A reaction with a twemoji.

Implementations

impl ReactionType[src]

pub fn as_data(&self) -> String[src]

Creates a data-esque display of the type. This is not very useful for displaying, as the primary client can not render it, but can be useful for debugging.

Note: This is mainly for use internally. There is otherwise most likely little use for it.

pub fn unicode_eq(&self, other: &str) -> bool[src]

Helper function to allow testing equality of unicode emojis without having to perform any allocation. Will always return false if the reaction was not a unicode reaction.

pub fn unicode_partial_cmp(&self, other: &str) -> Option<Ordering>[src]

Helper function to allow comparing unicode emojis without having to perform any allocation. Will return None if the reaction was not a unicode reaction.

Trait Implementations

impl Clone for ReactionType[src]

fn clone(&self) -> ReactionType[src]

Returns a copy of the value. Read more

fn clone_from(&mut self, source: &Self)1.0.0[src]

Performs copy-assignment from source. Read more

impl Debug for ReactionType[src]

fn fmt(&self, f: &mut Formatter<'_>) -> Result[src]

Formats the value using the given formatter. Read more

impl<'de> Deserialize<'de> for ReactionType[src]

fn deserialize<D: Deserializer<'de>>(
    deserializer: D
) -> StdResult<Self, D::Error>
[src]

Deserialize this value from the given Serde deserializer. Read more

impl Display for ReactionType[src]

fn fmt(&self, f: &mut Formatter<'_>) -> FmtResult[src]

Formats the reaction type, displaying the associated emoji in a way that clients can understand.

If the type is a custom emoji, then refer to the documentation for emoji’s formatter on how this is displayed. Otherwise, if the type is a unicode, then the inner unicode is displayed.

impl From<Emoji> for ReactionType[src]

fn from(emoji: Emoji) -> ReactionType[src]

Performs the conversion.

impl From<EmojiId> for ReactionType[src]

fn from(emoji_id: EmojiId) -> ReactionType[src]

Performs the conversion.

impl From<EmojiIdentifier> for ReactionType[src]

fn from(emoji_id: EmojiIdentifier) -> ReactionType[src]

Performs the conversion.

impl From<char> for ReactionType[src]

fn from(ch: char) -> ReactionType[src]

Creates a ReactionType from a char.

Examples

Reacting to a message with an apple:

message.react(ctx, '🍎').await?;

impl FromStr for ReactionType[src]

type Err = ReactionConversionError

The associated error which can be returned from parsing.

fn from_str(s: &str) -> Result<Self, Self::Err>[src]

Parses a string s to return a value of this type. Read more

impl Hash for ReactionType[src]

fn hash<__H: Hasher>(&self, state: &mut __H)[src]

Feeds this value into the given Hasher. Read more

fn hash_slice<H>(data: &[Self], state: &mut H) where
    H: Hasher
1.3.0[src]

Feeds a slice of this type into the given Hasher. Read more

impl PartialEq<ReactionType> for ReactionType[src]

fn eq(&self, other: &ReactionType) -> bool[src]

This method tests for self and other values to be equal, and is used by ==. Read more

fn ne(&self, other: &ReactionType) -> bool[src]

This method tests for !=.

impl Serialize for ReactionType[src]

fn serialize<S>(&self, serializer: S) -> StdResult<S::Ok, S::Error> where
    S: Serializer
[src]

Serialize this value into the given Serde serializer. Read more

impl<'a> TryFrom<&'a str> for ReactionType[src]

type Error = ReactionConversionError

Creates a ReactionType from a string slice.

Examples

Creating a ReactionType from a 🍎, modeling a similar API as the rest of the library:

use std::convert::TryInto;
use std::fmt::Debug;

use serenity::model::channel::ReactionType;

fn foo<R: TryInto<ReactionType>>(bar: R)
where
    R::Error: Debug,
{
    println!("{:?}", bar.try_into().unwrap());
}

foo("🍎");

Creating a ReactionType from a custom emoji argument in the following format:

use std::convert::TryFrom;

use serenity::model::channel::ReactionType;
use serenity::model::id::EmojiId;

let emoji_string = "<:customemoji:600404340292059257>";
let reaction = ReactionType::try_from(emoji_string).unwrap();
let reaction2 = ReactionType::Custom {
    animated: false,
    id: EmojiId(600404340292059257),
    name: Some("customemoji".to_string()),
};

assert_eq!(reaction, reaction2);

fn try_from(emoji_str: &str) -> Result<Self, Self::Error>[src]

Performs the conversion.

impl TryFrom<String> for ReactionType[src]

type Error = ReactionConversionError

The type returned in the event of a conversion error.

fn try_from(emoji_string: String) -> Result<Self, Self::Error>[src]

Performs the conversion.

impl Eq for ReactionType[src]

impl StructuralEq for ReactionType[src]

impl StructuralPartialEq for ReactionType[src]

Auto Trait Implementations

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

pub fn type_id(&self) -> TypeId[src]

Gets the TypeId of self. Read more

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

pub fn borrow(&self) -> &T[src]

Immutably borrows from an owned value. Read more

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

pub fn borrow_mut(&mut self) -> &mut T[src]

Mutably borrows from an owned value. Read more

impl<Q, K> Equivalent<K> for Q where
    K: Borrow<Q> + ?Sized,
    Q: Eq + ?Sized
[src]

pub fn equivalent(&self, key: &K) -> bool[src]

Compare self to key and return true if they are equal.

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

pub fn from(t: T) -> T[src]

Performs the conversion.

impl<F> FromStrAndCache for F where
    F: FromStr
[src]

type Err = <F as FromStr>::Err

pub fn from_str<'life0, 'async_trait, CRL>(
    CRL,
    &'life0 str
) -> Pin<Box<dyn Future<Output = Result<F, <F as FromStrAndCache>::Err>> + 'async_trait + Send, Global>> where
    'life0: 'async_trait,
    F: 'async_trait,
    CRL: AsRef<Cache> + Send + Sync + 'async_trait, 
[src]

impl<T> Instrument for T[src]

fn instrument(self, span: Span) -> Instrumented<Self>[src]

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more

fn in_current_span(self) -> Instrumented<Self>[src]

Instruments this type with the current Span, returning an Instrumented wrapper. Read more

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

pub fn into(self) -> U[src]

Performs the conversion.

impl<T> Same<T> for T

type Output = T

Should always be Self

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

type Owned = T

The resulting type after obtaining ownership.

pub fn to_owned(&self) -> T[src]

Creates owned data from borrowed data, usually by cloning. Read more

pub fn clone_into(&self, target: &mut T)[src]

🔬 This is a nightly-only experimental API. (toowned_clone_into)

recently added

Uses borrowed data to replace owned data, usually by cloning. Read more

impl<T> ToString for T where
    T: Display + ?Sized
[src]

pub default fn to_string(&self) -> String[src]

Converts the given value to a String. Read more

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.

pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>[src]

Performs the conversion.

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.

pub fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>[src]

Performs the conversion.

impl<V, T> VZip<V> for T where
    V: MultiLane<T>, 

pub fn vzip(self) -> V

impl<T> DeserializeOwned for T where
    T: for<'de> Deserialize<'de>, 
[src]