rtdlib/types/
page_block_related_article.rs1
2use crate::types::*;
3use crate::errors::*;
4use uuid::Uuid;
5
6
7
8
9#[derive(Debug, Clone, Default, Serialize, Deserialize)]
11pub struct PageBlockRelatedArticle {
12 #[doc(hidden)]
13 #[serde(rename(serialize = "@type", deserialize = "@type"))]
14 td_name: String,
15 #[doc(hidden)]
16 #[serde(rename(serialize = "@extra", deserialize = "@extra"))]
17 extra: Option<String>,
18 url: String,
20 title: String,
22 description: String,
24 photo: Option<Photo>,
26 author: String,
28 publish_date: i64,
30
31}
32
33impl RObject for PageBlockRelatedArticle {
34 #[doc(hidden)] fn td_name(&self) -> &'static str { "pageBlockRelatedArticle" }
35 #[doc(hidden)] fn extra(&self) -> Option<String> { self.extra.clone() }
36 fn to_json(&self) -> RTDResult<String> { Ok(serde_json::to_string(self)?) }
37}
38
39
40
41impl PageBlockRelatedArticle {
42 pub fn from_json<S: AsRef<str>>(json: S) -> RTDResult<Self> { Ok(serde_json::from_str(json.as_ref())?) }
43 pub fn builder() -> RTDPageBlockRelatedArticleBuilder {
44 let mut inner = PageBlockRelatedArticle::default();
45 inner.td_name = "pageBlockRelatedArticle".to_string();
46 inner.extra = Some(Uuid::new_v4().to_string());
47 RTDPageBlockRelatedArticleBuilder { inner }
48 }
49
50 pub fn url(&self) -> &String { &self.url }
51
52 pub fn title(&self) -> &String { &self.title }
53
54 pub fn description(&self) -> &String { &self.description }
55
56 pub fn photo(&self) -> &Option<Photo> { &self.photo }
57
58 pub fn author(&self) -> &String { &self.author }
59
60 pub fn publish_date(&self) -> i64 { self.publish_date }
61
62}
63
64#[doc(hidden)]
65pub struct RTDPageBlockRelatedArticleBuilder {
66 inner: PageBlockRelatedArticle
67}
68
69impl RTDPageBlockRelatedArticleBuilder {
70 pub fn build(&self) -> PageBlockRelatedArticle { self.inner.clone() }
71
72
73 pub fn url<T: AsRef<str>>(&mut self, url: T) -> &mut Self {
74 self.inner.url = url.as_ref().to_string();
75 self
76 }
77
78
79 pub fn title<T: AsRef<str>>(&mut self, title: T) -> &mut Self {
80 self.inner.title = title.as_ref().to_string();
81 self
82 }
83
84
85 pub fn description<T: AsRef<str>>(&mut self, description: T) -> &mut Self {
86 self.inner.description = description.as_ref().to_string();
87 self
88 }
89
90
91 pub fn photo<T: AsRef<Photo>>(&mut self, photo: T) -> &mut Self {
92 self.inner.photo = Some(photo.as_ref().clone());
93 self
94 }
95
96
97 pub fn author<T: AsRef<str>>(&mut self, author: T) -> &mut Self {
98 self.inner.author = author.as_ref().to_string();
99 self
100 }
101
102
103 pub fn publish_date(&mut self, publish_date: i64) -> &mut Self {
104 self.inner.publish_date = publish_date;
105 self
106 }
107
108}
109
110impl AsRef<PageBlockRelatedArticle> for PageBlockRelatedArticle {
111 fn as_ref(&self) -> &PageBlockRelatedArticle { self }
112}
113
114impl AsRef<PageBlockRelatedArticle> for RTDPageBlockRelatedArticleBuilder {
115 fn as_ref(&self) -> &PageBlockRelatedArticle { &self.inner }
116}
117
118
119