rtdlib/types/
email_address_authentication_code_info.rs

1
2use crate::types::*;
3use crate::errors::*;
4use uuid::Uuid;
5
6
7
8
9/// Information about the email address authentication code that was sent
10#[derive(Debug, Clone, Default, Serialize, Deserialize)]
11pub struct EmailAddressAuthenticationCodeInfo {
12  #[doc(hidden)]
13  #[serde(rename(serialize = "@type", deserialize = "@type"))]
14  td_name: String,
15  #[doc(hidden)]
16  #[serde(rename(serialize = "@extra", deserialize = "@extra"))]
17  extra: Option<String>,
18  /// Pattern of the email address to which an authentication code was sent
19  email_address_pattern: String,
20  /// Length of the code; 0 if unknown
21  length: i64,
22  
23}
24
25impl RObject for EmailAddressAuthenticationCodeInfo {
26  #[doc(hidden)] fn td_name(&self) -> &'static str { "emailAddressAuthenticationCodeInfo" }
27  #[doc(hidden)] fn extra(&self) -> Option<String> { self.extra.clone() }
28  fn to_json(&self) -> RTDResult<String> { Ok(serde_json::to_string(self)?) }
29}
30
31
32
33impl EmailAddressAuthenticationCodeInfo {
34  pub fn from_json<S: AsRef<str>>(json: S) -> RTDResult<Self> { Ok(serde_json::from_str(json.as_ref())?) }
35  pub fn builder() -> RTDEmailAddressAuthenticationCodeInfoBuilder {
36    let mut inner = EmailAddressAuthenticationCodeInfo::default();
37    inner.td_name = "emailAddressAuthenticationCodeInfo".to_string();
38    inner.extra = Some(Uuid::new_v4().to_string());
39    RTDEmailAddressAuthenticationCodeInfoBuilder { inner }
40  }
41
42  pub fn email_address_pattern(&self) -> &String { &self.email_address_pattern }
43
44  pub fn length(&self) -> i64 { self.length }
45
46}
47
48#[doc(hidden)]
49pub struct RTDEmailAddressAuthenticationCodeInfoBuilder {
50  inner: EmailAddressAuthenticationCodeInfo
51}
52
53impl RTDEmailAddressAuthenticationCodeInfoBuilder {
54  pub fn build(&self) -> EmailAddressAuthenticationCodeInfo { self.inner.clone() }
55
56   
57  pub fn email_address_pattern<T: AsRef<str>>(&mut self, email_address_pattern: T) -> &mut Self {
58    self.inner.email_address_pattern = email_address_pattern.as_ref().to_string();
59    self
60  }
61
62   
63  pub fn length(&mut self, length: i64) -> &mut Self {
64    self.inner.length = length;
65    self
66  }
67
68}
69
70impl AsRef<EmailAddressAuthenticationCodeInfo> for EmailAddressAuthenticationCodeInfo {
71  fn as_ref(&self) -> &EmailAddressAuthenticationCodeInfo { self }
72}
73
74impl AsRef<EmailAddressAuthenticationCodeInfo> for RTDEmailAddressAuthenticationCodeInfoBuilder {
75  fn as_ref(&self) -> &EmailAddressAuthenticationCodeInfo { &self.inner }
76}
77
78
79