rust_tdlib/types/
get_internal_link_type.rs

1use crate::errors::Result;
2use crate::types::*;
3use uuid::Uuid;
4
5/// Returns information about the type of an internal link. Returns a 404 error if the link is not internal. Can be called before authorization
6#[derive(Debug, Clone, Default, Serialize, Deserialize)]
7pub struct GetInternalLinkType {
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    /// The link
14
15    #[serde(default)]
16    link: String,
17
18    #[serde(rename(serialize = "@type"))]
19    td_type: String,
20}
21
22impl RObject for GetInternalLinkType {
23    #[doc(hidden)]
24    fn extra(&self) -> Option<&str> {
25        self.extra.as_deref()
26    }
27    #[doc(hidden)]
28    fn client_id(&self) -> Option<i32> {
29        self.client_id
30    }
31}
32
33impl TDInternalLinkType for GetInternalLinkType {}
34
35impl RFunction for GetInternalLinkType {}
36
37impl GetInternalLinkType {
38    pub fn from_json<S: AsRef<str>>(json: S) -> Result<Self> {
39        Ok(serde_json::from_str(json.as_ref())?)
40    }
41    pub fn builder() -> GetInternalLinkTypeBuilder {
42        let mut inner = GetInternalLinkType::default();
43        inner.extra = Some(Uuid::new_v4().to_string());
44
45        inner.td_type = "getInternalLinkType".to_string();
46
47        GetInternalLinkTypeBuilder { inner }
48    }
49
50    pub fn link(&self) -> &String {
51        &self.link
52    }
53}
54
55#[doc(hidden)]
56pub struct GetInternalLinkTypeBuilder {
57    inner: GetInternalLinkType,
58}
59
60#[deprecated]
61pub type RTDGetInternalLinkTypeBuilder = GetInternalLinkTypeBuilder;
62
63impl GetInternalLinkTypeBuilder {
64    pub fn build(&self) -> GetInternalLinkType {
65        self.inner.clone()
66    }
67
68    pub fn link<T: AsRef<str>>(&mut self, link: T) -> &mut Self {
69        self.inner.link = link.as_ref().to_string();
70        self
71    }
72}
73
74impl AsRef<GetInternalLinkType> for GetInternalLinkType {
75    fn as_ref(&self) -> &GetInternalLinkType {
76        self
77    }
78}
79
80impl AsRef<GetInternalLinkType> for GetInternalLinkTypeBuilder {
81    fn as_ref(&self) -> &GetInternalLinkType {
82        &self.inner
83    }
84}