Skip to main content

rust_tdlib/types/
mask_point.rs

1use crate::errors::Result;
2use crate::types::*;
3use uuid::Uuid;
4
5use std::fmt::Debug;
6
7/// Part of the face, relative to which a mask is placed
8pub trait TDMaskPoint: Debug + RObject {}
9
10/// Part of the face, relative to which a mask is placed
11#[derive(Debug, Clone, Deserialize, Serialize, Default)]
12#[serde(tag = "@type")]
13pub enum MaskPoint {
14    #[doc(hidden)]
15    #[default]
16    _Default,
17    /// The mask is placed relatively to the chin
18    #[serde(rename = "maskPointChin")]
19    Chin(MaskPointChin),
20    /// The mask is placed relatively to the eyes
21    #[serde(rename = "maskPointEyes")]
22    Eyes(MaskPointEyes),
23    /// The mask is placed relatively to the forehead
24    #[serde(rename = "maskPointForehead")]
25    Forehead(MaskPointForehead),
26    /// The mask is placed relatively to the mouth
27    #[serde(rename = "maskPointMouth")]
28    Mouth(MaskPointMouth),
29}
30
31impl RObject for MaskPoint {
32    #[doc(hidden)]
33    fn extra(&self) -> Option<&str> {
34        match self {
35            MaskPoint::Chin(t) => t.extra(),
36            MaskPoint::Eyes(t) => t.extra(),
37            MaskPoint::Forehead(t) => t.extra(),
38            MaskPoint::Mouth(t) => t.extra(),
39
40            _ => None,
41        }
42    }
43    #[doc(hidden)]
44    fn client_id(&self) -> Option<i32> {
45        match self {
46            MaskPoint::Chin(t) => t.client_id(),
47            MaskPoint::Eyes(t) => t.client_id(),
48            MaskPoint::Forehead(t) => t.client_id(),
49            MaskPoint::Mouth(t) => t.client_id(),
50
51            _ => None,
52        }
53    }
54}
55
56impl MaskPoint {
57    pub fn from_json<S: AsRef<str>>(json: S) -> Result<Self> {
58        Ok(serde_json::from_str(json.as_ref())?)
59    }
60    #[doc(hidden)]
61    pub fn _is_default(&self) -> bool {
62        matches!(self, MaskPoint::_Default)
63    }
64}
65
66impl AsRef<MaskPoint> for MaskPoint {
67    fn as_ref(&self) -> &MaskPoint {
68        self
69    }
70}
71
72/// The mask is placed relatively to the chin
73#[derive(Debug, Clone, Default, Serialize, Deserialize)]
74pub struct MaskPointChin {
75    #[doc(hidden)]
76    #[serde(rename(serialize = "@extra", deserialize = "@extra"))]
77    extra: Option<String>,
78    #[serde(rename(serialize = "@client_id", deserialize = "@client_id"))]
79    client_id: Option<i32>,
80}
81
82impl RObject for MaskPointChin {
83    #[doc(hidden)]
84    fn extra(&self) -> Option<&str> {
85        self.extra.as_deref()
86    }
87    #[doc(hidden)]
88    fn client_id(&self) -> Option<i32> {
89        self.client_id
90    }
91}
92
93impl TDMaskPoint for MaskPointChin {}
94
95impl MaskPointChin {
96    pub fn from_json<S: AsRef<str>>(json: S) -> Result<Self> {
97        Ok(serde_json::from_str(json.as_ref())?)
98    }
99    pub fn builder() -> MaskPointChinBuilder {
100        let mut inner = MaskPointChin::default();
101        inner.extra = Some(Uuid::new_v4().to_string());
102
103        MaskPointChinBuilder { inner }
104    }
105}
106
107#[doc(hidden)]
108pub struct MaskPointChinBuilder {
109    inner: MaskPointChin,
110}
111
112#[deprecated]
113pub type RTDMaskPointChinBuilder = MaskPointChinBuilder;
114
115impl MaskPointChinBuilder {
116    pub fn build(&self) -> MaskPointChin {
117        self.inner.clone()
118    }
119}
120
121impl AsRef<MaskPointChin> for MaskPointChin {
122    fn as_ref(&self) -> &MaskPointChin {
123        self
124    }
125}
126
127impl AsRef<MaskPointChin> for MaskPointChinBuilder {
128    fn as_ref(&self) -> &MaskPointChin {
129        &self.inner
130    }
131}
132
133/// The mask is placed relatively to the eyes
134#[derive(Debug, Clone, Default, Serialize, Deserialize)]
135pub struct MaskPointEyes {
136    #[doc(hidden)]
137    #[serde(rename(serialize = "@extra", deserialize = "@extra"))]
138    extra: Option<String>,
139    #[serde(rename(serialize = "@client_id", deserialize = "@client_id"))]
140    client_id: Option<i32>,
141}
142
143impl RObject for MaskPointEyes {
144    #[doc(hidden)]
145    fn extra(&self) -> Option<&str> {
146        self.extra.as_deref()
147    }
148    #[doc(hidden)]
149    fn client_id(&self) -> Option<i32> {
150        self.client_id
151    }
152}
153
154impl TDMaskPoint for MaskPointEyes {}
155
156impl MaskPointEyes {
157    pub fn from_json<S: AsRef<str>>(json: S) -> Result<Self> {
158        Ok(serde_json::from_str(json.as_ref())?)
159    }
160    pub fn builder() -> MaskPointEyesBuilder {
161        let mut inner = MaskPointEyes::default();
162        inner.extra = Some(Uuid::new_v4().to_string());
163
164        MaskPointEyesBuilder { inner }
165    }
166}
167
168#[doc(hidden)]
169pub struct MaskPointEyesBuilder {
170    inner: MaskPointEyes,
171}
172
173#[deprecated]
174pub type RTDMaskPointEyesBuilder = MaskPointEyesBuilder;
175
176impl MaskPointEyesBuilder {
177    pub fn build(&self) -> MaskPointEyes {
178        self.inner.clone()
179    }
180}
181
182impl AsRef<MaskPointEyes> for MaskPointEyes {
183    fn as_ref(&self) -> &MaskPointEyes {
184        self
185    }
186}
187
188impl AsRef<MaskPointEyes> for MaskPointEyesBuilder {
189    fn as_ref(&self) -> &MaskPointEyes {
190        &self.inner
191    }
192}
193
194/// The mask is placed relatively to the forehead
195#[derive(Debug, Clone, Default, Serialize, Deserialize)]
196pub struct MaskPointForehead {
197    #[doc(hidden)]
198    #[serde(rename(serialize = "@extra", deserialize = "@extra"))]
199    extra: Option<String>,
200    #[serde(rename(serialize = "@client_id", deserialize = "@client_id"))]
201    client_id: Option<i32>,
202}
203
204impl RObject for MaskPointForehead {
205    #[doc(hidden)]
206    fn extra(&self) -> Option<&str> {
207        self.extra.as_deref()
208    }
209    #[doc(hidden)]
210    fn client_id(&self) -> Option<i32> {
211        self.client_id
212    }
213}
214
215impl TDMaskPoint for MaskPointForehead {}
216
217impl MaskPointForehead {
218    pub fn from_json<S: AsRef<str>>(json: S) -> Result<Self> {
219        Ok(serde_json::from_str(json.as_ref())?)
220    }
221    pub fn builder() -> MaskPointForeheadBuilder {
222        let mut inner = MaskPointForehead::default();
223        inner.extra = Some(Uuid::new_v4().to_string());
224
225        MaskPointForeheadBuilder { inner }
226    }
227}
228
229#[doc(hidden)]
230pub struct MaskPointForeheadBuilder {
231    inner: MaskPointForehead,
232}
233
234#[deprecated]
235pub type RTDMaskPointForeheadBuilder = MaskPointForeheadBuilder;
236
237impl MaskPointForeheadBuilder {
238    pub fn build(&self) -> MaskPointForehead {
239        self.inner.clone()
240    }
241}
242
243impl AsRef<MaskPointForehead> for MaskPointForehead {
244    fn as_ref(&self) -> &MaskPointForehead {
245        self
246    }
247}
248
249impl AsRef<MaskPointForehead> for MaskPointForeheadBuilder {
250    fn as_ref(&self) -> &MaskPointForehead {
251        &self.inner
252    }
253}
254
255/// The mask is placed relatively to the mouth
256#[derive(Debug, Clone, Default, Serialize, Deserialize)]
257pub struct MaskPointMouth {
258    #[doc(hidden)]
259    #[serde(rename(serialize = "@extra", deserialize = "@extra"))]
260    extra: Option<String>,
261    #[serde(rename(serialize = "@client_id", deserialize = "@client_id"))]
262    client_id: Option<i32>,
263}
264
265impl RObject for MaskPointMouth {
266    #[doc(hidden)]
267    fn extra(&self) -> Option<&str> {
268        self.extra.as_deref()
269    }
270    #[doc(hidden)]
271    fn client_id(&self) -> Option<i32> {
272        self.client_id
273    }
274}
275
276impl TDMaskPoint for MaskPointMouth {}
277
278impl MaskPointMouth {
279    pub fn from_json<S: AsRef<str>>(json: S) -> Result<Self> {
280        Ok(serde_json::from_str(json.as_ref())?)
281    }
282    pub fn builder() -> MaskPointMouthBuilder {
283        let mut inner = MaskPointMouth::default();
284        inner.extra = Some(Uuid::new_v4().to_string());
285
286        MaskPointMouthBuilder { inner }
287    }
288}
289
290#[doc(hidden)]
291pub struct MaskPointMouthBuilder {
292    inner: MaskPointMouth,
293}
294
295#[deprecated]
296pub type RTDMaskPointMouthBuilder = MaskPointMouthBuilder;
297
298impl MaskPointMouthBuilder {
299    pub fn build(&self) -> MaskPointMouth {
300        self.inner.clone()
301    }
302}
303
304impl AsRef<MaskPointMouth> for MaskPointMouth {
305    fn as_ref(&self) -> &MaskPointMouth {
306        self
307    }
308}
309
310impl AsRef<MaskPointMouth> for MaskPointMouthBuilder {
311    fn as_ref(&self) -> &MaskPointMouth {
312        &self.inner
313    }
314}