rust_tdlib/types/
check_chat_invite_link.rs

1use crate::errors::Result;
2use crate::types::*;
3use uuid::Uuid;
4
5/// Checks the validity of an invite link for a chat and returns information about the corresponding chat
6#[derive(Debug, Clone, Default, Serialize, Deserialize)]
7pub struct CheckChatInviteLink {
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    /// Invite link to be checked
14
15    #[serde(default)]
16    invite_link: String,
17
18    #[serde(rename(serialize = "@type"))]
19    td_type: String,
20}
21
22impl RObject for CheckChatInviteLink {
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 RFunction for CheckChatInviteLink {}
34
35impl CheckChatInviteLink {
36    pub fn from_json<S: AsRef<str>>(json: S) -> Result<Self> {
37        Ok(serde_json::from_str(json.as_ref())?)
38    }
39    pub fn builder() -> CheckChatInviteLinkBuilder {
40        let mut inner = CheckChatInviteLink::default();
41        inner.extra = Some(Uuid::new_v4().to_string());
42
43        inner.td_type = "checkChatInviteLink".to_string();
44
45        CheckChatInviteLinkBuilder { inner }
46    }
47
48    pub fn invite_link(&self) -> &String {
49        &self.invite_link
50    }
51}
52
53#[doc(hidden)]
54pub struct CheckChatInviteLinkBuilder {
55    inner: CheckChatInviteLink,
56}
57
58#[deprecated]
59pub type RTDCheckChatInviteLinkBuilder = CheckChatInviteLinkBuilder;
60
61impl CheckChatInviteLinkBuilder {
62    pub fn build(&self) -> CheckChatInviteLink {
63        self.inner.clone()
64    }
65
66    pub fn invite_link<T: AsRef<str>>(&mut self, invite_link: T) -> &mut Self {
67        self.inner.invite_link = invite_link.as_ref().to_string();
68        self
69    }
70}
71
72impl AsRef<CheckChatInviteLink> for CheckChatInviteLink {
73    fn as_ref(&self) -> &CheckChatInviteLink {
74        self
75    }
76}
77
78impl AsRef<CheckChatInviteLink> for CheckChatInviteLinkBuilder {
79    fn as_ref(&self) -> &CheckChatInviteLink {
80        &self.inner
81    }
82}