rtdlib/types/
rich_text.rs

1
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
14/// TRAIT | Describes a text object inside an instant-view web page
15pub trait TDRichText: Debug + RObject {}
16
17/// Describes a text object inside an instant-view web page
18#[derive(Debug, Clone, Serialize)]
19#[serde(untagged)]
20pub enum RichText {
21  #[doc(hidden)] _Default(()),
22  /// An anchor
23  Anchor(RichTextAnchor),
24  /// A link to an anchor on the same web page
25  AnchorLink(RichTextAnchorLink),
26  /// A bold rich text
27  Bold(RichTextBold),
28  /// A rich text email link
29  EmailAddress(RichTextEmailAddress),
30  /// A fixed-width rich text
31  Fixed(RichTextFixed),
32  /// A small image inside the text
33  Icon(RichTextIcon),
34  /// An italicized rich text
35  Italic(RichTextItalic),
36  /// A marked rich text
37  Marked(RichTextMarked),
38  /// A rich text phone number
39  PhoneNumber(RichTextPhoneNumber),
40  /// A plain text
41  Plain(RichTextPlain),
42  /// A reference to a richTexts object on the same web page
43  Reference(RichTextReference),
44  /// A strikethrough rich text
45  Strikethrough(RichTextStrikethrough),
46  /// A subscript rich text
47  Subscript(RichTextSubscript),
48  /// A superscript rich text
49  Superscript(RichTextSuperscript),
50  /// An underlined rich text
51  Underline(RichTextUnderline),
52  /// A rich text URL link
53  Url(RichTextUrl),
54  /// A concatenation of rich texts
55  RichTexts(RichTexts),
56
57}
58
59impl Default for RichText {
60  fn default() -> Self { RichText::_Default(()) }
61}
62
63impl<'de> Deserialize<'de> for RichText {
64  fn deserialize<D>(deserializer: D) -> Result<RichText, D::Error> where D: Deserializer<'de> {
65    use serde::de::Error;
66    rtd_enum_deserialize!(
67      RichText,
68      (richTextAnchor, Anchor);
69      (richTextAnchorLink, AnchorLink);
70      (richTextBold, Bold);
71      (richTextEmailAddress, EmailAddress);
72      (richTextFixed, Fixed);
73      (richTextIcon, Icon);
74      (richTextItalic, Italic);
75      (richTextMarked, Marked);
76      (richTextPhoneNumber, PhoneNumber);
77      (richTextPlain, Plain);
78      (richTextReference, Reference);
79      (richTextStrikethrough, Strikethrough);
80      (richTextSubscript, Subscript);
81      (richTextSuperscript, Superscript);
82      (richTextUnderline, Underline);
83      (richTextUrl, Url);
84      (richTexts, RichTexts);
85
86    )(deserializer)
87  }
88}
89
90impl RObject for RichText {
91  #[doc(hidden)] fn td_name(&self) -> &'static str {
92    match self {
93      RichText::Anchor(t) => t.td_name(),
94      RichText::AnchorLink(t) => t.td_name(),
95      RichText::Bold(t) => t.td_name(),
96      RichText::EmailAddress(t) => t.td_name(),
97      RichText::Fixed(t) => t.td_name(),
98      RichText::Icon(t) => t.td_name(),
99      RichText::Italic(t) => t.td_name(),
100      RichText::Marked(t) => t.td_name(),
101      RichText::PhoneNumber(t) => t.td_name(),
102      RichText::Plain(t) => t.td_name(),
103      RichText::Reference(t) => t.td_name(),
104      RichText::Strikethrough(t) => t.td_name(),
105      RichText::Subscript(t) => t.td_name(),
106      RichText::Superscript(t) => t.td_name(),
107      RichText::Underline(t) => t.td_name(),
108      RichText::Url(t) => t.td_name(),
109      RichText::RichTexts(t) => t.td_name(),
110
111      _ => "-1",
112    }
113  }
114  #[doc(hidden)] fn extra(&self) -> Option<String> {
115    match self {
116      RichText::Anchor(t) => t.extra(),
117      RichText::AnchorLink(t) => t.extra(),
118      RichText::Bold(t) => t.extra(),
119      RichText::EmailAddress(t) => t.extra(),
120      RichText::Fixed(t) => t.extra(),
121      RichText::Icon(t) => t.extra(),
122      RichText::Italic(t) => t.extra(),
123      RichText::Marked(t) => t.extra(),
124      RichText::PhoneNumber(t) => t.extra(),
125      RichText::Plain(t) => t.extra(),
126      RichText::Reference(t) => t.extra(),
127      RichText::Strikethrough(t) => t.extra(),
128      RichText::Subscript(t) => t.extra(),
129      RichText::Superscript(t) => t.extra(),
130      RichText::Underline(t) => t.extra(),
131      RichText::Url(t) => t.extra(),
132      RichText::RichTexts(t) => t.extra(),
133
134      _ => None,
135    }
136  }
137  fn to_json(&self) -> RTDResult<String> { Ok(serde_json::to_string(self)?) }
138}
139
140impl RichText {
141  pub fn from_json<S: AsRef<str>>(json: S) -> RTDResult<Self> { Ok(serde_json::from_str(json.as_ref())?) }
142  #[doc(hidden)] pub fn _is_default(&self) -> bool { if let RichText::_Default(_) = self { true } else { false } }
143
144  pub fn is_anchor(&self) -> bool { if let RichText::Anchor(_) = self { true } else { false } }
145  pub fn is_anchor_link(&self) -> bool { if let RichText::AnchorLink(_) = self { true } else { false } }
146  pub fn is_bold(&self) -> bool { if let RichText::Bold(_) = self { true } else { false } }
147  pub fn is_email_address(&self) -> bool { if let RichText::EmailAddress(_) = self { true } else { false } }
148  pub fn is_fixed(&self) -> bool { if let RichText::Fixed(_) = self { true } else { false } }
149  pub fn is_icon(&self) -> bool { if let RichText::Icon(_) = self { true } else { false } }
150  pub fn is_italic(&self) -> bool { if let RichText::Italic(_) = self { true } else { false } }
151  pub fn is_marked(&self) -> bool { if let RichText::Marked(_) = self { true } else { false } }
152  pub fn is_phone_number(&self) -> bool { if let RichText::PhoneNumber(_) = self { true } else { false } }
153  pub fn is_plain(&self) -> bool { if let RichText::Plain(_) = self { true } else { false } }
154  pub fn is_reference(&self) -> bool { if let RichText::Reference(_) = self { true } else { false } }
155  pub fn is_strikethrough(&self) -> bool { if let RichText::Strikethrough(_) = self { true } else { false } }
156  pub fn is_subscript(&self) -> bool { if let RichText::Subscript(_) = self { true } else { false } }
157  pub fn is_superscript(&self) -> bool { if let RichText::Superscript(_) = self { true } else { false } }
158  pub fn is_underline(&self) -> bool { if let RichText::Underline(_) = self { true } else { false } }
159  pub fn is_url(&self) -> bool { if let RichText::Url(_) = self { true } else { false } }
160  pub fn is_rich_texts(&self) -> bool { if let RichText::RichTexts(_) = self { true } else { false } }
161
162  pub fn on_anchor<F: FnOnce(&RichTextAnchor)>(&self, fnc: F) -> &Self { if let RichText::Anchor(t) = self { fnc(t) }; self }
163  pub fn on_anchor_link<F: FnOnce(&RichTextAnchorLink)>(&self, fnc: F) -> &Self { if let RichText::AnchorLink(t) = self { fnc(t) }; self }
164  pub fn on_bold<F: FnOnce(&RichTextBold)>(&self, fnc: F) -> &Self { if let RichText::Bold(t) = self { fnc(t) }; self }
165  pub fn on_email_address<F: FnOnce(&RichTextEmailAddress)>(&self, fnc: F) -> &Self { if let RichText::EmailAddress(t) = self { fnc(t) }; self }
166  pub fn on_fixed<F: FnOnce(&RichTextFixed)>(&self, fnc: F) -> &Self { if let RichText::Fixed(t) = self { fnc(t) }; self }
167  pub fn on_icon<F: FnOnce(&RichTextIcon)>(&self, fnc: F) -> &Self { if let RichText::Icon(t) = self { fnc(t) }; self }
168  pub fn on_italic<F: FnOnce(&RichTextItalic)>(&self, fnc: F) -> &Self { if let RichText::Italic(t) = self { fnc(t) }; self }
169  pub fn on_marked<F: FnOnce(&RichTextMarked)>(&self, fnc: F) -> &Self { if let RichText::Marked(t) = self { fnc(t) }; self }
170  pub fn on_phone_number<F: FnOnce(&RichTextPhoneNumber)>(&self, fnc: F) -> &Self { if let RichText::PhoneNumber(t) = self { fnc(t) }; self }
171  pub fn on_plain<F: FnOnce(&RichTextPlain)>(&self, fnc: F) -> &Self { if let RichText::Plain(t) = self { fnc(t) }; self }
172  pub fn on_reference<F: FnOnce(&RichTextReference)>(&self, fnc: F) -> &Self { if let RichText::Reference(t) = self { fnc(t) }; self }
173  pub fn on_strikethrough<F: FnOnce(&RichTextStrikethrough)>(&self, fnc: F) -> &Self { if let RichText::Strikethrough(t) = self { fnc(t) }; self }
174  pub fn on_subscript<F: FnOnce(&RichTextSubscript)>(&self, fnc: F) -> &Self { if let RichText::Subscript(t) = self { fnc(t) }; self }
175  pub fn on_superscript<F: FnOnce(&RichTextSuperscript)>(&self, fnc: F) -> &Self { if let RichText::Superscript(t) = self { fnc(t) }; self }
176  pub fn on_underline<F: FnOnce(&RichTextUnderline)>(&self, fnc: F) -> &Self { if let RichText::Underline(t) = self { fnc(t) }; self }
177  pub fn on_url<F: FnOnce(&RichTextUrl)>(&self, fnc: F) -> &Self { if let RichText::Url(t) = self { fnc(t) }; self }
178  pub fn on_rich_texts<F: FnOnce(&RichTexts)>(&self, fnc: F) -> &Self { if let RichText::RichTexts(t) = self { fnc(t) }; self }
179
180  pub fn as_anchor(&self) -> Option<&RichTextAnchor> { if let RichText::Anchor(t) = self { return Some(t) } None }
181  pub fn as_anchor_link(&self) -> Option<&RichTextAnchorLink> { if let RichText::AnchorLink(t) = self { return Some(t) } None }
182  pub fn as_bold(&self) -> Option<&RichTextBold> { if let RichText::Bold(t) = self { return Some(t) } None }
183  pub fn as_email_address(&self) -> Option<&RichTextEmailAddress> { if let RichText::EmailAddress(t) = self { return Some(t) } None }
184  pub fn as_fixed(&self) -> Option<&RichTextFixed> { if let RichText::Fixed(t) = self { return Some(t) } None }
185  pub fn as_icon(&self) -> Option<&RichTextIcon> { if let RichText::Icon(t) = self { return Some(t) } None }
186  pub fn as_italic(&self) -> Option<&RichTextItalic> { if let RichText::Italic(t) = self { return Some(t) } None }
187  pub fn as_marked(&self) -> Option<&RichTextMarked> { if let RichText::Marked(t) = self { return Some(t) } None }
188  pub fn as_phone_number(&self) -> Option<&RichTextPhoneNumber> { if let RichText::PhoneNumber(t) = self { return Some(t) } None }
189  pub fn as_plain(&self) -> Option<&RichTextPlain> { if let RichText::Plain(t) = self { return Some(t) } None }
190  pub fn as_reference(&self) -> Option<&RichTextReference> { if let RichText::Reference(t) = self { return Some(t) } None }
191  pub fn as_strikethrough(&self) -> Option<&RichTextStrikethrough> { if let RichText::Strikethrough(t) = self { return Some(t) } None }
192  pub fn as_subscript(&self) -> Option<&RichTextSubscript> { if let RichText::Subscript(t) = self { return Some(t) } None }
193  pub fn as_superscript(&self) -> Option<&RichTextSuperscript> { if let RichText::Superscript(t) = self { return Some(t) } None }
194  pub fn as_underline(&self) -> Option<&RichTextUnderline> { if let RichText::Underline(t) = self { return Some(t) } None }
195  pub fn as_url(&self) -> Option<&RichTextUrl> { if let RichText::Url(t) = self { return Some(t) } None }
196  pub fn as_rich_texts(&self) -> Option<&RichTexts> { if let RichText::RichTexts(t) = self { return Some(t) } None }
197
198
199
200  pub fn anchor<T: AsRef<RichTextAnchor>>(t: T) -> Self { RichText::Anchor(t.as_ref().clone()) }
201
202  pub fn anchor_link<T: AsRef<RichTextAnchorLink>>(t: T) -> Self { RichText::AnchorLink(t.as_ref().clone()) }
203
204  pub fn bold<T: AsRef<RichTextBold>>(t: T) -> Self { RichText::Bold(t.as_ref().clone()) }
205
206  pub fn email_address<T: AsRef<RichTextEmailAddress>>(t: T) -> Self { RichText::EmailAddress(t.as_ref().clone()) }
207
208  pub fn fixed<T: AsRef<RichTextFixed>>(t: T) -> Self { RichText::Fixed(t.as_ref().clone()) }
209
210  pub fn icon<T: AsRef<RichTextIcon>>(t: T) -> Self { RichText::Icon(t.as_ref().clone()) }
211
212  pub fn italic<T: AsRef<RichTextItalic>>(t: T) -> Self { RichText::Italic(t.as_ref().clone()) }
213
214  pub fn marked<T: AsRef<RichTextMarked>>(t: T) -> Self { RichText::Marked(t.as_ref().clone()) }
215
216  pub fn phone_number<T: AsRef<RichTextPhoneNumber>>(t: T) -> Self { RichText::PhoneNumber(t.as_ref().clone()) }
217
218  pub fn plain<T: AsRef<RichTextPlain>>(t: T) -> Self { RichText::Plain(t.as_ref().clone()) }
219
220  pub fn reference<T: AsRef<RichTextReference>>(t: T) -> Self { RichText::Reference(t.as_ref().clone()) }
221
222  pub fn strikethrough<T: AsRef<RichTextStrikethrough>>(t: T) -> Self { RichText::Strikethrough(t.as_ref().clone()) }
223
224  pub fn subscript<T: AsRef<RichTextSubscript>>(t: T) -> Self { RichText::Subscript(t.as_ref().clone()) }
225
226  pub fn superscript<T: AsRef<RichTextSuperscript>>(t: T) -> Self { RichText::Superscript(t.as_ref().clone()) }
227
228  pub fn underline<T: AsRef<RichTextUnderline>>(t: T) -> Self { RichText::Underline(t.as_ref().clone()) }
229
230  pub fn url<T: AsRef<RichTextUrl>>(t: T) -> Self { RichText::Url(t.as_ref().clone()) }
231
232  pub fn rich_texts<T: AsRef<RichTexts>>(t: T) -> Self { RichText::RichTexts(t.as_ref().clone()) }
233
234}
235
236impl AsRef<RichText> for RichText {
237  fn as_ref(&self) -> &RichText { self }
238}
239
240
241
242
243
244
245
246/// An anchor
247#[derive(Debug, Clone, Default, Serialize, Deserialize)]
248pub struct RichTextAnchor {
249  #[doc(hidden)]
250  #[serde(rename(serialize = "@type", deserialize = "@type"))]
251  td_name: String,
252  #[doc(hidden)]
253  #[serde(rename(serialize = "@extra", deserialize = "@extra"))]
254  extra: Option<String>,
255  /// Anchor name
256  name: String,
257  
258}
259
260impl RObject for RichTextAnchor {
261  #[doc(hidden)] fn td_name(&self) -> &'static str { "richTextAnchor" }
262  #[doc(hidden)] fn extra(&self) -> Option<String> { self.extra.clone() }
263  fn to_json(&self) -> RTDResult<String> { Ok(serde_json::to_string(self)?) }
264}
265
266
267impl TDRichText for RichTextAnchor {}
268
269
270
271impl RichTextAnchor {
272  pub fn from_json<S: AsRef<str>>(json: S) -> RTDResult<Self> { Ok(serde_json::from_str(json.as_ref())?) }
273  pub fn builder() -> RTDRichTextAnchorBuilder {
274    let mut inner = RichTextAnchor::default();
275    inner.td_name = "richTextAnchor".to_string();
276    inner.extra = Some(Uuid::new_v4().to_string());
277    RTDRichTextAnchorBuilder { inner }
278  }
279
280  pub fn name(&self) -> &String { &self.name }
281
282}
283
284#[doc(hidden)]
285pub struct RTDRichTextAnchorBuilder {
286  inner: RichTextAnchor
287}
288
289impl RTDRichTextAnchorBuilder {
290  pub fn build(&self) -> RichTextAnchor { self.inner.clone() }
291
292   
293  pub fn name<T: AsRef<str>>(&mut self, name: T) -> &mut Self {
294    self.inner.name = name.as_ref().to_string();
295    self
296  }
297
298}
299
300impl AsRef<RichTextAnchor> for RichTextAnchor {
301  fn as_ref(&self) -> &RichTextAnchor { self }
302}
303
304impl AsRef<RichTextAnchor> for RTDRichTextAnchorBuilder {
305  fn as_ref(&self) -> &RichTextAnchor { &self.inner }
306}
307
308
309
310
311
312
313
314/// A link to an anchor on the same web page
315#[derive(Debug, Clone, Default, Serialize, Deserialize)]
316pub struct RichTextAnchorLink {
317  #[doc(hidden)]
318  #[serde(rename(serialize = "@type", deserialize = "@type"))]
319  td_name: String,
320  #[doc(hidden)]
321  #[serde(rename(serialize = "@extra", deserialize = "@extra"))]
322  extra: Option<String>,
323  /// The link text
324  text: Box<RichText>,
325  /// The anchor name. If the name is empty, the link must bring back to top
326  anchor_name: String,
327  /// An HTTP URL, opening the anchor
328  url: String,
329  
330}
331
332impl RObject for RichTextAnchorLink {
333  #[doc(hidden)] fn td_name(&self) -> &'static str { "richTextAnchorLink" }
334  #[doc(hidden)] fn extra(&self) -> Option<String> { self.extra.clone() }
335  fn to_json(&self) -> RTDResult<String> { Ok(serde_json::to_string(self)?) }
336}
337
338
339impl TDRichText for RichTextAnchorLink {}
340
341
342
343impl RichTextAnchorLink {
344  pub fn from_json<S: AsRef<str>>(json: S) -> RTDResult<Self> { Ok(serde_json::from_str(json.as_ref())?) }
345  pub fn builder() -> RTDRichTextAnchorLinkBuilder {
346    let mut inner = RichTextAnchorLink::default();
347    inner.td_name = "richTextAnchorLink".to_string();
348    inner.extra = Some(Uuid::new_v4().to_string());
349    RTDRichTextAnchorLinkBuilder { inner }
350  }
351
352  pub fn text(&self) -> &Box<RichText> { &self.text }
353
354  pub fn anchor_name(&self) -> &String { &self.anchor_name }
355
356  pub fn url(&self) -> &String { &self.url }
357
358}
359
360#[doc(hidden)]
361pub struct RTDRichTextAnchorLinkBuilder {
362  inner: RichTextAnchorLink
363}
364
365impl RTDRichTextAnchorLinkBuilder {
366  pub fn build(&self) -> RichTextAnchorLink { self.inner.clone() }
367
368   
369  pub fn text<T: AsRef<Box<RichText>>>(&mut self, text: T) -> &mut Self {
370    self.inner.text = text.as_ref().clone();
371    self
372  }
373
374   
375  pub fn anchor_name<T: AsRef<str>>(&mut self, anchor_name: T) -> &mut Self {
376    self.inner.anchor_name = anchor_name.as_ref().to_string();
377    self
378  }
379
380   
381  pub fn url<T: AsRef<str>>(&mut self, url: T) -> &mut Self {
382    self.inner.url = url.as_ref().to_string();
383    self
384  }
385
386}
387
388impl AsRef<RichTextAnchorLink> for RichTextAnchorLink {
389  fn as_ref(&self) -> &RichTextAnchorLink { self }
390}
391
392impl AsRef<RichTextAnchorLink> for RTDRichTextAnchorLinkBuilder {
393  fn as_ref(&self) -> &RichTextAnchorLink { &self.inner }
394}
395
396
397
398
399
400
401
402/// A bold rich text
403#[derive(Debug, Clone, Default, Serialize, Deserialize)]
404pub struct RichTextBold {
405  #[doc(hidden)]
406  #[serde(rename(serialize = "@type", deserialize = "@type"))]
407  td_name: String,
408  #[doc(hidden)]
409  #[serde(rename(serialize = "@extra", deserialize = "@extra"))]
410  extra: Option<String>,
411  /// Text
412  text: Box<RichText>,
413  
414}
415
416impl RObject for RichTextBold {
417  #[doc(hidden)] fn td_name(&self) -> &'static str { "richTextBold" }
418  #[doc(hidden)] fn extra(&self) -> Option<String> { self.extra.clone() }
419  fn to_json(&self) -> RTDResult<String> { Ok(serde_json::to_string(self)?) }
420}
421
422
423impl TDRichText for RichTextBold {}
424
425
426
427impl RichTextBold {
428  pub fn from_json<S: AsRef<str>>(json: S) -> RTDResult<Self> { Ok(serde_json::from_str(json.as_ref())?) }
429  pub fn builder() -> RTDRichTextBoldBuilder {
430    let mut inner = RichTextBold::default();
431    inner.td_name = "richTextBold".to_string();
432    inner.extra = Some(Uuid::new_v4().to_string());
433    RTDRichTextBoldBuilder { inner }
434  }
435
436  pub fn text(&self) -> &Box<RichText> { &self.text }
437
438}
439
440#[doc(hidden)]
441pub struct RTDRichTextBoldBuilder {
442  inner: RichTextBold
443}
444
445impl RTDRichTextBoldBuilder {
446  pub fn build(&self) -> RichTextBold { self.inner.clone() }
447
448   
449  pub fn text<T: AsRef<Box<RichText>>>(&mut self, text: T) -> &mut Self {
450    self.inner.text = text.as_ref().clone();
451    self
452  }
453
454}
455
456impl AsRef<RichTextBold> for RichTextBold {
457  fn as_ref(&self) -> &RichTextBold { self }
458}
459
460impl AsRef<RichTextBold> for RTDRichTextBoldBuilder {
461  fn as_ref(&self) -> &RichTextBold { &self.inner }
462}
463
464
465
466
467
468
469
470/// A rich text email link
471#[derive(Debug, Clone, Default, Serialize, Deserialize)]
472pub struct RichTextEmailAddress {
473  #[doc(hidden)]
474  #[serde(rename(serialize = "@type", deserialize = "@type"))]
475  td_name: String,
476  #[doc(hidden)]
477  #[serde(rename(serialize = "@extra", deserialize = "@extra"))]
478  extra: Option<String>,
479  /// Text
480  text: Box<RichText>,
481  /// Email address
482  email_address: String,
483  
484}
485
486impl RObject for RichTextEmailAddress {
487  #[doc(hidden)] fn td_name(&self) -> &'static str { "richTextEmailAddress" }
488  #[doc(hidden)] fn extra(&self) -> Option<String> { self.extra.clone() }
489  fn to_json(&self) -> RTDResult<String> { Ok(serde_json::to_string(self)?) }
490}
491
492
493impl TDRichText for RichTextEmailAddress {}
494
495
496
497impl RichTextEmailAddress {
498  pub fn from_json<S: AsRef<str>>(json: S) -> RTDResult<Self> { Ok(serde_json::from_str(json.as_ref())?) }
499  pub fn builder() -> RTDRichTextEmailAddressBuilder {
500    let mut inner = RichTextEmailAddress::default();
501    inner.td_name = "richTextEmailAddress".to_string();
502    inner.extra = Some(Uuid::new_v4().to_string());
503    RTDRichTextEmailAddressBuilder { inner }
504  }
505
506  pub fn text(&self) -> &Box<RichText> { &self.text }
507
508  pub fn email_address(&self) -> &String { &self.email_address }
509
510}
511
512#[doc(hidden)]
513pub struct RTDRichTextEmailAddressBuilder {
514  inner: RichTextEmailAddress
515}
516
517impl RTDRichTextEmailAddressBuilder {
518  pub fn build(&self) -> RichTextEmailAddress { self.inner.clone() }
519
520   
521  pub fn text<T: AsRef<Box<RichText>>>(&mut self, text: T) -> &mut Self {
522    self.inner.text = text.as_ref().clone();
523    self
524  }
525
526   
527  pub fn email_address<T: AsRef<str>>(&mut self, email_address: T) -> &mut Self {
528    self.inner.email_address = email_address.as_ref().to_string();
529    self
530  }
531
532}
533
534impl AsRef<RichTextEmailAddress> for RichTextEmailAddress {
535  fn as_ref(&self) -> &RichTextEmailAddress { self }
536}
537
538impl AsRef<RichTextEmailAddress> for RTDRichTextEmailAddressBuilder {
539  fn as_ref(&self) -> &RichTextEmailAddress { &self.inner }
540}
541
542
543
544
545
546
547
548/// A fixed-width rich text
549#[derive(Debug, Clone, Default, Serialize, Deserialize)]
550pub struct RichTextFixed {
551  #[doc(hidden)]
552  #[serde(rename(serialize = "@type", deserialize = "@type"))]
553  td_name: String,
554  #[doc(hidden)]
555  #[serde(rename(serialize = "@extra", deserialize = "@extra"))]
556  extra: Option<String>,
557  /// Text
558  text: Box<RichText>,
559  
560}
561
562impl RObject for RichTextFixed {
563  #[doc(hidden)] fn td_name(&self) -> &'static str { "richTextFixed" }
564  #[doc(hidden)] fn extra(&self) -> Option<String> { self.extra.clone() }
565  fn to_json(&self) -> RTDResult<String> { Ok(serde_json::to_string(self)?) }
566}
567
568
569impl TDRichText for RichTextFixed {}
570
571
572
573impl RichTextFixed {
574  pub fn from_json<S: AsRef<str>>(json: S) -> RTDResult<Self> { Ok(serde_json::from_str(json.as_ref())?) }
575  pub fn builder() -> RTDRichTextFixedBuilder {
576    let mut inner = RichTextFixed::default();
577    inner.td_name = "richTextFixed".to_string();
578    inner.extra = Some(Uuid::new_v4().to_string());
579    RTDRichTextFixedBuilder { inner }
580  }
581
582  pub fn text(&self) -> &Box<RichText> { &self.text }
583
584}
585
586#[doc(hidden)]
587pub struct RTDRichTextFixedBuilder {
588  inner: RichTextFixed
589}
590
591impl RTDRichTextFixedBuilder {
592  pub fn build(&self) -> RichTextFixed { self.inner.clone() }
593
594   
595  pub fn text<T: AsRef<Box<RichText>>>(&mut self, text: T) -> &mut Self {
596    self.inner.text = text.as_ref().clone();
597    self
598  }
599
600}
601
602impl AsRef<RichTextFixed> for RichTextFixed {
603  fn as_ref(&self) -> &RichTextFixed { self }
604}
605
606impl AsRef<RichTextFixed> for RTDRichTextFixedBuilder {
607  fn as_ref(&self) -> &RichTextFixed { &self.inner }
608}
609
610
611
612
613
614
615
616/// A small image inside the text
617#[derive(Debug, Clone, Default, Serialize, Deserialize)]
618pub struct RichTextIcon {
619  #[doc(hidden)]
620  #[serde(rename(serialize = "@type", deserialize = "@type"))]
621  td_name: String,
622  #[doc(hidden)]
623  #[serde(rename(serialize = "@extra", deserialize = "@extra"))]
624  extra: Option<String>,
625  /// The image represented as a document. The image can be in GIF, JPEG or PNG format
626  document: Document,
627  /// Width of a bounding box in which the image must be shown; 0 if unknown
628  width: i64,
629  /// Height of a bounding box in which the image must be shown; 0 if unknown
630  height: i64,
631  
632}
633
634impl RObject for RichTextIcon {
635  #[doc(hidden)] fn td_name(&self) -> &'static str { "richTextIcon" }
636  #[doc(hidden)] fn extra(&self) -> Option<String> { self.extra.clone() }
637  fn to_json(&self) -> RTDResult<String> { Ok(serde_json::to_string(self)?) }
638}
639
640
641impl TDRichText for RichTextIcon {}
642
643
644
645impl RichTextIcon {
646  pub fn from_json<S: AsRef<str>>(json: S) -> RTDResult<Self> { Ok(serde_json::from_str(json.as_ref())?) }
647  pub fn builder() -> RTDRichTextIconBuilder {
648    let mut inner = RichTextIcon::default();
649    inner.td_name = "richTextIcon".to_string();
650    inner.extra = Some(Uuid::new_v4().to_string());
651    RTDRichTextIconBuilder { inner }
652  }
653
654  pub fn document(&self) -> &Document { &self.document }
655
656  pub fn width(&self) -> i64 { self.width }
657
658  pub fn height(&self) -> i64 { self.height }
659
660}
661
662#[doc(hidden)]
663pub struct RTDRichTextIconBuilder {
664  inner: RichTextIcon
665}
666
667impl RTDRichTextIconBuilder {
668  pub fn build(&self) -> RichTextIcon { self.inner.clone() }
669
670   
671  pub fn document<T: AsRef<Document>>(&mut self, document: T) -> &mut Self {
672    self.inner.document = document.as_ref().clone();
673    self
674  }
675
676   
677  pub fn width(&mut self, width: i64) -> &mut Self {
678    self.inner.width = width;
679    self
680  }
681
682   
683  pub fn height(&mut self, height: i64) -> &mut Self {
684    self.inner.height = height;
685    self
686  }
687
688}
689
690impl AsRef<RichTextIcon> for RichTextIcon {
691  fn as_ref(&self) -> &RichTextIcon { self }
692}
693
694impl AsRef<RichTextIcon> for RTDRichTextIconBuilder {
695  fn as_ref(&self) -> &RichTextIcon { &self.inner }
696}
697
698
699
700
701
702
703
704/// An italicized rich text
705#[derive(Debug, Clone, Default, Serialize, Deserialize)]
706pub struct RichTextItalic {
707  #[doc(hidden)]
708  #[serde(rename(serialize = "@type", deserialize = "@type"))]
709  td_name: String,
710  #[doc(hidden)]
711  #[serde(rename(serialize = "@extra", deserialize = "@extra"))]
712  extra: Option<String>,
713  /// Text
714  text: Box<RichText>,
715  
716}
717
718impl RObject for RichTextItalic {
719  #[doc(hidden)] fn td_name(&self) -> &'static str { "richTextItalic" }
720  #[doc(hidden)] fn extra(&self) -> Option<String> { self.extra.clone() }
721  fn to_json(&self) -> RTDResult<String> { Ok(serde_json::to_string(self)?) }
722}
723
724
725impl TDRichText for RichTextItalic {}
726
727
728
729impl RichTextItalic {
730  pub fn from_json<S: AsRef<str>>(json: S) -> RTDResult<Self> { Ok(serde_json::from_str(json.as_ref())?) }
731  pub fn builder() -> RTDRichTextItalicBuilder {
732    let mut inner = RichTextItalic::default();
733    inner.td_name = "richTextItalic".to_string();
734    inner.extra = Some(Uuid::new_v4().to_string());
735    RTDRichTextItalicBuilder { inner }
736  }
737
738  pub fn text(&self) -> &Box<RichText> { &self.text }
739
740}
741
742#[doc(hidden)]
743pub struct RTDRichTextItalicBuilder {
744  inner: RichTextItalic
745}
746
747impl RTDRichTextItalicBuilder {
748  pub fn build(&self) -> RichTextItalic { self.inner.clone() }
749
750   
751  pub fn text<T: AsRef<Box<RichText>>>(&mut self, text: T) -> &mut Self {
752    self.inner.text = text.as_ref().clone();
753    self
754  }
755
756}
757
758impl AsRef<RichTextItalic> for RichTextItalic {
759  fn as_ref(&self) -> &RichTextItalic { self }
760}
761
762impl AsRef<RichTextItalic> for RTDRichTextItalicBuilder {
763  fn as_ref(&self) -> &RichTextItalic { &self.inner }
764}
765
766
767
768
769
770
771
772/// A marked rich text
773#[derive(Debug, Clone, Default, Serialize, Deserialize)]
774pub struct RichTextMarked {
775  #[doc(hidden)]
776  #[serde(rename(serialize = "@type", deserialize = "@type"))]
777  td_name: String,
778  #[doc(hidden)]
779  #[serde(rename(serialize = "@extra", deserialize = "@extra"))]
780  extra: Option<String>,
781  /// Text
782  text: Box<RichText>,
783  
784}
785
786impl RObject for RichTextMarked {
787  #[doc(hidden)] fn td_name(&self) -> &'static str { "richTextMarked" }
788  #[doc(hidden)] fn extra(&self) -> Option<String> { self.extra.clone() }
789  fn to_json(&self) -> RTDResult<String> { Ok(serde_json::to_string(self)?) }
790}
791
792
793impl TDRichText for RichTextMarked {}
794
795
796
797impl RichTextMarked {
798  pub fn from_json<S: AsRef<str>>(json: S) -> RTDResult<Self> { Ok(serde_json::from_str(json.as_ref())?) }
799  pub fn builder() -> RTDRichTextMarkedBuilder {
800    let mut inner = RichTextMarked::default();
801    inner.td_name = "richTextMarked".to_string();
802    inner.extra = Some(Uuid::new_v4().to_string());
803    RTDRichTextMarkedBuilder { inner }
804  }
805
806  pub fn text(&self) -> &Box<RichText> { &self.text }
807
808}
809
810#[doc(hidden)]
811pub struct RTDRichTextMarkedBuilder {
812  inner: RichTextMarked
813}
814
815impl RTDRichTextMarkedBuilder {
816  pub fn build(&self) -> RichTextMarked { self.inner.clone() }
817
818   
819  pub fn text<T: AsRef<Box<RichText>>>(&mut self, text: T) -> &mut Self {
820    self.inner.text = text.as_ref().clone();
821    self
822  }
823
824}
825
826impl AsRef<RichTextMarked> for RichTextMarked {
827  fn as_ref(&self) -> &RichTextMarked { self }
828}
829
830impl AsRef<RichTextMarked> for RTDRichTextMarkedBuilder {
831  fn as_ref(&self) -> &RichTextMarked { &self.inner }
832}
833
834
835
836
837
838
839
840/// A rich text phone number
841#[derive(Debug, Clone, Default, Serialize, Deserialize)]
842pub struct RichTextPhoneNumber {
843  #[doc(hidden)]
844  #[serde(rename(serialize = "@type", deserialize = "@type"))]
845  td_name: String,
846  #[doc(hidden)]
847  #[serde(rename(serialize = "@extra", deserialize = "@extra"))]
848  extra: Option<String>,
849  /// Text
850  text: Box<RichText>,
851  /// Phone number
852  phone_number: String,
853  
854}
855
856impl RObject for RichTextPhoneNumber {
857  #[doc(hidden)] fn td_name(&self) -> &'static str { "richTextPhoneNumber" }
858  #[doc(hidden)] fn extra(&self) -> Option<String> { self.extra.clone() }
859  fn to_json(&self) -> RTDResult<String> { Ok(serde_json::to_string(self)?) }
860}
861
862
863impl TDRichText for RichTextPhoneNumber {}
864
865
866
867impl RichTextPhoneNumber {
868  pub fn from_json<S: AsRef<str>>(json: S) -> RTDResult<Self> { Ok(serde_json::from_str(json.as_ref())?) }
869  pub fn builder() -> RTDRichTextPhoneNumberBuilder {
870    let mut inner = RichTextPhoneNumber::default();
871    inner.td_name = "richTextPhoneNumber".to_string();
872    inner.extra = Some(Uuid::new_v4().to_string());
873    RTDRichTextPhoneNumberBuilder { inner }
874  }
875
876  pub fn text(&self) -> &Box<RichText> { &self.text }
877
878  pub fn phone_number(&self) -> &String { &self.phone_number }
879
880}
881
882#[doc(hidden)]
883pub struct RTDRichTextPhoneNumberBuilder {
884  inner: RichTextPhoneNumber
885}
886
887impl RTDRichTextPhoneNumberBuilder {
888  pub fn build(&self) -> RichTextPhoneNumber { self.inner.clone() }
889
890   
891  pub fn text<T: AsRef<Box<RichText>>>(&mut self, text: T) -> &mut Self {
892    self.inner.text = text.as_ref().clone();
893    self
894  }
895
896   
897  pub fn phone_number<T: AsRef<str>>(&mut self, phone_number: T) -> &mut Self {
898    self.inner.phone_number = phone_number.as_ref().to_string();
899    self
900  }
901
902}
903
904impl AsRef<RichTextPhoneNumber> for RichTextPhoneNumber {
905  fn as_ref(&self) -> &RichTextPhoneNumber { self }
906}
907
908impl AsRef<RichTextPhoneNumber> for RTDRichTextPhoneNumberBuilder {
909  fn as_ref(&self) -> &RichTextPhoneNumber { &self.inner }
910}
911
912
913
914
915
916
917
918/// A plain text
919#[derive(Debug, Clone, Default, Serialize, Deserialize)]
920pub struct RichTextPlain {
921  #[doc(hidden)]
922  #[serde(rename(serialize = "@type", deserialize = "@type"))]
923  td_name: String,
924  #[doc(hidden)]
925  #[serde(rename(serialize = "@extra", deserialize = "@extra"))]
926  extra: Option<String>,
927  /// Text
928  text: Box<RichText>,
929  
930}
931
932impl RObject for RichTextPlain {
933  #[doc(hidden)] fn td_name(&self) -> &'static str { "richTextPlain" }
934  #[doc(hidden)] fn extra(&self) -> Option<String> { self.extra.clone() }
935  fn to_json(&self) -> RTDResult<String> { Ok(serde_json::to_string(self)?) }
936}
937
938
939impl TDRichText for RichTextPlain {}
940
941
942
943impl RichTextPlain {
944  pub fn from_json<S: AsRef<str>>(json: S) -> RTDResult<Self> { Ok(serde_json::from_str(json.as_ref())?) }
945  pub fn builder() -> RTDRichTextPlainBuilder {
946    let mut inner = RichTextPlain::default();
947    inner.td_name = "richTextPlain".to_string();
948    inner.extra = Some(Uuid::new_v4().to_string());
949    RTDRichTextPlainBuilder { inner }
950  }
951
952  pub fn text(&self) -> &Box<RichText> { &self.text }
953
954}
955
956#[doc(hidden)]
957pub struct RTDRichTextPlainBuilder {
958  inner: RichTextPlain
959}
960
961impl RTDRichTextPlainBuilder {
962  pub fn build(&self) -> RichTextPlain { self.inner.clone() }
963
964   
965  pub fn text<T: AsRef<Box<RichText>>>(&mut self, text: T) -> &mut Self {
966    self.inner.text = text.as_ref().clone();
967    self
968  }
969
970}
971
972impl AsRef<RichTextPlain> for RichTextPlain {
973  fn as_ref(&self) -> &RichTextPlain { self }
974}
975
976impl AsRef<RichTextPlain> for RTDRichTextPlainBuilder {
977  fn as_ref(&self) -> &RichTextPlain { &self.inner }
978}
979
980
981
982
983
984
985
986/// A reference to a richTexts object on the same web page
987#[derive(Debug, Clone, Default, Serialize, Deserialize)]
988pub struct RichTextReference {
989  #[doc(hidden)]
990  #[serde(rename(serialize = "@type", deserialize = "@type"))]
991  td_name: String,
992  #[doc(hidden)]
993  #[serde(rename(serialize = "@extra", deserialize = "@extra"))]
994  extra: Option<String>,
995  /// The text
996  text: Box<RichText>,
997  /// The name of a richTextAnchor object, which is the first element of the target richTexts object
998  anchor_name: String,
999  /// An HTTP URL, opening the reference
1000  url: String,
1001  
1002}
1003
1004impl RObject for RichTextReference {
1005  #[doc(hidden)] fn td_name(&self) -> &'static str { "richTextReference" }
1006  #[doc(hidden)] fn extra(&self) -> Option<String> { self.extra.clone() }
1007  fn to_json(&self) -> RTDResult<String> { Ok(serde_json::to_string(self)?) }
1008}
1009
1010
1011impl TDRichText for RichTextReference {}
1012
1013
1014
1015impl RichTextReference {
1016  pub fn from_json<S: AsRef<str>>(json: S) -> RTDResult<Self> { Ok(serde_json::from_str(json.as_ref())?) }
1017  pub fn builder() -> RTDRichTextReferenceBuilder {
1018    let mut inner = RichTextReference::default();
1019    inner.td_name = "richTextReference".to_string();
1020    inner.extra = Some(Uuid::new_v4().to_string());
1021    RTDRichTextReferenceBuilder { inner }
1022  }
1023
1024  pub fn text(&self) -> &Box<RichText> { &self.text }
1025
1026  pub fn anchor_name(&self) -> &String { &self.anchor_name }
1027
1028  pub fn url(&self) -> &String { &self.url }
1029
1030}
1031
1032#[doc(hidden)]
1033pub struct RTDRichTextReferenceBuilder {
1034  inner: RichTextReference
1035}
1036
1037impl RTDRichTextReferenceBuilder {
1038  pub fn build(&self) -> RichTextReference { self.inner.clone() }
1039
1040   
1041  pub fn text<T: AsRef<Box<RichText>>>(&mut self, text: T) -> &mut Self {
1042    self.inner.text = text.as_ref().clone();
1043    self
1044  }
1045
1046   
1047  pub fn anchor_name<T: AsRef<str>>(&mut self, anchor_name: T) -> &mut Self {
1048    self.inner.anchor_name = anchor_name.as_ref().to_string();
1049    self
1050  }
1051
1052   
1053  pub fn url<T: AsRef<str>>(&mut self, url: T) -> &mut Self {
1054    self.inner.url = url.as_ref().to_string();
1055    self
1056  }
1057
1058}
1059
1060impl AsRef<RichTextReference> for RichTextReference {
1061  fn as_ref(&self) -> &RichTextReference { self }
1062}
1063
1064impl AsRef<RichTextReference> for RTDRichTextReferenceBuilder {
1065  fn as_ref(&self) -> &RichTextReference { &self.inner }
1066}
1067
1068
1069
1070
1071
1072
1073
1074/// A strikethrough rich text
1075#[derive(Debug, Clone, Default, Serialize, Deserialize)]
1076pub struct RichTextStrikethrough {
1077  #[doc(hidden)]
1078  #[serde(rename(serialize = "@type", deserialize = "@type"))]
1079  td_name: String,
1080  #[doc(hidden)]
1081  #[serde(rename(serialize = "@extra", deserialize = "@extra"))]
1082  extra: Option<String>,
1083  /// Text
1084  text: Box<RichText>,
1085  
1086}
1087
1088impl RObject for RichTextStrikethrough {
1089  #[doc(hidden)] fn td_name(&self) -> &'static str { "richTextStrikethrough" }
1090  #[doc(hidden)] fn extra(&self) -> Option<String> { self.extra.clone() }
1091  fn to_json(&self) -> RTDResult<String> { Ok(serde_json::to_string(self)?) }
1092}
1093
1094
1095impl TDRichText for RichTextStrikethrough {}
1096
1097
1098
1099impl RichTextStrikethrough {
1100  pub fn from_json<S: AsRef<str>>(json: S) -> RTDResult<Self> { Ok(serde_json::from_str(json.as_ref())?) }
1101  pub fn builder() -> RTDRichTextStrikethroughBuilder {
1102    let mut inner = RichTextStrikethrough::default();
1103    inner.td_name = "richTextStrikethrough".to_string();
1104    inner.extra = Some(Uuid::new_v4().to_string());
1105    RTDRichTextStrikethroughBuilder { inner }
1106  }
1107
1108  pub fn text(&self) -> &Box<RichText> { &self.text }
1109
1110}
1111
1112#[doc(hidden)]
1113pub struct RTDRichTextStrikethroughBuilder {
1114  inner: RichTextStrikethrough
1115}
1116
1117impl RTDRichTextStrikethroughBuilder {
1118  pub fn build(&self) -> RichTextStrikethrough { self.inner.clone() }
1119
1120   
1121  pub fn text<T: AsRef<Box<RichText>>>(&mut self, text: T) -> &mut Self {
1122    self.inner.text = text.as_ref().clone();
1123    self
1124  }
1125
1126}
1127
1128impl AsRef<RichTextStrikethrough> for RichTextStrikethrough {
1129  fn as_ref(&self) -> &RichTextStrikethrough { self }
1130}
1131
1132impl AsRef<RichTextStrikethrough> for RTDRichTextStrikethroughBuilder {
1133  fn as_ref(&self) -> &RichTextStrikethrough { &self.inner }
1134}
1135
1136
1137
1138
1139
1140
1141
1142/// A subscript rich text
1143#[derive(Debug, Clone, Default, Serialize, Deserialize)]
1144pub struct RichTextSubscript {
1145  #[doc(hidden)]
1146  #[serde(rename(serialize = "@type", deserialize = "@type"))]
1147  td_name: String,
1148  #[doc(hidden)]
1149  #[serde(rename(serialize = "@extra", deserialize = "@extra"))]
1150  extra: Option<String>,
1151  /// Text
1152  text: Box<RichText>,
1153  
1154}
1155
1156impl RObject for RichTextSubscript {
1157  #[doc(hidden)] fn td_name(&self) -> &'static str { "richTextSubscript" }
1158  #[doc(hidden)] fn extra(&self) -> Option<String> { self.extra.clone() }
1159  fn to_json(&self) -> RTDResult<String> { Ok(serde_json::to_string(self)?) }
1160}
1161
1162
1163impl TDRichText for RichTextSubscript {}
1164
1165
1166
1167impl RichTextSubscript {
1168  pub fn from_json<S: AsRef<str>>(json: S) -> RTDResult<Self> { Ok(serde_json::from_str(json.as_ref())?) }
1169  pub fn builder() -> RTDRichTextSubscriptBuilder {
1170    let mut inner = RichTextSubscript::default();
1171    inner.td_name = "richTextSubscript".to_string();
1172    inner.extra = Some(Uuid::new_v4().to_string());
1173    RTDRichTextSubscriptBuilder { inner }
1174  }
1175
1176  pub fn text(&self) -> &Box<RichText> { &self.text }
1177
1178}
1179
1180#[doc(hidden)]
1181pub struct RTDRichTextSubscriptBuilder {
1182  inner: RichTextSubscript
1183}
1184
1185impl RTDRichTextSubscriptBuilder {
1186  pub fn build(&self) -> RichTextSubscript { self.inner.clone() }
1187
1188   
1189  pub fn text<T: AsRef<Box<RichText>>>(&mut self, text: T) -> &mut Self {
1190    self.inner.text = text.as_ref().clone();
1191    self
1192  }
1193
1194}
1195
1196impl AsRef<RichTextSubscript> for RichTextSubscript {
1197  fn as_ref(&self) -> &RichTextSubscript { self }
1198}
1199
1200impl AsRef<RichTextSubscript> for RTDRichTextSubscriptBuilder {
1201  fn as_ref(&self) -> &RichTextSubscript { &self.inner }
1202}
1203
1204
1205
1206
1207
1208
1209
1210/// A superscript rich text
1211#[derive(Debug, Clone, Default, Serialize, Deserialize)]
1212pub struct RichTextSuperscript {
1213  #[doc(hidden)]
1214  #[serde(rename(serialize = "@type", deserialize = "@type"))]
1215  td_name: String,
1216  #[doc(hidden)]
1217  #[serde(rename(serialize = "@extra", deserialize = "@extra"))]
1218  extra: Option<String>,
1219  /// Text
1220  text: Box<RichText>,
1221  
1222}
1223
1224impl RObject for RichTextSuperscript {
1225  #[doc(hidden)] fn td_name(&self) -> &'static str { "richTextSuperscript" }
1226  #[doc(hidden)] fn extra(&self) -> Option<String> { self.extra.clone() }
1227  fn to_json(&self) -> RTDResult<String> { Ok(serde_json::to_string(self)?) }
1228}
1229
1230
1231impl TDRichText for RichTextSuperscript {}
1232
1233
1234
1235impl RichTextSuperscript {
1236  pub fn from_json<S: AsRef<str>>(json: S) -> RTDResult<Self> { Ok(serde_json::from_str(json.as_ref())?) }
1237  pub fn builder() -> RTDRichTextSuperscriptBuilder {
1238    let mut inner = RichTextSuperscript::default();
1239    inner.td_name = "richTextSuperscript".to_string();
1240    inner.extra = Some(Uuid::new_v4().to_string());
1241    RTDRichTextSuperscriptBuilder { inner }
1242  }
1243
1244  pub fn text(&self) -> &Box<RichText> { &self.text }
1245
1246}
1247
1248#[doc(hidden)]
1249pub struct RTDRichTextSuperscriptBuilder {
1250  inner: RichTextSuperscript
1251}
1252
1253impl RTDRichTextSuperscriptBuilder {
1254  pub fn build(&self) -> RichTextSuperscript { self.inner.clone() }
1255
1256   
1257  pub fn text<T: AsRef<Box<RichText>>>(&mut self, text: T) -> &mut Self {
1258    self.inner.text = text.as_ref().clone();
1259    self
1260  }
1261
1262}
1263
1264impl AsRef<RichTextSuperscript> for RichTextSuperscript {
1265  fn as_ref(&self) -> &RichTextSuperscript { self }
1266}
1267
1268impl AsRef<RichTextSuperscript> for RTDRichTextSuperscriptBuilder {
1269  fn as_ref(&self) -> &RichTextSuperscript { &self.inner }
1270}
1271
1272
1273
1274
1275
1276
1277
1278/// An underlined rich text
1279#[derive(Debug, Clone, Default, Serialize, Deserialize)]
1280pub struct RichTextUnderline {
1281  #[doc(hidden)]
1282  #[serde(rename(serialize = "@type", deserialize = "@type"))]
1283  td_name: String,
1284  #[doc(hidden)]
1285  #[serde(rename(serialize = "@extra", deserialize = "@extra"))]
1286  extra: Option<String>,
1287  /// Text
1288  text: Box<RichText>,
1289  
1290}
1291
1292impl RObject for RichTextUnderline {
1293  #[doc(hidden)] fn td_name(&self) -> &'static str { "richTextUnderline" }
1294  #[doc(hidden)] fn extra(&self) -> Option<String> { self.extra.clone() }
1295  fn to_json(&self) -> RTDResult<String> { Ok(serde_json::to_string(self)?) }
1296}
1297
1298
1299impl TDRichText for RichTextUnderline {}
1300
1301
1302
1303impl RichTextUnderline {
1304  pub fn from_json<S: AsRef<str>>(json: S) -> RTDResult<Self> { Ok(serde_json::from_str(json.as_ref())?) }
1305  pub fn builder() -> RTDRichTextUnderlineBuilder {
1306    let mut inner = RichTextUnderline::default();
1307    inner.td_name = "richTextUnderline".to_string();
1308    inner.extra = Some(Uuid::new_v4().to_string());
1309    RTDRichTextUnderlineBuilder { inner }
1310  }
1311
1312  pub fn text(&self) -> &Box<RichText> { &self.text }
1313
1314}
1315
1316#[doc(hidden)]
1317pub struct RTDRichTextUnderlineBuilder {
1318  inner: RichTextUnderline
1319}
1320
1321impl RTDRichTextUnderlineBuilder {
1322  pub fn build(&self) -> RichTextUnderline { self.inner.clone() }
1323
1324   
1325  pub fn text<T: AsRef<Box<RichText>>>(&mut self, text: T) -> &mut Self {
1326    self.inner.text = text.as_ref().clone();
1327    self
1328  }
1329
1330}
1331
1332impl AsRef<RichTextUnderline> for RichTextUnderline {
1333  fn as_ref(&self) -> &RichTextUnderline { self }
1334}
1335
1336impl AsRef<RichTextUnderline> for RTDRichTextUnderlineBuilder {
1337  fn as_ref(&self) -> &RichTextUnderline { &self.inner }
1338}
1339
1340
1341
1342
1343
1344
1345
1346/// A rich text URL link
1347#[derive(Debug, Clone, Default, Serialize, Deserialize)]
1348pub struct RichTextUrl {
1349  #[doc(hidden)]
1350  #[serde(rename(serialize = "@type", deserialize = "@type"))]
1351  td_name: String,
1352  #[doc(hidden)]
1353  #[serde(rename(serialize = "@extra", deserialize = "@extra"))]
1354  extra: Option<String>,
1355  /// Text
1356  text: Box<RichText>,
1357  /// URL
1358  url: String,
1359  /// True, if the URL has cached instant view server-side
1360  is_cached: bool,
1361  
1362}
1363
1364impl RObject for RichTextUrl {
1365  #[doc(hidden)] fn td_name(&self) -> &'static str { "richTextUrl" }
1366  #[doc(hidden)] fn extra(&self) -> Option<String> { self.extra.clone() }
1367  fn to_json(&self) -> RTDResult<String> { Ok(serde_json::to_string(self)?) }
1368}
1369
1370
1371impl TDRichText for RichTextUrl {}
1372
1373
1374
1375impl RichTextUrl {
1376  pub fn from_json<S: AsRef<str>>(json: S) -> RTDResult<Self> { Ok(serde_json::from_str(json.as_ref())?) }
1377  pub fn builder() -> RTDRichTextUrlBuilder {
1378    let mut inner = RichTextUrl::default();
1379    inner.td_name = "richTextUrl".to_string();
1380    inner.extra = Some(Uuid::new_v4().to_string());
1381    RTDRichTextUrlBuilder { inner }
1382  }
1383
1384  pub fn text(&self) -> &Box<RichText> { &self.text }
1385
1386  pub fn url(&self) -> &String { &self.url }
1387
1388  pub fn is_cached(&self) -> bool { self.is_cached }
1389
1390}
1391
1392#[doc(hidden)]
1393pub struct RTDRichTextUrlBuilder {
1394  inner: RichTextUrl
1395}
1396
1397impl RTDRichTextUrlBuilder {
1398  pub fn build(&self) -> RichTextUrl { self.inner.clone() }
1399
1400   
1401  pub fn text<T: AsRef<Box<RichText>>>(&mut self, text: T) -> &mut Self {
1402    self.inner.text = text.as_ref().clone();
1403    self
1404  }
1405
1406   
1407  pub fn url<T: AsRef<str>>(&mut self, url: T) -> &mut Self {
1408    self.inner.url = url.as_ref().to_string();
1409    self
1410  }
1411
1412   
1413  pub fn is_cached(&mut self, is_cached: bool) -> &mut Self {
1414    self.inner.is_cached = is_cached;
1415    self
1416  }
1417
1418}
1419
1420impl AsRef<RichTextUrl> for RichTextUrl {
1421  fn as_ref(&self) -> &RichTextUrl { self }
1422}
1423
1424impl AsRef<RichTextUrl> for RTDRichTextUrlBuilder {
1425  fn as_ref(&self) -> &RichTextUrl { &self.inner }
1426}
1427
1428
1429
1430
1431
1432
1433
1434/// A concatenation of rich texts
1435#[derive(Debug, Clone, Default, Serialize, Deserialize)]
1436pub struct RichTexts {
1437  #[doc(hidden)]
1438  #[serde(rename(serialize = "@type", deserialize = "@type"))]
1439  td_name: String,
1440  #[doc(hidden)]
1441  #[serde(rename(serialize = "@extra", deserialize = "@extra"))]
1442  extra: Option<String>,
1443  /// Texts
1444  texts: Vec<RichText>,
1445  
1446}
1447
1448impl RObject for RichTexts {
1449  #[doc(hidden)] fn td_name(&self) -> &'static str { "richTexts" }
1450  #[doc(hidden)] fn extra(&self) -> Option<String> { self.extra.clone() }
1451  fn to_json(&self) -> RTDResult<String> { Ok(serde_json::to_string(self)?) }
1452}
1453
1454
1455impl TDRichText for RichTexts {}
1456
1457
1458
1459impl RichTexts {
1460  pub fn from_json<S: AsRef<str>>(json: S) -> RTDResult<Self> { Ok(serde_json::from_str(json.as_ref())?) }
1461  pub fn builder() -> RTDRichTextsBuilder {
1462    let mut inner = RichTexts::default();
1463    inner.td_name = "richTexts".to_string();
1464    inner.extra = Some(Uuid::new_v4().to_string());
1465    RTDRichTextsBuilder { inner }
1466  }
1467
1468  pub fn texts(&self) -> &Vec<RichText> { &self.texts }
1469
1470}
1471
1472#[doc(hidden)]
1473pub struct RTDRichTextsBuilder {
1474  inner: RichTexts
1475}
1476
1477impl RTDRichTextsBuilder {
1478  pub fn build(&self) -> RichTexts { self.inner.clone() }
1479
1480   
1481  pub fn texts(&mut self, texts: Vec<RichText>) -> &mut Self {
1482    self.inner.texts = texts;
1483    self
1484  }
1485
1486}
1487
1488impl AsRef<RichTexts> for RichTexts {
1489  fn as_ref(&self) -> &RichTexts { self }
1490}
1491
1492impl AsRef<RichTexts> for RTDRichTextsBuilder {
1493  fn as_ref(&self) -> &RichTexts { &self.inner }
1494}
1495
1496
1497