rtdlib/types/
input_thumbnail.rs1
2use crate::types::*;
3use crate::errors::*;
4use uuid::Uuid;
5
6
7
8
9#[derive(Debug, Clone, Default, Serialize, Deserialize)]
11pub struct InputThumbnail {
12 #[doc(hidden)]
13 #[serde(rename(serialize = "@type", deserialize = "@type"))]
14 td_name: String,
15 #[doc(hidden)]
16 #[serde(rename(serialize = "@extra", deserialize = "@extra"))]
17 extra: Option<String>,
18 thumbnail: InputFile,
20 width: i64,
22 height: i64,
24
25}
26
27impl RObject for InputThumbnail {
28 #[doc(hidden)] fn td_name(&self) -> &'static str { "inputThumbnail" }
29 #[doc(hidden)] fn extra(&self) -> Option<String> { self.extra.clone() }
30 fn to_json(&self) -> RTDResult<String> { Ok(serde_json::to_string(self)?) }
31}
32
33
34
35impl InputThumbnail {
36 pub fn from_json<S: AsRef<str>>(json: S) -> RTDResult<Self> { Ok(serde_json::from_str(json.as_ref())?) }
37 pub fn builder() -> RTDInputThumbnailBuilder {
38 let mut inner = InputThumbnail::default();
39 inner.td_name = "inputThumbnail".to_string();
40 inner.extra = Some(Uuid::new_v4().to_string());
41 RTDInputThumbnailBuilder { inner }
42 }
43
44 pub fn thumbnail(&self) -> &InputFile { &self.thumbnail }
45
46 pub fn width(&self) -> i64 { self.width }
47
48 pub fn height(&self) -> i64 { self.height }
49
50}
51
52#[doc(hidden)]
53pub struct RTDInputThumbnailBuilder {
54 inner: InputThumbnail
55}
56
57impl RTDInputThumbnailBuilder {
58 pub fn build(&self) -> InputThumbnail { self.inner.clone() }
59
60
61 pub fn thumbnail<T: AsRef<InputFile>>(&mut self, thumbnail: T) -> &mut Self {
62 self.inner.thumbnail = thumbnail.as_ref().clone();
63 self
64 }
65
66
67 pub fn width(&mut self, width: i64) -> &mut Self {
68 self.inner.width = width;
69 self
70 }
71
72
73 pub fn height(&mut self, height: i64) -> &mut Self {
74 self.inner.height = height;
75 self
76 }
77
78}
79
80impl AsRef<InputThumbnail> for InputThumbnail {
81 fn as_ref(&self) -> &InputThumbnail { self }
82}
83
84impl AsRef<InputThumbnail> for RTDInputThumbnailBuilder {
85 fn as_ref(&self) -> &InputThumbnail { &self.inner }
86}
87
88
89