#[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
Custom
Fields
animated: bool
Whether the emoji is animated.
Unicode(String)
A reaction with a twemoji.
Implementations
sourceimpl ReactionType
impl ReactionType
sourcepub fn as_data(&self) -> String
Available on crate feature model
only.
pub fn as_data(&self) -> String
model
only.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.
sourcepub fn unicode_eq(&self, other: &str) -> bool
Available on crate feature model
only.
pub fn unicode_eq(&self, other: &str) -> bool
model
only.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.
sourcepub fn unicode_partial_cmp(&self, other: &str) -> Option<Ordering>
Available on crate feature model
only.
pub fn unicode_partial_cmp(&self, other: &str) -> Option<Ordering>
model
only.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
sourceimpl Clone for ReactionType
impl Clone for ReactionType
sourcefn clone(&self) -> ReactionType
fn clone(&self) -> ReactionType
Returns a copy of the value. Read more
1.0.0 · sourcefn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source
. Read more
sourceimpl Debug for ReactionType
impl Debug for ReactionType
sourceimpl<'de> Deserialize<'de> for ReactionType
impl<'de> Deserialize<'de> for ReactionType
sourcefn deserialize<D: Deserializer<'de>>(
deserializer: D
) -> StdResult<Self, D::Error>
fn deserialize<D: Deserializer<'de>>(
deserializer: D
) -> StdResult<Self, D::Error>
Deserialize this value from the given Serde deserializer. Read more
sourceimpl Display for ReactionType
impl Display for ReactionType
sourcefn fmt(&self, f: &mut Formatter<'_>) -> Result
fn fmt(&self, f: &mut Formatter<'_>) -> Result
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.
sourceimpl From<Emoji> for ReactionType
impl From<Emoji> for ReactionType
sourcefn from(emoji: Emoji) -> ReactionType
fn from(emoji: Emoji) -> ReactionType
Converts to this type from the input type.
sourceimpl From<EmojiId> for ReactionType
impl From<EmojiId> for ReactionType
sourcefn from(emoji_id: EmojiId) -> ReactionType
fn from(emoji_id: EmojiId) -> ReactionType
Converts to this type from the input type.
sourceimpl From<EmojiIdentifier> for ReactionType
impl From<EmojiIdentifier> for ReactionType
sourcefn from(emoji_id: EmojiIdentifier) -> ReactionType
fn from(emoji_id: EmojiIdentifier) -> ReactionType
Converts to this type from the input type.
sourceimpl From<char> for ReactionType
impl From<char> for ReactionType
sourcefn from(ch: char) -> ReactionType
fn from(ch: char) -> ReactionType
Creates a ReactionType
from a char
.
Examples
Reacting to a message with an apple:
message.react(ctx, '🍎').await?;
sourceimpl FromStr for ReactionType
impl FromStr for ReactionType
sourceimpl Hash for ReactionType
impl Hash for ReactionType
sourceimpl PartialEq<ReactionType> for ReactionType
impl PartialEq<ReactionType> for ReactionType
sourcefn eq(&self, other: &ReactionType) -> bool
fn eq(&self, other: &ReactionType) -> bool
This method tests for self
and other
values to be equal, and is used
by ==
. Read more
sourcefn ne(&self, other: &ReactionType) -> bool
fn ne(&self, other: &ReactionType) -> bool
This method tests for !=
.
sourceimpl Serialize for ReactionType
impl Serialize for ReactionType
sourceimpl<'a> TryFrom<&'a str> for ReactionType
impl<'a> TryFrom<&'a str> for ReactionType
type Error = ReactionConversionError
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);
sourceimpl TryFrom<String> for ReactionType
impl TryFrom<String> for ReactionType
impl Eq for ReactionType
impl StructuralEq for ReactionType
impl StructuralPartialEq for ReactionType
Auto Trait Implementations
impl RefUnwindSafe for ReactionType
impl Send for ReactionType
impl Sync for ReactionType
impl Unpin for ReactionType
impl UnwindSafe for ReactionType
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<Q, K> Equivalent<K> for Q where
Q: Eq + ?Sized,
K: Borrow<Q> + ?Sized,
impl<Q, K> Equivalent<K> for Q where
Q: Eq + ?Sized,
K: Borrow<Q> + ?Sized,
sourcefn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to key
and return true
if they are equal.
sourceimpl<F> FromStrAndCache for F where
F: FromStr,
impl<F> FromStrAndCache for F where
F: FromStr,
sourceimpl<T> Instrument for T
impl<T> Instrument for T
sourcefn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
sourcefn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
sourceimpl<T> ToOwned for T where
T: Clone,
impl<T> ToOwned for T where
T: Clone,
type Owned = T
type Owned = T
The resulting type after obtaining ownership.
sourcefn clone_into(&self, target: &mut T)
fn clone_into(&self, target: &mut T)
toowned_clone_into
)Uses borrowed data to replace owned data, usually by cloning. Read more
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
fn vzip(self) -> V
sourceimpl<T> WithSubscriber for T
impl<T> WithSubscriber for T
sourcefn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> where
S: Into<Dispatch>,
fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> where
S: Into<Dispatch>,
Attaches the provided Subscriber
to this type, returning a
WithDispatch
wrapper. Read more
sourcefn with_current_subscriber(self) -> WithDispatch<Self>
fn with_current_subscriber(self) -> WithDispatch<Self>
Attaches the current default Subscriber
to this type, returning a
WithDispatch
wrapper. Read more