rust_tdlib/types/
parse_markdown.rs1use crate::errors::Result;
2use crate::types::*;
3use uuid::Uuid;
4
5#[derive(Debug, Clone, Default, Serialize, Deserialize)]
7pub struct ParseMarkdown {
8 #[doc(hidden)]
9 #[serde(rename(serialize = "@extra", deserialize = "@extra"))]
10 extra: Option<String>,
11 #[serde(rename(serialize = "@client_id", deserialize = "@client_id"))]
12 client_id: Option<i32>,
13 text: FormattedText,
15
16 #[serde(rename(serialize = "@type"))]
17 td_type: String,
18}
19
20impl RObject for ParseMarkdown {
21 #[doc(hidden)]
22 fn extra(&self) -> Option<&str> {
23 self.extra.as_deref()
24 }
25 #[doc(hidden)]
26 fn client_id(&self) -> Option<i32> {
27 self.client_id
28 }
29}
30
31impl RFunction for ParseMarkdown {}
32
33impl ParseMarkdown {
34 pub fn from_json<S: AsRef<str>>(json: S) -> Result<Self> {
35 Ok(serde_json::from_str(json.as_ref())?)
36 }
37 pub fn builder() -> ParseMarkdownBuilder {
38 let mut inner = ParseMarkdown::default();
39 inner.extra = Some(Uuid::new_v4().to_string());
40
41 inner.td_type = "parseMarkdown".to_string();
42
43 ParseMarkdownBuilder { inner }
44 }
45
46 pub fn text(&self) -> &FormattedText {
47 &self.text
48 }
49}
50
51#[doc(hidden)]
52pub struct ParseMarkdownBuilder {
53 inner: ParseMarkdown,
54}
55
56#[deprecated]
57pub type RTDParseMarkdownBuilder = ParseMarkdownBuilder;
58
59impl ParseMarkdownBuilder {
60 pub fn build(&self) -> ParseMarkdown {
61 self.inner.clone()
62 }
63
64 pub fn text<T: AsRef<FormattedText>>(&mut self, text: T) -> &mut Self {
65 self.inner.text = text.as_ref().clone();
66 self
67 }
68}
69
70impl AsRef<ParseMarkdown> for ParseMarkdown {
71 fn as_ref(&self) -> &ParseMarkdown {
72 self
73 }
74}
75
76impl AsRef<ParseMarkdown> for ParseMarkdownBuilder {
77 fn as_ref(&self) -> &ParseMarkdown {
78 &self.inner
79 }
80}