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
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479

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




use std::fmt::Debug;
use serde::de::{Deserialize, Deserializer};



/// TRAIT | Describes format of the thumbnail
pub trait TDThumbnailFormat: Debug + RObject {}

/// Describes format of the thumbnail
#[derive(Debug, Clone, Serialize)]
#[serde(untagged)]
pub enum ThumbnailFormat {
  #[doc(hidden)] _Default(()),
  /// The thumbnail is in static GIF format. It will be used only for some bot inline results
  Gif(ThumbnailFormatGif),
  /// The thumbnail is in JPEG format
  Jpeg(ThumbnailFormatJpeg),
  /// The thumbnail is in MPEG4 format. It will be used only for some animations and videos
  Mpeg4(ThumbnailFormatMpeg4),
  /// The thumbnail is in PNG format. It will be used only for background patterns
  Png(ThumbnailFormatPng),
  /// The thumbnail is in TGS format. It will be used only for animated sticker sets
  Tgs(ThumbnailFormatTgs),
  /// The thumbnail is in WEBP format. It will be used only for some stickers
  Webp(ThumbnailFormatWebp),

}

impl Default for ThumbnailFormat {
  fn default() -> Self { ThumbnailFormat::_Default(()) }
}

impl<'de> Deserialize<'de> for ThumbnailFormat {
  fn deserialize<D>(deserializer: D) -> Result<ThumbnailFormat, D::Error> where D: Deserializer<'de> {
    use serde::de::Error;
    rtd_enum_deserialize!(
      ThumbnailFormat,
      (thumbnailFormatGif, Gif);
      (thumbnailFormatJpeg, Jpeg);
      (thumbnailFormatMpeg4, Mpeg4);
      (thumbnailFormatPng, Png);
      (thumbnailFormatTgs, Tgs);
      (thumbnailFormatWebp, Webp);

    )(deserializer)
  }
}

impl RObject for ThumbnailFormat {
  #[doc(hidden)] fn td_name(&self) -> &'static str {
    match self {
      ThumbnailFormat::Gif(t) => t.td_name(),
      ThumbnailFormat::Jpeg(t) => t.td_name(),
      ThumbnailFormat::Mpeg4(t) => t.td_name(),
      ThumbnailFormat::Png(t) => t.td_name(),
      ThumbnailFormat::Tgs(t) => t.td_name(),
      ThumbnailFormat::Webp(t) => t.td_name(),

      _ => "-1",
    }
  }
  #[doc(hidden)] fn extra(&self) -> Option<String> {
    match self {
      ThumbnailFormat::Gif(t) => t.extra(),
      ThumbnailFormat::Jpeg(t) => t.extra(),
      ThumbnailFormat::Mpeg4(t) => t.extra(),
      ThumbnailFormat::Png(t) => t.extra(),
      ThumbnailFormat::Tgs(t) => t.extra(),
      ThumbnailFormat::Webp(t) => t.extra(),

      _ => None,
    }
  }
  fn to_json(&self) -> RTDResult<String> { Ok(serde_json::to_string(self)?) }
}

impl ThumbnailFormat {
  pub fn from_json<S: AsRef<str>>(json: S) -> RTDResult<Self> { Ok(serde_json::from_str(json.as_ref())?) }
  #[doc(hidden)] pub fn _is_default(&self) -> bool { if let ThumbnailFormat::_Default(_) = self { true } else { false } }

  pub fn is_gif(&self) -> bool { if let ThumbnailFormat::Gif(_) = self { true } else { false } }
  pub fn is_jpeg(&self) -> bool { if let ThumbnailFormat::Jpeg(_) = self { true } else { false } }
  pub fn is_mpeg4(&self) -> bool { if let ThumbnailFormat::Mpeg4(_) = self { true } else { false } }
  pub fn is_png(&self) -> bool { if let ThumbnailFormat::Png(_) = self { true } else { false } }
  pub fn is_tgs(&self) -> bool { if let ThumbnailFormat::Tgs(_) = self { true } else { false } }
  pub fn is_webp(&self) -> bool { if let ThumbnailFormat::Webp(_) = self { true } else { false } }

