rust_tdlib/types/
page_block_vertical_alignment.rs

1use crate::errors::Result;
2use crate::types::*;
3use uuid::Uuid;
4
5use std::fmt::Debug;
6
7/// Describes a Vertical alignment of a table cell content
8pub trait TDPageBlockVerticalAlignment: Debug + RObject {}
9
10/// Describes a Vertical alignment of a table cell content
11#[derive(Debug, Clone, Deserialize, Serialize, Default)]
12#[serde(tag = "@type")]
13pub enum PageBlockVerticalAlignment {
14    #[doc(hidden)]
15    #[default]
16    _Default,
17    /// The content must be bottom-aligned
18    #[serde(rename = "pageBlockVerticalAlignmentBottom")]
19    Bottom(PageBlockVerticalAlignmentBottom),
20    /// The content must be middle-aligned
21    #[serde(rename = "pageBlockVerticalAlignmentMiddle")]
22    Middle(PageBlockVerticalAlignmentMiddle),
23    /// The content must be top-aligned
24    #[serde(rename = "pageBlockVerticalAlignmentTop")]
25    Top(PageBlockVerticalAlignmentTop),
26}
27
28impl RObject for PageBlockVerticalAlignment {
29    #[doc(hidden)]
30    fn extra(&self) -> Option<&str> {
31        match self {
32            PageBlockVerticalAlignment::Bottom(t) => t.extra(),
33            PageBlockVerticalAlignment::Middle(t) => t.extra(),
34            PageBlockVerticalAlignment::Top(t) => t.extra(),
35
36            _ => None,
37        }
38    }
39    #[doc(hidden)]
40    fn client_id(&self) -> Option<i32> {
41        match self {
42            PageBlockVerticalAlignment::Bottom(t) => t.client_id(),
43            PageBlockVerticalAlignment::Middle(t) => t.client_id(),
44            PageBlockVerticalAlignment::Top(t) => t.client_id(),
45
46            _ => None,
47        }
48    }
49}
50
51impl PageBlockVerticalAlignment {
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, PageBlockVerticalAlignment::_Default)
58    }
59}
60
61impl AsRef<PageBlockVerticalAlignment> for PageBlockVerticalAlignment {
62    fn as_ref(&self) -> &PageBlockVerticalAlignment {
63        self
64    }
65}
66
67/// The content must be bottom-aligned
68#[derive(Debug, Clone, Default, Serialize, Deserialize)]
69pub struct PageBlockVerticalAlignmentBottom {
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 PageBlockVerticalAlignmentBottom {
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 TDPageBlockVerticalAlignment for PageBlockVerticalAlignmentBottom {}
89
90impl PageBlockVerticalAlignmentBottom {
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() -> PageBlockVerticalAlignmentBottomBuilder {
95        let mut inner = PageBlockVerticalAlignmentBottom::default();
96        inner.extra = Some(Uuid::new_v4().to_string());
97
98        PageBlockVerticalAlignmentBottomBuilder { inner }
99    }
100}
101
102#[doc(hidden)]
103pub struct PageBlockVerticalAlignmentBottomBuilder {
104    inner: PageBlockVerticalAlignmentBottom,
105}
106
107#[deprecated]
108pub type RTDPageBlockVerticalAlignmentBottomBuilder = PageBlockVerticalAlignmentBottomBuilder;
109
110impl PageBlockVerticalAlignmentBottomBuilder {
111    pub fn build(&self) -> PageBlockVerticalAlignmentBottom {
112        self.inner.clone()
113    }
114}
115
116impl AsRef<PageBlockVerticalAlignmentBottom> for PageBlockVerticalAlignmentBottom {
117    fn as_ref(&self) -> &PageBlockVerticalAlignmentBottom {
118        self
119    }
120}
121
122impl AsRef<PageBlockVerticalAlignmentBottom> for PageBlockVerticalAlignmentBottomBuilder {
123    fn as_ref(&self) -> &PageBlockVerticalAlignmentBottom {
124        &self.inner
125    }
126}
127
128/// The content must be middle-aligned
129#[derive(Debug, Clone, Default, Serialize, Deserialize)]
130pub struct PageBlockVerticalAlignmentMiddle {
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 PageBlockVerticalAlignmentMiddle {
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 TDPageBlockVerticalAlignment for PageBlockVerticalAlignmentMiddle {}
150
151impl PageBlockVerticalAlignmentMiddle {
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() -> PageBlockVerticalAlignmentMiddleBuilder {
156        let mut inner = PageBlockVerticalAlignmentMiddle::default();
157        inner.extra = Some(Uuid::new_v4().to_string());
158
159        PageBlockVerticalAlignmentMiddleBuilder { inner }
160    }
161}
162
163#[doc(hidden)]
164pub struct PageBlockVerticalAlignmentMiddleBuilder {
165    inner: PageBlockVerticalAlignmentMiddle,
166}
167
168#[deprecated]
169pub type RTDPageBlockVerticalAlignmentMiddleBuilder = PageBlockVerticalAlignmentMiddleBuilder;
170
171impl PageBlockVerticalAlignmentMiddleBuilder {
172    pub fn build(&self) -> PageBlockVerticalAlignmentMiddle {
173        self.inner.clone()
174    }
175}
176
177impl AsRef<PageBlockVerticalAlignmentMiddle> for PageBlockVerticalAlignmentMiddle {
178    fn as_ref(&self) -> &PageBlockVerticalAlignmentMiddle {
179        self
180    }
181}
182
183impl AsRef<PageBlockVerticalAlignmentMiddle> for PageBlockVerticalAlignmentMiddleBuilder {
184    fn as_ref(&self) -> &PageBlockVerticalAlignmentMiddle {
185        &self.inner
186    }
187}
188
189/// The content must be top-aligned
190#[derive(Debug, Clone, Default, Serialize, Deserialize)]
191pub struct PageBlockVerticalAlignmentTop {
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 PageBlockVerticalAlignmentTop {
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 TDPageBlockVerticalAlignment for PageBlockVerticalAlignmentTop {}
211
212impl PageBlockVerticalAlignmentTop {
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() -> PageBlockVerticalAlignmentTopBuilder {
217        let mut inner = PageBlockVerticalAlignmentTop::default();
218        inner.extra = Some(Uuid::new_v4().to_string());
219
220        PageBlockVerticalAlignmentTopBuilder { inner }
221    }
222}
223
224#[doc(hidden)]
225pub struct PageBlockVerticalAlignmentTopBuilder {
226    inner: PageBlockVerticalAlignmentTop,
227}
228
229#[deprecated]
230pub type RTDPageBlockVerticalAlignmentTopBuilder = PageBlockVerticalAlignmentTopBuilder;
231
232impl PageBlockVerticalAlignmentTopBuilder {
233    pub fn build(&self) -> PageBlockVerticalAlignmentTop {
234        self.inner.clone()
235    }
236}
237
238impl AsRef<PageBlockVerticalAlignmentTop> for PageBlockVerticalAlignmentTop {
239    fn as_ref(&self) -> &PageBlockVerticalAlignmentTop {
240        self
241    }
242}
243
244impl AsRef<PageBlockVerticalAlignmentTop> for PageBlockVerticalAlignmentTopBuilder {
245    fn as_ref(&self) -> &PageBlockVerticalAlignmentTop {
246        &self.inner
247    }
248}