use crate::errors::*;
use crate::types::*;
use uuid::Uuid;
#[derive(Debug, Clone, Default, Serialize, Deserialize)]
pub struct AnimatedEmoji {
#[doc(hidden)]
#[serde(rename(serialize = "@type", deserialize = "@type"))]
td_name: String,
#[doc(hidden)]
#[serde(rename(serialize = "@extra", deserialize = "@extra"))]
extra: Option<String>,
sticker: Option<Sticker>,
sticker_width: i64,
sticker_height: i64,
fitzpatrick_type: i64,
sound: Option<File>,
is_regular_emoji: bool,
}
impl RObject for AnimatedEmoji {
#[doc(hidden)]
fn td_name(&self) -> &'static str {
"animatedEmoji"
}
#[doc(hidden)]
fn extra(&self) -> Option<String> {
self.extra.clone()
}
fn to_json(&self) -> RTDResult<String> {
Ok(serde_json::to_string(self)?)
}
}
impl AnimatedEmoji {
pub fn from_json<S: AsRef<str>>(json: S) -> RTDResult<Self> {
Ok(serde_json::from_str(json.as_ref())?)
}
pub fn builder() -> RTDAnimatedEmojiBuilder {
let inner = AnimatedEmoji {
td_name: "animatedEmoji".to_string(),
extra: Some(Uuid::new_v4().to_string()),
..Default::default()
};
RTDAnimatedEmojiBuilder { inner }
}
pub fn sticker(&self) -> &Option<Sticker> {
&self.sticker
}
pub fn sticker_width(&self) -> i64 {
self.sticker_width
}
pub fn sticker_height(&self) -> i64 {
self.sticker_height
}
pub fn fitzpatrick_type(&self) -> i64 {
self.fitzpatrick_type
}
pub fn sound(&self) -> &Option<File> {
&self.sound
}
pub fn is_regular_emoji(&self) -> bool {
self.is_regular_emoji
}
}
#[doc(hidden)]
pub struct RTDAnimatedEmojiBuilder {
inner: AnimatedEmoji,
}
impl RTDAnimatedEmojiBuilder {
pub fn build(&self) -> AnimatedEmoji {
self.inner.clone()
}
pub fn sticker<T: AsRef<Sticker>>(&mut self, sticker: T) -> &mut Self {
self.inner.sticker = Some(sticker.as_ref().clone());
self
}
pub fn sticker_width(&mut self, sticker_width: i64) -> &mut Self {
self.inner.sticker_width = sticker_width;
self
}
pub fn sticker_height(&mut self, sticker_height: i64) -> &mut Self {
self.inner.sticker_height = sticker_height;
self
}
pub fn fitzpatrick_type(&mut self, fitzpatrick_type: i64) -> &mut Self {
self.inner.fitzpatrick_type = fitzpatrick_type;
self
}
pub fn sound<T: AsRef<File>>(&mut self, sound: T) -> &mut Self {
self.inner.sound = Some(sound.as_ref().clone());
self
}
pub fn is_regular_emoji(&mut self, is_regular_emoji: bool) -> &mut Self {
self.inner.is_regular_emoji = is_regular_emoji;
self
}
}
impl AsRef<AnimatedEmoji> for AnimatedEmoji {
fn as_ref(&self) -> &AnimatedEmoji {
self
}
}
impl AsRef<AnimatedEmoji> for RTDAnimatedEmojiBuilder {
fn as_ref(&self) -> &AnimatedEmoji {
&self.inner
}
}