rust_tdlib/types/
get_background_url.rs

1use crate::errors::Result;
2use crate::types::*;
3use uuid::Uuid;
4
5/// Constructs a persistent HTTP URL for a background
6#[derive(Debug, Clone, Default, Serialize, Deserialize)]
7pub struct GetBackgroundUrl {
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    /// Background name
14
15    #[serde(default)]
16    name: String,
17    /// Background type
18
19    #[serde(rename(serialize = "type", deserialize = "type"))]
20    #[serde(skip_serializing_if = "BackgroundType::_is_default")]
21    type_: BackgroundType,
22
23    #[serde(rename(serialize = "@type"))]
24    td_type: String,
25}
26
27impl RObject for GetBackgroundUrl {
28    #[doc(hidden)]
29    fn extra(&self) -> Option<&str> {
30        self.extra.as_deref()
31    }
32    #[doc(hidden)]
33    fn client_id(&self) -> Option<i32> {
34        self.client_id
35    }
36}
37
38impl RFunction for GetBackgroundUrl {}
39
40impl GetBackgroundUrl {
41    pub fn from_json<S: AsRef<str>>(json: S) -> Result<Self> {
42        Ok(serde_json::from_str(json.as_ref())?)
43    }
44    pub fn builder() -> GetBackgroundUrlBuilder {
45        let mut inner = GetBackgroundUrl::default();
46        inner.extra = Some(Uuid::new_v4().to_string());
47
48        inner.td_type = "getBackgroundUrl".to_string();
49
50        GetBackgroundUrlBuilder { inner }
51    }
52
53    pub fn name(&self) -> &String {
54        &self.name
55    }
56
57    pub fn type_(&self) -> &BackgroundType {
58        &self.type_
59    }
60}
61
62#[doc(hidden)]
63pub struct GetBackgroundUrlBuilder {
64    inner: GetBackgroundUrl,
65}
66
67#[deprecated]
68pub type RTDGetBackgroundUrlBuilder = GetBackgroundUrlBuilder;
69
70impl GetBackgroundUrlBuilder {
71    pub fn build(&self) -> GetBackgroundUrl {
72        self.inner.clone()
73    }
74
75    pub fn name<T: AsRef<str>>(&mut self, name: T) -> &mut Self {
76        self.inner.name = name.as_ref().to_string();
77        self
78    }
79
80    pub fn type_<T: AsRef<BackgroundType>>(&mut self, type_: T) -> &mut Self {
81        self.inner.type_ = type_.as_ref().clone();
82        self
83    }
84}
85
86impl AsRef<GetBackgroundUrl> for GetBackgroundUrl {
87    fn as_ref(&self) -> &GetBackgroundUrl {
88        self
89    }
90}
91
92impl AsRef<GetBackgroundUrl> for GetBackgroundUrlBuilder {
93    fn as_ref(&self) -> &GetBackgroundUrl {
94        &self.inner
95    }
96}