  pub fn on_gif<F: FnOnce(&ThumbnailFormatGif)>(&self, fnc: F) -> &Self { if let ThumbnailFormat::Gif(t) = self { fnc(t) }; self }
  pub fn on_jpeg<F: FnOnce(&ThumbnailFormatJpeg)>(&self, fnc: F) -> &Self { if let ThumbnailFormat::Jpeg(t) = self { fnc(t) }; self }
  pub fn on_mpeg4<F: FnOnce(&ThumbnailFormatMpeg4)>(&self, fnc: F) -> &Self { if let ThumbnailFormat::Mpeg4(t) = self { fnc(t) }; self }
  pub fn on_png<F: FnOnce(&ThumbnailFormatPng)>(&self, fnc: F) -> &Self { if let ThumbnailFormat::Png(t) = self { fnc(t) }; self }
  pub fn on_tgs<F: FnOnce(&ThumbnailFormatTgs)>(&self, fnc: F) -> &Self { if let ThumbnailFormat::Tgs(t) = self { fnc(t) }; self }
  pub fn on_webp<F: FnOnce(&ThumbnailFormatWebp)>(&self, fnc: F) -> &Self { if let ThumbnailFormat::Webp(t) = self { fnc(t) }; self }

  pub fn as_gif(&self) -> Option<&ThumbnailFormatGif> { if let ThumbnailFormat::Gif(t) = self { return Some(t) } None }
  pub fn as_jpeg(&self) -> Option<&ThumbnailFormatJpeg> { if let ThumbnailFormat::Jpeg(t) = self { return Some(t) } None }
  pub fn as_mpeg4(&self) -> Option<&ThumbnailFormatMpeg4> { if let ThumbnailFormat::Mpeg4(t) = self { return Some(t) } None }
  pub fn as_png(&self) -> Option<&ThumbnailFormatPng> { if let ThumbnailFormat::Png(t) = self { return Some(t) } None }
  pub fn as_tgs(&self) -> Option<&ThumbnailFormatTgs> { if let ThumbnailFormat::Tgs(t) = self { return Some(t) } None }
  pub fn as_webp(&self) -> Option<&ThumbnailFormatWebp> { if let ThumbnailFormat::Webp(t) = self { return Some(t) } None }



  pub fn gif<T: AsRef<ThumbnailFormatGif>>(t: T) -> Self { ThumbnailFormat::Gif(t.as_ref().clone()) }

  pub fn jpeg<T: AsRef<ThumbnailFormatJpeg>>(t: T) -> Self { ThumbnailFormat::Jpeg(t.as_ref().clone()) }

  pub fn mpeg4<T: AsRef<ThumbnailFormatMpeg4>>(t: T) -> Self { ThumbnailFormat::Mpeg4(t.as_ref().clone()) }

  pub fn png<T: AsRef<ThumbnailFormatPng>>(t: T) -> Self { ThumbnailFormat::Png(t.as_ref().clone()) }

  pub fn tgs<T: AsRef<ThumbnailFormatTgs>>(t: T) -> Self { ThumbnailFormat::Tgs(t.as_ref().clone()) }

  pub fn webp<T: AsRef<ThumbnailFormatWebp>>(t: T) -> Self { ThumbnailFormat::Webp(t.as_ref().clone()) }

}

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







/// The thumbnail is in static GIF format. It will be used only for some bot inline results
#[derive(Debug, Clone, Default, Serialize, Deserialize)]
pub struct ThumbnailFormatGif {
  #[doc(hidden)]
  #[serde(rename(serialize = "@type", deserialize = "@type"))]
  td_name: String,
  #[doc(hidden)]
  #[serde(rename(serialize = "@extra", deserialize = "@extra"))]
  extra: Option<String>,
  
}

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


impl TDThumbnailFormat for ThumbnailFormatGif {}



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

}

#[doc(hidden)]
pub struct RTDThumbnailFormatGifBuilder {
  inner: ThumbnailFormatGif
}

impl RTDThumbnailFormatGifBuilder {
  pub fn build(&self) -> ThumbnailFormatGif { self.inner.clone() }

}

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

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







