rtdlib/types/
page_block_vertical_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 TDPageBlockVerticalAlignment: Debug + RObject {}
16
17#[derive(Debug, Clone, Serialize)]
19#[serde(untagged)]
20pub enum PageBlockVerticalAlignment {
21 #[doc(hidden)] _Default(()),
22 Bottom(PageBlockVerticalAlignmentBottom),
24 Middle(PageBlockVerticalAlignmentMiddle),
26 Top(PageBlockVerticalAlignmentTop),
28
29}
30
31impl Default for PageBlockVerticalAlignment {
32 fn default() -> Self { PageBlockVerticalAlignment::_Default(()) }
33}
34
35impl<'de> Deserialize<'de> for PageBlockVerticalAlignment {
36 fn deserialize<D>(deserializer: D) -> Result<PageBlockVerticalAlignment, D::Error> where D: Deserializer<'de> {
37 use serde::de::Error;
38 rtd_enum_deserialize!(
39 PageBlockVerticalAlignment,
40 (pageBlockVerticalAlignmentBottom, Bottom);
41 (pageBlockVerticalAlignmentMiddle, Middle);
42 (pageBlockVerticalAlignmentTop, Top);
43
44 )(deserializer)
45 }
46}
47
48impl RObject for PageBlockVerticalAlignment {
49 #[doc(hidden)] fn td_name(&self) -> &'static str {
50 match self {
51 PageBlockVerticalAlignment::Bottom(t) => t.td_name(),
52 PageBlockVerticalAlignment::Middle(t) => t.td_name(),
53 PageBlockVerticalAlignment::Top(t) => t.td_name(),
54
55 _ => "-1",
56 }
57 }
58 #[doc(hidden)] fn extra(&self) -> Option<String> {
59 match self {
60 PageBlockVerticalAlignment::Bottom(t) => t.extra(),
61 PageBlockVerticalAlignment::Middle(t) => t.extra(),
62 PageBlockVerticalAlignment::Top(t) => t.extra(),
63
64 _ => None,
65 }
66 }
67 fn to_json(&self) -> RTDResult<String> { Ok(serde_json::to_string(self)?) }
68}
69
70impl PageBlockVerticalAlignment {
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 PageBlockVerticalAlignment::_Default(_) = self { true } else { false } }
73
74 pub fn is_bottom(&self) -> bool { if let PageBlockVerticalAlignment::Bottom(_) = self { true } else { false } }
75 pub fn is_middle(&self) -> bool { if let PageBlockVerticalAlignment::Middle(_) = self { true } else { false } }
76 pub fn is_top(&self) -> bool { if let PageBlockVerticalAlignment::Top(_) = self { true } else { false } }
77
78 pub fn on_bottom<F: FnOnce(&PageBlockVerticalAlignmentBottom)>(&self, fnc: F) -> &Self { if let PageBlockVerticalAlignment::Bottom(t) = self { fnc(t) }; self }
79 pub fn on_middle<F: FnOnce(&PageBlockVerticalAlignmentMiddle)>(&self, fnc: F) -> &Self { if let PageBlockVerticalAlignment::Middle(t) = self { fnc(t) }; self }
80 pub fn on_top<F: FnOnce(&PageBlockVerticalAlignmentTop)>(&self, fnc: F) -> &Self { if let PageBlockVerticalAlignment::Top(t) = self { fnc(t) }; self }
81
82 pub fn as_bottom(&self) -> Option<&PageBlockVerticalAlignmentBottom> { if let PageBlockVerticalAlignment::Bottom(t) = self { return Some(t) } None }
83 pub fn as_middle(&self) -> Option<&PageBlockVerticalAlignmentMiddle> { if let PageBlockVerticalAlignment::Middle(t) = self { return Some(t) } None }
84 pub fn as_top(&self) -> Option<&PageBlockVerticalAlignmentTop> { if let PageBlockVerticalAlignment::Top(t) = self { return Some(t) } None }
85
86
87
88 pub fn bottom<T: AsRef<PageBlockVerticalAlignmentBottom>>(t: T) -> Self { PageBlockVerticalAlignment::Bottom(t.as_ref().clone()) }
89
90 pub fn middle<T: AsRef<PageBlockVerticalAlignmentMiddle>>(t: T) -> Self { PageBlockVerticalAlignment::Middle(t.as_ref().clone()) }
91
92 pub fn top<T: AsRef<PageBlockVerticalAlignmentTop>>(t: T) -> Self { PageBlockVerticalAlignment::Top(t.as_ref().clone()) }
93
94}
95
96impl AsRef<PageBlockVerticalAlignment> for PageBlockVerticalAlignment {
97 fn as_ref(&self) -> &PageBlockVerticalAlignment { self }
98}
99
100
101
102
103
104
105
106#[derive(Debug, Clone, Default, Serialize, Deserialize)]
108pub struct PageBlockVerticalAlignmentBottom {
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 PageBlockVerticalAlignmentBottom {
119 #[doc(hidden)] fn td_name(&self) -> &'static str { "pageBlockVerticalAlignmentBottom" }
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 TDPageBlockVerticalAlignment for PageBlockVerticalAlignmentBottom {}
126
127
128
129impl PageBlockVerticalAlignmentBottom {
130 pub fn from_json<S: AsRef<str>>(json: S) -> RTDResult<Self> { Ok(serde_json::from_str(json.as_ref())?) }
131 pub fn builder() -> RTDPageBlockVerticalAlignmentBottomBuilder {
132 let mut inner = PageBlockVerticalAlignmentBottom::default();
133 inner.td_name = "pageBlockVerticalAlignmentBottom".to_string();
134 inner.extra = Some(Uuid::new_v4().to_string());
135 RTDPageBlockVerticalAlignmentBottomBuilder { inner }
136 }
137
138}
139
140#[doc(hidden)]
141pub struct RTDPageBlockVerticalAlignmentBottomBuilder {
142 inner: PageBlockVerticalAlignmentBottom
143}
144
145impl RTDPageBlockVerticalAlignmentBottomBuilder {
146 pub fn build(&self) -> PageBlockVerticalAlignmentBottom { self.inner.clone() }
147
148}
149
150impl AsRef<PageBlockVerticalAlignmentBottom> for PageBlockVerticalAlignmentBottom {
151 fn as_ref(&self) -> &PageBlockVerticalAlignmentBottom { self }
152}
153
154impl AsRef<PageBlockVerticalAlignmentBottom> for RTDPageBlockVerticalAlignmentBottomBuilder {
155 fn as_ref(&self) -> &PageBlockVerticalAlignmentBottom { &self.inner }
156}
157
158
159
160
161
162
163
164#[derive(Debug, Clone, Default, Serialize, Deserialize)]
166pub struct PageBlockVerticalAlignmentMiddle {
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 PageBlockVerticalAlignmentMiddle {
177 #[doc(hidden)] fn td_name(&self) -> &'static str { "pageBlockVerticalAlignmentMiddle" }
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 TDPageBlockVerticalAlignment for PageBlockVerticalAlignmentMiddle {}
184
185
186
187impl PageBlockVerticalAlignmentMiddle {
188 pub fn from_json<S: AsRef<str>>(json: S) -> RTDResult<Self> { Ok(serde_json::from_str(json.as_ref())?) }
189 pub fn builder() -> RTDPageBlockVerticalAlignmentMiddleBuilder {
190 let mut inner = PageBlockVerticalAlignmentMiddle::default();
191 inner.td_name = "pageBlockVerticalAlignmentMiddle".to_string();
192 inner.extra = Some(Uuid::new_v4().to_string());
193 RTDPageBlockVerticalAlignmentMiddleBuilder { inner }
194 }
195
196}
197
198#[doc(hidden)]
199pub struct RTDPageBlockVerticalAlignmentMiddleBuilder {
200 inner: PageBlockVerticalAlignmentMiddle
201}
202
203impl RTDPageBlockVerticalAlignmentMiddleBuilder {
204 pub fn build(&self) -> PageBlockVerticalAlignmentMiddle { self.inner.clone() }
205
206}
207
208impl AsRef<PageBlockVerticalAlignmentMiddle> for PageBlockVerticalAlignmentMiddle {
209 fn as_ref(&self) -> &PageBlockVerticalAlignmentMiddle { self }
210}
211
212impl AsRef<PageBlockVerticalAlignmentMiddle> for RTDPageBlockVerticalAlignmentMiddleBuilder {
213 fn as_ref(&self) -> &PageBlockVerticalAlignmentMiddle { &self.inner }
214}
215
216
217
218
219
220
221
222#[derive(Debug, Clone, Default, Serialize, Deserialize)]
224pub struct PageBlockVerticalAlignmentTop {
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 PageBlockVerticalAlignmentTop {
235 #[doc(hidden)] fn td_name(&self) -> &'static str { "pageBlockVerticalAlignmentTop" }
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 TDPageBlockVerticalAlignment for PageBlockVerticalAlignmentTop {}
242
243
244
245impl PageBlockVerticalAlignmentTop {
246 pub fn from_json<S: AsRef<str>>(json: S) -> RTDResult<Self> { Ok(serde_json::from_str(json.as_ref())?) }
247 pub fn builder() -> RTDPageBlockVerticalAlignmentTopBuilder {
248 let mut inner = PageBlockVerticalAlignmentTop::default();
249 inner.td_name = "pageBlockVerticalAlignmentTop".to_string();
250 inner.extra = Some(Uuid::new_v4().to_string());
251 RTDPageBlockVerticalAlignmentTopBuilder { inner }
252 }
253
254}
255
256#[doc(hidden)]
257pub struct RTDPageBlockVerticalAlignmentTopBuilder {
258 inner: PageBlockVerticalAlignmentTop
259}
260
261impl RTDPageBlockVerticalAlignmentTopBuilder {
262 pub fn build(&self) -> PageBlockVerticalAlignmentTop { self.inner.clone() }
263
264}
265
266impl AsRef<PageBlockVerticalAlignmentTop> for PageBlockVerticalAlignmentTop {
267 fn as_ref(&self) -> &PageBlockVerticalAlignmentTop { self }
268}
269
270impl AsRef<PageBlockVerticalAlignmentTop> for RTDPageBlockVerticalAlignmentTopBuilder {
271 fn as_ref(&self) -> &PageBlockVerticalAlignmentTop { &self.inner }
272}
273
274
275