rtdlib/types/
page_block_horizontal_alignment.rs1
2use crate::types::*;
3use crate::errors::*;
4use uuid::Uuid;
5
6
7
8
9use std::fmt::Debug;
10use serde::de::{Deserialize, Deserializer};
11
12
13
14pub trait TDPageBlockHorizontalAlignment: Debug + RObject {}
16
17#[derive(Debug, Clone, Serialize)]
19#[serde(untagged)]
20pub enum PageBlockHorizontalAlignment {
21 #[doc(hidden)] _Default(()),
22 Center(PageBlockHorizontalAlignmentCenter),
24 Left(PageBlockHorizontalAlignmentLeft),
26 Right(PageBlockHorizontalAlignmentRight),
28
29}
30
31impl Default for PageBlockHorizontalAlignment {
32 fn default() -> Self { PageBlockHorizontalAlignment::_Default(()) }
33}
34
35impl<'de> Deserialize<'de> for PageBlockHorizontalAlignment {
36 fn deserialize<D>(deserializer: D) -> Result<PageBlockHorizontalAlignment, D::Error> where D: Deserializer<'de> {
37 use serde::de::Error;
38 rtd_enum_deserialize!(
39 PageBlockHorizontalAlignment,
40 (pageBlockHorizontalAlignmentCenter, Center);
41 (pageBlockHorizontalAlignmentLeft, Left);
42 (pageBlockHorizontalAlignmentRight, Right);
43
44 )(deserializer)
45 }
46}
47
48impl RObject for PageBlockHorizontalAlignment {
49 #[doc(hidden)] fn td_name(&self) -> &'static str {
50 match self {
51 PageBlockHorizontalAlignment::Center(t) => t.td_name(),
52 PageBlockHorizontalAlignment::Left(t) => t.td_name(),
53 PageBlockHorizontalAlignment::Right(t) => t.td_name(),
54
55 _ => "-1",
56 }
57 }
58 #[doc(hidden)] fn extra(&self) -> Option<String> {
59 match self {
60 PageBlockHorizontalAlignment::Center(t) => t.extra(),
61 PageBlockHorizontalAlignment::Left(t) => t.extra(),
62 PageBlockHorizontalAlignment::Right(t) => t.extra(),
63
64 _ => None,
65 }
66 }
67 fn to_json(&self) -> RTDResult<String> { Ok(serde_json::to_string(self)?) }
68}
69
70impl PageBlockHorizontalAlignment {
71 pub fn from_json<S: AsRef<str>>(json: S) -> RTDResult<Self> { Ok(serde_json::from_str(json.as_ref())?) }
72 #[doc(hidden)] pub fn _is_default(&self) -> bool { if let PageBlockHorizontalAlignment::_Default(_) = self { true } else { false } }
73
74 pub fn is_center(&self) -> bool { if let PageBlockHorizontalAlignment::Center(_) = self { true } else { false } }
75 pub fn is_left(&self) -> bool { if let PageBlockHorizontalAlignment::Left(_) = self { true } else { false } }
76 pub fn is_right(&self) -> bool { if let PageBlockHorizontalAlignment::Right(_) = self { true } else { false } }
77
78 pub fn on_center<F: FnOnce(&PageBlockHorizontalAlignmentCenter)>(&self, fnc: F) -> &Self { if let PageBlockHorizontalAlignment::Center(t) = self { fnc(t) }; self }
79 pub fn on_left<F: FnOnce(&PageBlockHorizontalAlignmentLeft)>(&self, fnc: F) -> &Self { if let PageBlockHorizontalAlignment::Left(t) = self { fnc(t) }; self }
80 pub fn on_right<F: FnOnce(&PageBlockHorizontalAlignmentRight)>(&self, fnc: F) -> &Self { if let PageBlockHorizontalAlignment::Right(t) = self { fnc(t) }; self }
81
82 pub fn as_center(&self) -> Option<&PageBlockHorizontalAlignmentCenter> { if let PageBlockHorizontalAlignment::Center(t) = self { return Some(t) } None }
83 pub fn as_left(&self) -> Option<&PageBlockHorizontalAlignmentLeft> { if let PageBlockHorizontalAlignment::Left(t) = self { return Some(t) } None }
84 pub fn as_right(&self) -> Option<&PageBlockHorizontalAlignmentRight> { if let PageBlockHorizontalAlignment::Right(t) = self { return Some(t) } None }
85
86
87
88 pub fn center<T: AsRef<PageBlockHorizontalAlignmentCenter>>(t: T) -> Self { PageBlockHorizontalAlignment::Center(t.as_ref().clone()) }
89
90 pub fn left<T: AsRef<PageBlockHorizontalAlignmentLeft>>(t: T) -> Self { PageBlockHorizontalAlignment::Left(t.as_ref().clone()) }
91
92 pub fn right<T: AsRef<PageBlockHorizontalAlignmentRight>>(t: T) -> Self { PageBlockHorizontalAlignment::Right(t.as_ref().clone()) }
93
94}
95
96impl AsRef<PageBlockHorizontalAlignment> for PageBlockHorizontalAlignment {
97 fn as_ref(&self) -> &PageBlockHorizontalAlignment { self }
98}
99
100
101
102
103
104
105
106#[derive(Debug, Clone, Default, Serialize, Deserialize)]
108pub struct PageBlockHorizontalAlignmentCenter {
109 #[doc(hidden)]
110 #[serde(rename(serialize = "@type", deserialize = "@type"))]
111 td_name: String,
112 #[doc(hidden)]
113 #[serde(rename(serialize = "@extra", deserialize = "@extra"))]
114 extra: Option<String>,
115
116}
117
118impl RObject for PageBlockHorizontalAlignmentCenter {
119 #[doc(hidden)] fn td_name(&self) -> &'static str { "pageBlockHorizontalAlignmentCenter" }
120 #[doc(hidden)] fn extra(&self) -> Option<String> { self.extra.clone() }
121 fn to_json(&self) -> RTDResult<String> { Ok(serde_json::to_string(self)?) }
122}
123
124
125impl TDPageBlockHorizontalAlignment for PageBlockHorizontalAlignmentCenter {}
126
127
128
129impl PageBlockHorizontalAlignmentCenter {
130 pub fn from_json<S: AsRef<str>>(json: S) -> RTDResult<Self> { Ok(serde_json::from_str(json.as_ref())?) }
131 pub fn builder() -> RTDPageBlockHorizontalAlignmentCenterBuilder {
132 let mut inner = PageBlockHorizontalAlignmentCenter::default();
133 inner.td_name = "pageBlockHorizontalAlignmentCenter".to_string();
134 inner.extra = Some(Uuid::new_v4().to_string());
135 RTDPageBlockHorizontalAlignmentCenterBuilder { inner }
136 }
137
138}
139
140#[doc(hidden)]
141pub struct RTDPageBlockHorizontalAlignmentCenterBuilder {
142 inner: PageBlockHorizontalAlignmentCenter
143}
144
145impl RTDPageBlockHorizontalAlignmentCenterBuilder {
146 pub fn build(&self) -> PageBlockHorizontalAlignmentCenter { self.inner.clone() }
147
148}
149
150impl AsRef<PageBlockHorizontalAlignmentCenter> for PageBlockHorizontalAlignmentCenter {
151 fn as_ref(&self) -> &PageBlockHorizontalAlignmentCenter { self }
152}
153
154impl AsRef<PageBlockHorizontalAlignmentCenter> for RTDPageBlockHorizontalAlignmentCenterBuilder {
155 fn as_ref(&self) -> &PageBlockHorizontalAlignmentCenter { &self.inner }
156}
157
158
159
160
161
162
163
164#[derive(Debug, Clone, Default, Serialize, Deserialize)]
166pub struct PageBlockHorizontalAlignmentLeft {
167 #[doc(hidden)]
168 #[serde(rename(serialize = "@type", deserialize = "@type"))]
169 td_name: String,
170 #[doc(hidden)]
171 #[serde(rename(serialize = "@extra", deserialize = "@extra"))]
172 extra: Option<String>,
173
174}
175
176impl RObject for PageBlockHorizontalAlignmentLeft {
177 #[doc(hidden)] fn td_name(&self) -> &'static str { "pageBlockHorizontalAlignmentLeft" }
178 #[doc(hidden)] fn extra(&self) -> Option<String> { self.extra.clone() }
179 fn to_json(&self) -> RTDResult<String> { Ok(serde_json::to_string(self)?) }
180}
181
182
183impl TDPageBlockHorizontalAlignment for PageBlockHorizontalAlignmentLeft {}
184
185
186
187impl PageBlockHorizontalAlignmentLeft {
188 pub fn from_json<S: AsRef<str>>(json: S) -> RTDResult<Self> { Ok(serde_json::from_str(json.as_ref())?) }
189 pub fn builder() -> RTDPageBlockHorizontalAlignmentLeftBuilder {
190 let mut inner = PageBlockHorizontalAlignmentLeft::default();
191 inner.td_name = "pageBlockHorizontalAlignmentLeft".to_string();
192 inner.extra = Some(Uuid::new_v4().to_string());
193 RTDPageBlockHorizontalAlignmentLeftBuilder { inner }
194 }
195
196}
197
198#[doc(hidden)]
199pub struct RTDPageBlockHorizontalAlignmentLeftBuilder {
200 inner: PageBlockHorizontalAlignmentLeft
201}
202
203impl RTDPageBlockHorizontalAlignmentLeftBuilder {
204 pub fn build(&self) -> PageBlockHorizontalAlignmentLeft { self.inner.clone() }
205
206}
207
208impl AsRef<PageBlockHorizontalAlignmentLeft> for PageBlockHorizontalAlignmentLeft {
209 fn as_ref(&self) -> &PageBlockHorizontalAlignmentLeft { self }
210}
211
212impl AsRef<PageBlockHorizontalAlignmentLeft> for RTDPageBlockHorizontalAlignmentLeftBuilder {
213 fn as_ref(&self) -> &PageBlockHorizontalAlignmentLeft { &self.inner }
214}
215
216
217
218
219
220
221
222#[derive(Debug, Clone, Default, Serialize, Deserialize)]
224pub struct PageBlockHorizontalAlignmentRight {
225 #[doc(hidden)]
226 #[serde(rename(serialize = "@type", deserialize = "@type"))]
227 td_name: String,
228 #[doc(hidden)]
229 #[serde(rename(serialize = "@extra", deserialize = "@extra"))]
230 extra: Option<String>,
231
232}
233
234impl RObject for PageBlockHorizontalAlignmentRight {
235 #[doc(hidden)] fn td_name(&self) -> &'static str { "pageBlockHorizontalAlignmentRight" }
236 #[doc(hidden)] fn extra(&self) -> Option<String> { self.extra.clone() }
237 fn to_json(&self) -> RTDResult<String> { Ok(serde_json::to_string(self)?) }
238}
239
240
241impl TDPageBlockHorizontalAlignment for PageBlockHorizontalAlignmentRight {}
242
243
244
245impl PageBlockHorizontalAlignmentRight {
246 pub fn from_json<S: AsRef<str>>(json: S) -> RTDResult<Self> { Ok(serde_json::from_str(json.as_ref())?) }
247 pub fn builder() -> RTDPageBlockHorizontalAlignmentRightBuilder {
248 let mut inner = PageBlockHorizontalAlignmentRight::default();
249 inner.td_name = "pageBlockHorizontalAlignmentRight".to_string();
250 inner.extra = Some(Uuid::new_v4().to_string());
251 RTDPageBlockHorizontalAlignmentRightBuilder { inner }
252 }
253
254}
255
256#[doc(hidden)]
257pub struct RTDPageBlockHorizontalAlignmentRightBuilder {
258 inner: PageBlockHorizontalAlignmentRight
259}
260
261impl RTDPageBlockHorizontalAlignmentRightBuilder {
262 pub fn build(&self) -> PageBlockHorizontalAlignmentRight { self.inner.clone() }
263
264}
265
266impl AsRef<PageBlockHorizontalAlignmentRight> for PageBlockHorizontalAlignmentRight {
267 fn as_ref(&self) -> &PageBlockHorizontalAlignmentRight { self }
268}
269
270impl AsRef<PageBlockHorizontalAlignmentRight> for RTDPageBlockHorizontalAlignmentRightBuilder {
271 fn as_ref(&self) -> &PageBlockHorizontalAlignmentRight { &self.inner }
272}
273
274
275