/// The thumbnail is in JPEG format
#[derive(Debug, Clone, Default, Serialize, Deserialize)]
pub struct ThumbnailFormatJpeg {
  #[doc(hidden)]
  #[serde(rename(serialize = "@type", deserialize = "@type"))]
  td_name: String,
  #[doc(hidden)]
  #[serde(rename(serialize = "@extra", deserialize = "@extra"))]
  extra: Option<String>,
  
}

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


impl TDThumbnailFormat for ThumbnailFormatJpeg {}



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

}

#[doc(hidden)]
pub struct RTDThumbnailFormatJpegBuilder {
  inner: ThumbnailFormatJpeg
}

impl RTDThumbnailFormatJpegBuilder {
  pub fn build(&self) -> ThumbnailFormatJpeg { self.inner.clone() }

}

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

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







/// The thumbnail is in MPEG4 format. It will be used only for some animations and videos
#[derive(Debug, Clone, Default, Serialize, Deserialize)]
pub struct ThumbnailFormatMpeg4 {
  #[doc(hidden)]
  #[serde(rename(serialize = "@type", deserialize = "@type"))]
  td_name: String,
  #[doc(hidden)]
  #[serde(rename(serialize = "@extra", deserialize = "@extra"))]
  extra: Option<String>,
  
}

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


impl TDThumbnailFormat for ThumbnailFormatMpeg4 {}



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

}

#[doc(hidden)]
pub struct RTDThumbnailFormatMpeg4Builder {
  inner: ThumbnailFormatMpeg4
}

impl RTDThumbnailFormatMpeg4Builder {
  pub fn build(&self) -> ThumbnailFormatMpeg4 { self.inner.clone() }

}

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

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







/// The thumbnail is in PNG format. It will be used only for background patterns
#[derive(Debug, Clone, Default, Serialize, Deserialize)]
pub struct ThumbnailFormatPng {
  #[doc(hidden)]
  #[serde(rename(serialize = "@type", deserialize = "@type"))]
  td_name: String,
  #[doc(hidden)]
  #[serde(rename(serialize = "@extra", deserialize = "@extra"))]
  extra: Option<String>,
  
}

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


impl TDThumbnailFormat for ThumbnailFormatPng {}



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

}

#[doc(hidden)]
pub struct RTDThumbnailFormatPngBuilder {
  inner: ThumbnailFormatPng
}

impl RTDThumbnailFormatPngBuilder {
  pub fn build(&self) -> ThumbnailFormatPng { self.inner.clone() }

}

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

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







/// The thumbnail is in TGS format. It will be used only for animated sticker sets
#[derive(Debug, Clone, Default, Serialize, Deserialize)]
pub struct ThumbnailFormatTgs {
  #[doc(hidden)]
  #[serde(rename(serialize = "@type", deserialize = "@type"))]
  td_name: String,
  #[doc(hidden)]
  #[serde(rename(serialize = "@extra", deserialize = "@extra"))]
  extra: Option<String>,
  
}

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


impl TDThumbnailFormat for ThumbnailFormatTgs {}



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

}

#[doc(hidden)]
pub struct RTDThumbnailFormatTgsBuilder {
  inner: ThumbnailFormatTgs
}

impl RTDThumbnailFormatTgsBuilder {
  pub fn build(&self) -> ThumbnailFormatTgs { self.inner.clone() }

}

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

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







/// The thumbnail is in WEBP format. It will be used only for some stickers
#[derive(Debug, Clone, Default, Serialize, Deserialize)]
pub struct ThumbnailFormatWebp {
  #[doc(hidden)]
  #[serde(rename(serialize = "@type", deserialize = "@type"))]
  td_name: String,
  #[doc(hidden)]
  #[serde(rename(serialize = "@extra", deserialize = "@extra"))]
  extra: Option<String>,
  
}

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


impl TDThumbnailFormat for ThumbnailFormatWebp {}



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

}

#[doc(hidden)]
pub struct RTDThumbnailFormatWebpBuilder {
  inner: ThumbnailFormatWebp
}

impl RTDThumbnailFormatWebpBuilder {
  pub fn build(&self) -> ThumbnailFormatWebp { self.inner.clone() }

}

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

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