rust_tdlib/types/
page_block_horizontal_alignment.rs

1use crate::errors::Result;
2use crate::types::*;
3use uuid::Uuid;
4
5use std::fmt::Debug;
6
7/// Describes a horizontal alignment of a table cell content
8pub trait TDPageBlockHorizontalAlignment: Debug + RObject {}
9
10/// Describes a horizontal alignment of a table cell content
11#[derive(Debug, Clone, Deserialize, Serialize, Default)]
12#[serde(tag = "@type")]
13pub enum PageBlockHorizontalAlignment {
14    #[doc(hidden)]
15    #[default]
16    _Default,
17    /// The content must be center-aligned
18    #[serde(rename = "pageBlockHorizontalAlignmentCenter")]
19    Center(PageBlockHorizontalAlignmentCenter),
20    /// The content must be left-aligned
21    #[serde(rename = "pageBlockHorizontalAlignmentLeft")]
22    Left(PageBlockHorizontalAlignmentLeft),
23    /// The content must be right-aligned
24    #[serde(rename = "pageBlockHorizontalAlignmentRight")]
25    Right(PageBlockHorizontalAlignmentRight),
26}
27
28impl RObject for PageBlockHorizontalAlignment {
29    #[doc(hidden)]
30    fn extra(&self) -> Option<&str> {
31        match self {
32            PageBlockHorizontalAlignment::Center(t) => t.extra(),
33            PageBlockHorizontalAlignment::Left(t) => t.extra(),
34            PageBlockHorizontalAlignment::Right(t) => t.extra(),
35
36            _ => None,
37        }
38    }
39    #[doc(hidden)]
40    fn client_id(&self) -> Option<i32> {
41        match self {
42            PageBlockHorizontalAlignment::Center(t) => t.client_id(),
43            PageBlockHorizontalAlignment::Left(t) => t.client_id(),
44            PageBlockHorizontalAlignment::Right(t) => t.client_id(),
45
46            _ => None,
47        }
48    }
49}
50
51impl PageBlockHorizontalAlignment {
52    pub fn from_json<S: AsRef<str>>(json: S) -> Result<Self> {
53        Ok(serde_json::from_str(json.as_ref())?)
54    }
55    #[doc(hidden)]
56    pub fn _is_default(&self) -> bool {
57        matches!(self, PageBlockHorizontalAlignment::_Default)
58    }
59}
60
61impl AsRef<PageBlockHorizontalAlignment> for PageBlockHorizontalAlignment {
62    fn as_ref(&self) -> &PageBlockHorizontalAlignment {
63        self
64    }
65}
66
67/// The content must be center-aligned
68#[derive(Debug, Clone, Default, Serialize, Deserialize)]
69pub struct PageBlockHorizontalAlignmentCenter {
70    #[doc(hidden)]
71    #[serde(rename(serialize = "@extra", deserialize = "@extra"))]
72    extra: Option<String>,
73    #[serde(rename(serialize = "@client_id", deserialize = "@client_id"))]
74    client_id: Option<i32>,
75}
76
77impl RObject for PageBlockHorizontalAlignmentCenter {
78    #[doc(hidden)]
79    fn extra(&self) -> Option<&str> {
80        self.extra.as_deref()
81    }
82    #[doc(hidden)]
83    fn client_id(&self) -> Option<i32> {
84        self.client_id
85    }
86}
87
88impl TDPageBlockHorizontalAlignment for PageBlockHorizontalAlignmentCenter {}
89
90impl PageBlockHorizontalAlignmentCenter {
91    pub fn from_json<S: AsRef<str>>(json: S) -> Result<Self> {
92        Ok(serde_json::from_str(json.as_ref())?)
93    }
94    pub fn builder() -> PageBlockHorizontalAlignmentCenterBuilder {
95        let mut inner = PageBlockHorizontalAlignmentCenter::default();
96        inner.extra = Some(Uuid::new_v4().to_string());
97
98        PageBlockHorizontalAlignmentCenterBuilder { inner }
99    }
100}
101
102#[doc(hidden)]
103pub struct PageBlockHorizontalAlignmentCenterBuilder {
104    inner: PageBlockHorizontalAlignmentCenter,
105}
106
107#[deprecated]
108pub type RTDPageBlockHorizontalAlignmentCenterBuilder = PageBlockHorizontalAlignmentCenterBuilder;
109
110impl PageBlockHorizontalAlignmentCenterBuilder {
111    pub fn build(&self) -> PageBlockHorizontalAlignmentCenter {
112        self.inner.clone()
113    }
114}
115
116impl AsRef<PageBlockHorizontalAlignmentCenter> for PageBlockHorizontalAlignmentCenter {
117    fn as_ref(&self) -> &PageBlockHorizontalAlignmentCenter {
118        self
119    }
120}
121
122impl AsRef<PageBlockHorizontalAlignmentCenter> for PageBlockHorizontalAlignmentCenterBuilder {
123    fn as_ref(&self) -> &PageBlockHorizontalAlignmentCenter {
124        &self.inner
125    }
126}
127
128/// The content must be left-aligned
129#[derive(Debug, Clone, Default, Serialize, Deserialize)]
130pub struct PageBlockHorizontalAlignmentLeft {
131    #[doc(hidden)]
132    #[serde(rename(serialize = "@extra", deserialize = "@extra"))]
133    extra: Option<String>,
134    #[serde(rename(serialize = "@client_id", deserialize = "@client_id"))]
135    client_id: Option<i32>,
136}
137
138impl RObject for PageBlockHorizontalAlignmentLeft {
139    #[doc(hidden)]
140    fn extra(&self) -> Option<&str> {
141        self.extra.as_deref()
142    }
143    #[doc(hidden)]
144    fn client_id(&self) -> Option<i32> {
145        self.client_id
146    }
147}
148
149impl TDPageBlockHorizontalAlignment for PageBlockHorizontalAlignmentLeft {}
150
151impl PageBlockHorizontalAlignmentLeft {
152    pub fn from_json<S: AsRef<str>>(json: S) -> Result<Self> {
153        Ok(serde_json::from_str(json.as_ref())?)
154    }
155    pub fn builder() -> PageBlockHorizontalAlignmentLeftBuilder {
156        let mut inner = PageBlockHorizontalAlignmentLeft::default();
157        inner.extra = Some(Uuid::new_v4().to_string());
158
159        PageBlockHorizontalAlignmentLeftBuilder { inner }
160    }
161}
162
163#[doc(hidden)]
164pub struct PageBlockHorizontalAlignmentLeftBuilder {
165    inner: PageBlockHorizontalAlignmentLeft,
166}
167
168#[deprecated]
169pub type RTDPageBlockHorizontalAlignmentLeftBuilder = PageBlockHorizontalAlignmentLeftBuilder;
170
171impl PageBlockHorizontalAlignmentLeftBuilder {
172    pub fn build(&self) -> PageBlockHorizontalAlignmentLeft {
173        self.inner.clone()
174    }
175}
176
177impl AsRef<PageBlockHorizontalAlignmentLeft> for PageBlockHorizontalAlignmentLeft {
178    fn as_ref(&self) -> &PageBlockHorizontalAlignmentLeft {
179        self
180    }
181}
182
183impl AsRef<PageBlockHorizontalAlignmentLeft> for PageBlockHorizontalAlignmentLeftBuilder {
184    fn as_ref(&self) -> &PageBlockHorizontalAlignmentLeft {
185        &self.inner
186    }
187}
188
189/// The content must be right-aligned
190#[derive(Debug, Clone, Default, Serialize, Deserialize)]
191pub struct PageBlockHorizontalAlignmentRight {
192    #[doc(hidden)]
193    #[serde(rename(serialize = "@extra", deserialize = "@extra"))]
194    extra: Option<String>,
195    #[serde(rename(serialize = "@client_id", deserialize = "@client_id"))]
196    client_id: Option<i32>,
197}
198
199impl RObject for PageBlockHorizontalAlignmentRight {
200    #[doc(hidden)]
201    fn extra(&self) -> Option<&str> {
202        self.extra.as_deref()
203    }
204    #[doc(hidden)]
205    fn client_id(&self) -> Option<i32> {
206        self.client_id
207    }
208}
209
210impl TDPageBlockHorizontalAlignment for PageBlockHorizontalAlignmentRight {}
211
212impl PageBlockHorizontalAlignmentRight {
213    pub fn from_json<S: AsRef<str>>(json: S) -> Result<Self> {
214        Ok(serde_json::from_str(json.as_ref())?)
215    }
216    pub fn builder() -> PageBlockHorizontalAlignmentRightBuilder {
217        let mut inner = PageBlockHorizontalAlignmentRight::default();
218        inner.extra = Some(Uuid::new_v4().to_string());
219
220        PageBlockHorizontalAlignmentRightBuilder { inner }
221    }
222}
223
224#[doc(hidden)]
225pub struct PageBlockHorizontalAlignmentRightBuilder {
226    inner: PageBlockHorizontalAlignmentRight,
227}
228
229#[deprecated]
230pub type RTDPageBlockHorizontalAlignmentRightBuilder = PageBlockHorizontalAlignmentRightBuilder;
231
232impl PageBlockHorizontalAlignmentRightBuilder {
233    pub fn build(&self) -> PageBlockHorizontalAlignmentRight {
234        self.inner.clone()
235    }
236}
237
238impl AsRef<PageBlockHorizontalAlignmentRight> for PageBlockHorizontalAlignmentRight {
239    fn as_ref(&self) -> &PageBlockHorizontalAlignmentRight {
240        self
241    }
242}
243
244impl AsRef<PageBlockHorizontalAlignmentRight> for PageBlockHorizontalAlignmentRightBuilder {
245    fn as_ref(&self) -> &PageBlockHorizontalAlignmentRight {
246        &self.inner
247    }
248}