pub enum PartialEmoji {
Custom {
id: EmojiId,
name: Option<CompactString>,
animated: bool,
},
Unicode {
name: CompactString,
},
}Expand description
An emoji as used in reactions, message components and polls: either a custom emoji or a Unicode emoji (D-056).
See the emoji object examples for standard and custom emojis.
discord.js counterpart: PartialEmoji / ReactionEmoji.
§Examples
use djs_model::emoji::PartialEmoji;
let fire: PartialEmoji = serde_json::from_str(r#"{"id":null,"name":"🔥"}"#)?;
assert_eq!(fire, PartialEmoji::Unicode { name: "🔥".into() });
let custom: PartialEmoji = serde_json::from_str(r#"{"id":"41771983429993937","name":"LUL","animated":true}"#)?;
assert!(matches!(custom, PartialEmoji::Custom { animated: true, .. }));
assert_eq!(custom.name(), Some("LUL"));Variants§
Custom
A custom (guild or application) emoji.
Fields
Unicode
A standard Unicode emoji such as 🔥.
Fields
§
name: CompactStringThe emoji itself.
Implementations§
Source§impl PartialEmoji
impl PartialEmoji
Trait Implementations§
Source§impl Clone for PartialEmoji
impl Clone for PartialEmoji
Source§impl Debug for PartialEmoji
impl Debug for PartialEmoji
Source§impl<'de> Deserialize<'de> for PartialEmoji
impl<'de> Deserialize<'de> for PartialEmoji
Source§fn deserialize<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error>
fn deserialize<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error>
Deserialize this value from the given Serde deserializer. Read more
impl Eq for PartialEmoji
Source§impl From<&Emoji> for PartialEmoji
impl From<&Emoji> for PartialEmoji
Source§impl Hash for PartialEmoji
impl Hash for PartialEmoji
Source§impl PartialEq for PartialEmoji
impl PartialEq for PartialEmoji
Source§impl Serialize for PartialEmoji
impl Serialize for PartialEmoji
impl StructuralPartialEq for PartialEmoji
Auto Trait Implementations§
impl Freeze for PartialEmoji
impl RefUnwindSafe for PartialEmoji
impl Send for PartialEmoji
impl Sync for PartialEmoji
impl Unpin for PartialEmoji
impl UnsafeUnpin for PartialEmoji
impl UnwindSafe for PartialEmoji
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more