1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149

use crate::types::*;
use crate::errors::*;
use uuid::Uuid;




/// Describes a sticker
#[derive(Debug, Clone, Default, Serialize, Deserialize)]
pub struct Sticker {
  #[doc(hidden)]
  #[serde(rename(serialize = "@type", deserialize = "@type"))]
  td_name: String,
  #[doc(hidden)]
  #[serde(rename(serialize = "@extra", deserialize = "@extra"))]
  extra: Option<String>,
  /// The identifier of the sticker set to which the sticker belongs; 0 if none
  #[serde(deserialize_with = "serde_aux::field_attributes::deserialize_number_from_string")] set_id: isize,
  /// Sticker width; as defined by the sender
  width: i64,
  /// Sticker height; as defined by the sender
  height: i64,
  /// Emoji corresponding to the sticker
  emoji: String,
  /// True, if the sticker is an animated sticker in TGS format
  is_animated: bool,
  /// True, if the sticker is a mask
  is_mask: bool,
  /// Position where the mask should be placed; may be null
  mask_position: Option<MaskPosition>,
  /// Sticker thumbnail in WEBP or JPEG format; may be null
  thumbnail: Option<PhotoSize>,
  /// File containing the sticker
  sticker: File,
  
}

impl RObject for Sticker {
  #[doc(hidden)] fn td_name(&self) -> &'static str { "sticker" }
  #[doc(hidden)] fn extra(&self) -> Option<String> { self.extra.clone() }
  fn to_json(&self) -> RTDResult<String> { Ok(serde_json::to_string(self)?) }
}



impl Sticker {
  pub fn from_json<S: AsRef<str>>(json: S) -> RTDResult<Self> { Ok(serde_json::from_str(json.as_ref())?) }
  pub fn builder() -> RTDStickerBuilder {
    let mut inner = Sticker::default();
    inner.td_name = "sticker".to_string();
    inner.extra = Some(Uuid::new_v4().to_string());
    RTDStickerBuilder { inner }
  }

  pub fn set_id(&self) -> isize { self.set_id }

  pub fn width(&self) -> i64 { self.width }

  pub fn height(&self) -> i64 { self.height }

  pub fn emoji(&self) -> &String { &self.emoji }

  pub fn is_animated(&self) -> bool { self.is_animated }

  pub fn is_mask(&self) -> bool { self.is_mask }

  pub fn mask_position(&self) -> &Option<MaskPosition> { &self.mask_position }

  pub fn thumbnail(&self) -> &Option<PhotoSize> { &self.thumbnail }

  pub fn sticker(&self) -> &File { &self.sticker }

}

#[doc(hidden)]
pub struct RTDStickerBuilder {
  inner: Sticker
}

impl RTDStickerBuilder {
  pub fn build(&self) -> Sticker { self.inner.clone() }

   
  pub fn set_id(&mut self, set_id: isize) -> &mut Self {
    self.inner.set_id = set_id;
    self
  }

   
  pub fn width(&mut self, width: i64) -> &mut Self {
    self.inner.width = width;
    self
  }

   
  pub fn height(&mut self, height: i64) -> &mut Self {
    self.inner.height = height;
    self
  }

   
  pub fn emoji<T: AsRef<str>>(&mut self, emoji: T) -> &mut Self {
    self.inner.emoji = emoji.as_ref().to_string();
    self
  }

   
  pub fn is_animated(&mut self, is_animated: bool) -> &mut Self {
    self.inner.is_animated = is_animated;
    self
  }

   
  pub fn is_mask(&mut self, is_mask: bool) -> &mut Self {
    self.inner.is_mask = is_mask;
    self
  }

   
  pub fn mask_position<T: AsRef<MaskPosition>>(&mut self, mask_position: T) -> &mut Self {
    self.inner.mask_position = Some(mask_position.as_ref().clone());
    self
  }

   
  pub fn thumbnail<T: AsRef<PhotoSize>>(&mut self, thumbnail: T) -> &mut Self {
    self.inner.thumbnail = Some(thumbnail.as_ref().clone());
    self
  }

   
  pub fn sticker<T: AsRef<File>>(&mut self, sticker: T) -> &mut Self {
    self.inner.sticker = sticker.as_ref().clone();
    self
  }

}

impl AsRef<Sticker> for Sticker {
  fn as_ref(&self) -> &Sticker { self }
}

impl AsRef<Sticker> for RTDStickerBuilder {
  fn as_ref(&self) -> &Sticker { &self.inner }
}