rust_tdlib/types/
resend_authentication_code.rs

1use crate::errors::Result;
2use crate::types::*;
3use uuid::Uuid;
4
5/// Re-sends an authentication code to the user. Works only when the current authorization state is authorizationStateWaitCode, the next_code_type of the result is not null and the server-specified timeout has passed
6#[derive(Debug, Clone, Default, Serialize, Deserialize)]
7pub struct ResendAuthenticationCode {
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
14    #[serde(rename(serialize = "@type"))]
15    td_type: String,
16}
17
18impl RObject for ResendAuthenticationCode {
19    #[doc(hidden)]
20    fn extra(&self) -> Option<&str> {
21        self.extra.as_deref()
22    }
23    #[doc(hidden)]
24    fn client_id(&self) -> Option<i32> {
25        self.client_id
26    }
27}
28
29impl RFunction for ResendAuthenticationCode {}
30
31impl ResendAuthenticationCode {
32    pub fn from_json<S: AsRef<str>>(json: S) -> Result<Self> {
33        Ok(serde_json::from_str(json.as_ref())?)
34    }
35    pub fn builder() -> ResendAuthenticationCodeBuilder {
36        let mut inner = ResendAuthenticationCode::default();
37        inner.extra = Some(Uuid::new_v4().to_string());
38
39        inner.td_type = "resendAuthenticationCode".to_string();
40
41        ResendAuthenticationCodeBuilder { inner }
42    }
43}
44
45#[doc(hidden)]
46pub struct ResendAuthenticationCodeBuilder {
47    inner: ResendAuthenticationCode,
48}
49
50#[deprecated]
51pub type RTDResendAuthenticationCodeBuilder = ResendAuthenticationCodeBuilder;
52
53impl ResendAuthenticationCodeBuilder {
54    pub fn build(&self) -> ResendAuthenticationCode {
55        self.inner.clone()
56    }
57}
58
59impl AsRef<ResendAuthenticationCode> for ResendAuthenticationCode {
60    fn as_ref(&self) -> &ResendAuthenticationCode {
61        self
62    }
63}
64
65impl AsRef<ResendAuthenticationCode> for ResendAuthenticationCodeBuilder {
66    fn as_ref(&self) -> &ResendAuthenticationCode {
67        &self.inner
68    }
69}