rust_tdlib/types/
authorization_state.rs

1use crate::errors::Result;
2use crate::types::*;
3use uuid::Uuid;
4
5use std::fmt::Debug;
6
7/// Represents the current authorization state of the TDLib client
8pub trait TDAuthorizationState: Debug + RObject {}
9
10/// Represents the current authorization state of the TDLib client
11#[derive(Debug, Clone, Deserialize, Serialize, Default)]
12#[serde(tag = "@type")]
13pub enum AuthorizationState {
14    #[doc(hidden)]
15    #[default]
16    _Default,
17    /// TDLib client is in its final state. All databases are closed and all resources are released. No other updates will be received after this. All queries will be responded to with error code 500. To continue working, one must create a new instance of the TDLib client
18    #[serde(rename = "authorizationStateClosed")]
19    Closed(AuthorizationStateClosed),
20    /// TDLib is closing, all subsequent queries will be answered with the error 500. Note that closing TDLib can take a while. All resources will be freed only after authorizationStateClosed has been received
21    #[serde(rename = "authorizationStateClosing")]
22    Closing(AuthorizationStateClosing),
23    /// The user is currently logging out
24    #[serde(rename = "authorizationStateLoggingOut")]
25    LoggingOut(AuthorizationStateLoggingOut),
26    /// The user has been successfully authorized. TDLib is now ready to answer queries
27    #[serde(rename = "authorizationStateReady")]
28    Ready(AuthorizationStateReady),
29    /// TDLib needs the user's authentication code to authorize
30    #[serde(rename = "authorizationStateWaitCode")]
31    WaitCode(AuthorizationStateWaitCode),
32    /// TDLib needs an encryption key to decrypt the local database
33    #[serde(rename = "authorizationStateWaitEncryptionKey")]
34    WaitEncryptionKey(AuthorizationStateWaitEncryptionKey),
35    /// The user needs to confirm authorization on another logged in device by scanning a QR code with the provided link
36    #[serde(rename = "authorizationStateWaitOtherDeviceConfirmation")]
37    WaitOtherDeviceConfirmation(AuthorizationStateWaitOtherDeviceConfirmation),
38    /// The user has been authorized, but needs to enter a password to start using the application
39    #[serde(rename = "authorizationStateWaitPassword")]
40    WaitPassword(AuthorizationStateWaitPassword),
41    /// TDLib needs the user's phone number to authorize. Call `setAuthenticationPhoneNumber` to provide the phone number, or use `requestQrCodeAuthentication`, or `checkAuthenticationBotToken` for other authentication options
42    #[serde(rename = "authorizationStateWaitPhoneNumber")]
43    WaitPhoneNumber(AuthorizationStateWaitPhoneNumber),
44    /// The user is unregistered and need to accept terms of service and enter their first name and last name to finish registration
45    #[serde(rename = "authorizationStateWaitRegistration")]
46    WaitRegistration(AuthorizationStateWaitRegistration),
47    /// TDLib needs TdlibParameters for initialization
48    #[serde(rename = "authorizationStateWaitTdlibParameters")]
49    WaitTdlibParameters(AuthorizationStateWaitTdlibParameters),
50    /// Returns the current authorization state; this is an offline request. For informational purposes only. Use updateAuthorizationState instead to maintain the current authorization state. Can be called before initialization
51    #[serde(rename = "getAuthorizationState")]
52    GetAuthorizationState(GetAuthorizationState),
53}
54
55impl RObject for AuthorizationState {
56    #[doc(hidden)]
57    fn extra(&self) -> Option<&str> {
58        match self {
59            AuthorizationState::Closed(t) => t.extra(),
60            AuthorizationState::Closing(t) => t.extra(),
61            AuthorizationState::LoggingOut(t) => t.extra(),
62            AuthorizationState::Ready(t) => t.extra(),
63            AuthorizationState::WaitCode(t) => t.extra(),
64            AuthorizationState::WaitEncryptionKey(t) => t.extra(),
65            AuthorizationState::WaitOtherDeviceConfirmation(t) => t.extra(),
66            AuthorizationState::WaitPassword(t) => t.extra(),
67            AuthorizationState::WaitPhoneNumber(t) => t.extra(),
68            AuthorizationState::WaitRegistration(t) => t.extra(),
69            AuthorizationState::WaitTdlibParameters(t) => t.extra(),
70            AuthorizationState::GetAuthorizationState(t) => t.extra(),
71
72            _ => None,
73        }
74    }
75    #[doc(hidden)]
76    fn client_id(&self) -> Option<i32> {
77        match self {
78            AuthorizationState::Closed(t) => t.client_id(),
79            AuthorizationState::Closing(t) => t.client_id(),
80            AuthorizationState::LoggingOut(t) => t.client_id(),
81            AuthorizationState::Ready(t) => t.client_id(),
82            AuthorizationState::WaitCode(t) => t.client_id(),
83            AuthorizationState::WaitEncryptionKey(t) => t.client_id(),
84            AuthorizationState::WaitOtherDeviceConfirmation(t) => t.client_id(),
85            AuthorizationState::WaitPassword(t) => t.client_id(),
86            AuthorizationState::WaitPhoneNumber(t) => t.client_id(),
87            AuthorizationState::WaitRegistration(t) => t.client_id(),
88            AuthorizationState::WaitTdlibParameters(t) => t.client_id(),
89            AuthorizationState::GetAuthorizationState(t) => t.client_id(),
90
91            _ => None,
92        }
93    }
94}
95
96impl AuthorizationState {
97    pub fn from_json<S: AsRef<str>>(json: S) -> Result<Self> {
98        Ok(serde_json::from_str(json.as_ref())?)
99    }
100    #[doc(hidden)]
101    pub fn _is_default(&self) -> bool {
102        matches!(self, AuthorizationState::_Default)
103    }
104}
105
106impl AsRef<AuthorizationState> for AuthorizationState {
107    fn as_ref(&self) -> &AuthorizationState {
108        self
109    }
110}
111
112/// TDLib client is in its final state. All databases are closed and all resources are released. No other updates will be received after this. All queries will be responded to with error code 500. To continue working, one must create a new instance of the TDLib client
113#[derive(Debug, Clone, Default, Serialize, Deserialize)]
114pub struct AuthorizationStateClosed {
115    #[doc(hidden)]
116    #[serde(rename(serialize = "@extra", deserialize = "@extra"))]
117    extra: Option<String>,
118    #[serde(rename(serialize = "@client_id", deserialize = "@client_id"))]
119    client_id: Option<i32>,
120}
121
122impl RObject for AuthorizationStateClosed {
123    #[doc(hidden)]
124    fn extra(&self) -> Option<&str> {
125        self.extra.as_deref()
126    }
127    #[doc(hidden)]
128    fn client_id(&self) -> Option<i32> {
129        self.client_id
130    }
131}
132
133impl TDAuthorizationState for AuthorizationStateClosed {}
134
135impl AuthorizationStateClosed {
136    pub fn from_json<S: AsRef<str>>(json: S) -> Result<Self> {
137        Ok(serde_json::from_str(json.as_ref())?)
138    }
139    pub fn builder() -> AuthorizationStateClosedBuilder {
140        let mut inner = AuthorizationStateClosed::default();
141        inner.extra = Some(Uuid::new_v4().to_string());
142
143        AuthorizationStateClosedBuilder { inner }
144    }
145}
146
147#[doc(hidden)]
148pub struct AuthorizationStateClosedBuilder {
149    inner: AuthorizationStateClosed,
150}
151
152#[deprecated]
153pub type RTDAuthorizationStateClosedBuilder = AuthorizationStateClosedBuilder;
154
155impl AuthorizationStateClosedBuilder {
156    pub fn build(&self) -> AuthorizationStateClosed {
157        self.inner.clone()
158    }
159}
160
161impl AsRef<AuthorizationStateClosed> for AuthorizationStateClosed {
162    fn as_ref(&self) -> &AuthorizationStateClosed {
163        self
164    }
165}
166
167impl AsRef<AuthorizationStateClosed> for AuthorizationStateClosedBuilder {
168    fn as_ref(&self) -> &AuthorizationStateClosed {
169        &self.inner
170    }
171}
172
173/// TDLib is closing, all subsequent queries will be answered with the error 500. Note that closing TDLib can take a while. All resources will be freed only after authorizationStateClosed has been received
174#[derive(Debug, Clone, Default, Serialize, Deserialize)]
175pub struct AuthorizationStateClosing {
176    #[doc(hidden)]
177    #[serde(rename(serialize = "@extra", deserialize = "@extra"))]
178    extra: Option<String>,
179    #[serde(rename(serialize = "@client_id", deserialize = "@client_id"))]
180    client_id: Option<i32>,
181}
182
183impl RObject for AuthorizationStateClosing {
184    #[doc(hidden)]
185    fn extra(&self) -> Option<&str> {
186        self.extra.as_deref()
187    }
188    #[doc(hidden)]
189    fn client_id(&self) -> Option<i32> {
190        self.client_id
191    }
192}
193
194impl TDAuthorizationState for AuthorizationStateClosing {}
195
196impl AuthorizationStateClosing {
197    pub fn from_json<S: AsRef<str>>(json: S) -> Result<Self> {
198        Ok(serde_json::from_str(json.as_ref())?)
199    }
200    pub fn builder() -> AuthorizationStateClosingBuilder {
201        let mut inner = AuthorizationStateClosing::default();
202        inner.extra = Some(Uuid::new_v4().to_string());
203
204        AuthorizationStateClosingBuilder { inner }
205    }
206}
207
208#[doc(hidden)]
209pub struct AuthorizationStateClosingBuilder {
210    inner: AuthorizationStateClosing,
211}
212
213#[deprecated]
214pub type RTDAuthorizationStateClosingBuilder = AuthorizationStateClosingBuilder;
215
216impl AuthorizationStateClosingBuilder {
217    pub fn build(&self) -> AuthorizationStateClosing {
218        self.inner.clone()
219    }
220}
221
222impl AsRef<AuthorizationStateClosing> for AuthorizationStateClosing {
223    fn as_ref(&self) -> &AuthorizationStateClosing {
224        self
225    }
226}
227
228impl AsRef<AuthorizationStateClosing> for AuthorizationStateClosingBuilder {
229    fn as_ref(&self) -> &AuthorizationStateClosing {
230        &self.inner
231    }
232}
233
234/// The user is currently logging out
235#[derive(Debug, Clone, Default, Serialize, Deserialize)]
236pub struct AuthorizationStateLoggingOut {
237    #[doc(hidden)]
238    #[serde(rename(serialize = "@extra", deserialize = "@extra"))]
239    extra: Option<String>,
240    #[serde(rename(serialize = "@client_id", deserialize = "@client_id"))]
241    client_id: Option<i32>,
242}
243
244impl RObject for AuthorizationStateLoggingOut {
245    #[doc(hidden)]
246    fn extra(&self) -> Option<&str> {
247        self.extra.as_deref()
248    }
249    #[doc(hidden)]
250    fn client_id(&self) -> Option<i32> {
251        self.client_id
252    }
253}
254
255impl TDAuthorizationState for AuthorizationStateLoggingOut {}
256
257impl AuthorizationStateLoggingOut {
258    pub fn from_json<S: AsRef<str>>(json: S) -> Result<Self> {
259        Ok(serde_json::from_str(json.as_ref())?)
260    }
261    pub fn builder() -> AuthorizationStateLoggingOutBuilder {
262        let mut inner = AuthorizationStateLoggingOut::default();
263        inner.extra = Some(Uuid::new_v4().to_string());
264
265        AuthorizationStateLoggingOutBuilder { inner }
266    }
267}
268
269#[doc(hidden)]
270pub struct AuthorizationStateLoggingOutBuilder {
271    inner: AuthorizationStateLoggingOut,
272}
273
274#[deprecated]
275pub type RTDAuthorizationStateLoggingOutBuilder = AuthorizationStateLoggingOutBuilder;
276
277impl AuthorizationStateLoggingOutBuilder {
278    pub fn build(&self) -> AuthorizationStateLoggingOut {
279        self.inner.clone()
280    }
281}
282
283impl AsRef<AuthorizationStateLoggingOut> for AuthorizationStateLoggingOut {
284    fn as_ref(&self) -> &AuthorizationStateLoggingOut {
285        self
286    }
287}
288
289impl AsRef<AuthorizationStateLoggingOut> for AuthorizationStateLoggingOutBuilder {
290    fn as_ref(&self) -> &AuthorizationStateLoggingOut {
291        &self.inner
292    }
293}
294
295/// The user has been successfully authorized. TDLib is now ready to answer queries
296#[derive(Debug, Clone, Default, Serialize, Deserialize)]
297pub struct AuthorizationStateReady {
298    #[doc(hidden)]
299    #[serde(rename(serialize = "@extra", deserialize = "@extra"))]
300    extra: Option<String>,
301    #[serde(rename(serialize = "@client_id", deserialize = "@client_id"))]
302    client_id: Option<i32>,
303}
304
305impl RObject for AuthorizationStateReady {
306    #[doc(hidden)]
307    fn extra(&self) -> Option<&str> {
308        self.extra.as_deref()
309    }
310    #[doc(hidden)]
311    fn client_id(&self) -> Option<i32> {
312        self.client_id
313    }
314}
315
316impl TDAuthorizationState for AuthorizationStateReady {}
317
318impl AuthorizationStateReady {
319    pub fn from_json<S: AsRef<str>>(json: S) -> Result<Self> {
320        Ok(serde_json::from_str(json.as_ref())?)
321    }
322    pub fn builder() -> AuthorizationStateReadyBuilder {
323        let mut inner = AuthorizationStateReady::default();
324        inner.extra = Some(Uuid::new_v4().to_string());
325
326        AuthorizationStateReadyBuilder { inner }
327    }
328}
329
330#[doc(hidden)]
331pub struct AuthorizationStateReadyBuilder {
332    inner: AuthorizationStateReady,
333}
334
335#[deprecated]
336pub type RTDAuthorizationStateReadyBuilder = AuthorizationStateReadyBuilder;
337
338impl AuthorizationStateReadyBuilder {
339    pub fn build(&self) -> AuthorizationStateReady {
340        self.inner.clone()
341    }
342}
343
344impl AsRef<AuthorizationStateReady> for AuthorizationStateReady {
345    fn as_ref(&self) -> &AuthorizationStateReady {
346        self
347    }
348}
349
350impl AsRef<AuthorizationStateReady> for AuthorizationStateReadyBuilder {
351    fn as_ref(&self) -> &AuthorizationStateReady {
352        &self.inner
353    }
354}
355
356/// TDLib needs the user's authentication code to authorize
357#[derive(Debug, Clone, Default, Serialize, Deserialize)]
358pub struct AuthorizationStateWaitCode {
359    #[doc(hidden)]
360    #[serde(rename(serialize = "@extra", deserialize = "@extra"))]
361    extra: Option<String>,
362    #[serde(rename(serialize = "@client_id", deserialize = "@client_id"))]
363    client_id: Option<i32>,
364    /// Information about the authorization code that was sent
365    code_info: AuthenticationCodeInfo,
366}
367
368impl RObject for AuthorizationStateWaitCode {
369    #[doc(hidden)]
370    fn extra(&self) -> Option<&str> {
371        self.extra.as_deref()
372    }
373    #[doc(hidden)]
374    fn client_id(&self) -> Option<i32> {
375        self.client_id
376    }
377}
378
379impl TDAuthorizationState for AuthorizationStateWaitCode {}
380
381impl AuthorizationStateWaitCode {
382    pub fn from_json<S: AsRef<str>>(json: S) -> Result<Self> {
383        Ok(serde_json::from_str(json.as_ref())?)
384    }
385    pub fn builder() -> AuthorizationStateWaitCodeBuilder {
386        let mut inner = AuthorizationStateWaitCode::default();
387        inner.extra = Some(Uuid::new_v4().to_string());
388
389        AuthorizationStateWaitCodeBuilder { inner }
390    }
391
392    pub fn code_info(&self) -> &AuthenticationCodeInfo {
393        &self.code_info
394    }
395}
396
397#[doc(hidden)]
398pub struct AuthorizationStateWaitCodeBuilder {
399    inner: AuthorizationStateWaitCode,
400}
401
402#[deprecated]
403pub type RTDAuthorizationStateWaitCodeBuilder = AuthorizationStateWaitCodeBuilder;
404
405impl AuthorizationStateWaitCodeBuilder {
406    pub fn build(&self) -> AuthorizationStateWaitCode {
407        self.inner.clone()
408    }
409
410    pub fn code_info<T: AsRef<AuthenticationCodeInfo>>(&mut self, code_info: T) -> &mut Self {
411        self.inner.code_info = code_info.as_ref().clone();
412        self
413    }
414}
415
416impl AsRef<AuthorizationStateWaitCode> for AuthorizationStateWaitCode {
417    fn as_ref(&self) -> &AuthorizationStateWaitCode {
418        self
419    }
420}
421
422impl AsRef<AuthorizationStateWaitCode> for AuthorizationStateWaitCodeBuilder {
423    fn as_ref(&self) -> &AuthorizationStateWaitCode {
424        &self.inner
425    }
426}
427
428/// TDLib needs an encryption key to decrypt the local database
429#[derive(Debug, Clone, Default, Serialize, Deserialize)]
430pub struct AuthorizationStateWaitEncryptionKey {
431    #[doc(hidden)]
432    #[serde(rename(serialize = "@extra", deserialize = "@extra"))]
433    extra: Option<String>,
434    #[serde(rename(serialize = "@client_id", deserialize = "@client_id"))]
435    client_id: Option<i32>,
436    /// True, if the database is currently encrypted
437
438    #[serde(default)]
439    is_encrypted: bool,
440}
441
442impl RObject for AuthorizationStateWaitEncryptionKey {
443    #[doc(hidden)]
444    fn extra(&self) -> Option<&str> {
445        self.extra.as_deref()
446    }
447    #[doc(hidden)]
448    fn client_id(&self) -> Option<i32> {
449        self.client_id
450    }
451}
452
453impl TDAuthorizationState for AuthorizationStateWaitEncryptionKey {}
454
455impl AuthorizationStateWaitEncryptionKey {
456    pub fn from_json<S: AsRef<str>>(json: S) -> Result<Self> {
457        Ok(serde_json::from_str(json.as_ref())?)
458    }
459    pub fn builder() -> AuthorizationStateWaitEncryptionKeyBuilder {
460        let mut inner = AuthorizationStateWaitEncryptionKey::default();
461        inner.extra = Some(Uuid::new_v4().to_string());
462
463        AuthorizationStateWaitEncryptionKeyBuilder { inner }
464    }
465
466    pub fn is_encrypted(&self) -> bool {
467        self.is_encrypted
468    }
469}
470
471#[doc(hidden)]
472pub struct AuthorizationStateWaitEncryptionKeyBuilder {
473    inner: AuthorizationStateWaitEncryptionKey,
474}
475
476#[deprecated]
477pub type RTDAuthorizationStateWaitEncryptionKeyBuilder = AuthorizationStateWaitEncryptionKeyBuilder;
478
479impl AuthorizationStateWaitEncryptionKeyBuilder {
480    pub fn build(&self) -> AuthorizationStateWaitEncryptionKey {
481        self.inner.clone()
482    }
483
484    pub fn is_encrypted(&mut self, is_encrypted: bool) -> &mut Self {
485        self.inner.is_encrypted = is_encrypted;
486        self
487    }
488}
489
490impl AsRef<AuthorizationStateWaitEncryptionKey> for AuthorizationStateWaitEncryptionKey {
491    fn as_ref(&self) -> &AuthorizationStateWaitEncryptionKey {
492        self
493    }
494}
495
496impl AsRef<AuthorizationStateWaitEncryptionKey> for AuthorizationStateWaitEncryptionKeyBuilder {
497    fn as_ref(&self) -> &AuthorizationStateWaitEncryptionKey {
498        &self.inner
499    }
500}
501
502/// The user needs to confirm authorization on another logged in device by scanning a QR code with the provided link
503#[derive(Debug, Clone, Default, Serialize, Deserialize)]
504pub struct AuthorizationStateWaitOtherDeviceConfirmation {
505    #[doc(hidden)]
506    #[serde(rename(serialize = "@extra", deserialize = "@extra"))]
507    extra: Option<String>,
508    #[serde(rename(serialize = "@client_id", deserialize = "@client_id"))]
509    client_id: Option<i32>,
510    /// A tg:// URL for the QR code. The link will be updated frequently
511
512    #[serde(default)]
513    link: String,
514}
515
516impl RObject for AuthorizationStateWaitOtherDeviceConfirmation {
517    #[doc(hidden)]
518    fn extra(&self) -> Option<&str> {
519        self.extra.as_deref()
520    }
521    #[doc(hidden)]
522    fn client_id(&self) -> Option<i32> {
523        self.client_id
524    }
525}
526
527impl TDAuthorizationState for AuthorizationStateWaitOtherDeviceConfirmation {}
528
529impl AuthorizationStateWaitOtherDeviceConfirmation {
530    pub fn from_json<S: AsRef<str>>(json: S) -> Result<Self> {
531        Ok(serde_json::from_str(json.as_ref())?)
532    }
533    pub fn builder() -> AuthorizationStateWaitOtherDeviceConfirmationBuilder {
534        let mut inner = AuthorizationStateWaitOtherDeviceConfirmation::default();
535        inner.extra = Some(Uuid::new_v4().to_string());
536
537        AuthorizationStateWaitOtherDeviceConfirmationBuilder { inner }
538    }
539
540    pub fn link(&self) -> &String {
541        &self.link
542    }
543}
544
545#[doc(hidden)]
546pub struct AuthorizationStateWaitOtherDeviceConfirmationBuilder {
547    inner: AuthorizationStateWaitOtherDeviceConfirmation,
548}
549
550#[deprecated]
551pub type RTDAuthorizationStateWaitOtherDeviceConfirmationBuilder =
552    AuthorizationStateWaitOtherDeviceConfirmationBuilder;
553
554impl AuthorizationStateWaitOtherDeviceConfirmationBuilder {
555    pub fn build(&self) -> AuthorizationStateWaitOtherDeviceConfirmation {
556        self.inner.clone()
557    }
558
559    pub fn link<T: AsRef<str>>(&mut self, link: T) -> &mut Self {
560        self.inner.link = link.as_ref().to_string();
561        self
562    }
563}
564
565impl AsRef<AuthorizationStateWaitOtherDeviceConfirmation>
566    for AuthorizationStateWaitOtherDeviceConfirmation
567{
568    fn as_ref(&self) -> &AuthorizationStateWaitOtherDeviceConfirmation {
569        self
570    }
571}
572
573impl AsRef<AuthorizationStateWaitOtherDeviceConfirmation>
574    for AuthorizationStateWaitOtherDeviceConfirmationBuilder
575{
576    fn as_ref(&self) -> &AuthorizationStateWaitOtherDeviceConfirmation {
577        &self.inner
578    }
579}
580
581/// The user has been authorized, but needs to enter a password to start using the application
582#[derive(Debug, Clone, Default, Serialize, Deserialize)]
583pub struct AuthorizationStateWaitPassword {
584    #[doc(hidden)]
585    #[serde(rename(serialize = "@extra", deserialize = "@extra"))]
586    extra: Option<String>,
587    #[serde(rename(serialize = "@client_id", deserialize = "@client_id"))]
588    client_id: Option<i32>,
589    /// Hint for the password; may be empty
590
591    #[serde(default)]
592    password_hint: String,
593    /// True, if a recovery email address has been set up
594
595    #[serde(default)]
596    has_recovery_email_address: bool,
597    /// Pattern of the email address to which the recovery email was sent; empty until a recovery email has been sent
598
599    #[serde(default)]
600    recovery_email_address_pattern: String,
601}
602
603impl RObject for AuthorizationStateWaitPassword {
604    #[doc(hidden)]
605    fn extra(&self) -> Option<&str> {
606        self.extra.as_deref()
607    }
608    #[doc(hidden)]
609    fn client_id(&self) -> Option<i32> {
610        self.client_id
611    }
612}
613
614impl TDAuthorizationState for AuthorizationStateWaitPassword {}
615
616impl AuthorizationStateWaitPassword {
617    pub fn from_json<S: AsRef<str>>(json: S) -> Result<Self> {
618        Ok(serde_json::from_str(json.as_ref())?)
619    }
620    pub fn builder() -> AuthorizationStateWaitPasswordBuilder {
621        let mut inner = AuthorizationStateWaitPassword::default();
622        inner.extra = Some(Uuid::new_v4().to_string());
623
624        AuthorizationStateWaitPasswordBuilder { inner }
625    }
626
627    pub fn password_hint(&self) -> &String {
628        &self.password_hint
629    }
630
631    pub fn has_recovery_email_address(&self) -> bool {
632        self.has_recovery_email_address
633    }
634
635    pub fn recovery_email_address_pattern(&self) -> &String {
636        &self.recovery_email_address_pattern
637    }
638}
639
640#[doc(hidden)]
641pub struct AuthorizationStateWaitPasswordBuilder {
642    inner: AuthorizationStateWaitPassword,
643}
644
645#[deprecated]
646pub type RTDAuthorizationStateWaitPasswordBuilder = AuthorizationStateWaitPasswordBuilder;
647
648impl AuthorizationStateWaitPasswordBuilder {
649    pub fn build(&self) -> AuthorizationStateWaitPassword {
650        self.inner.clone()
651    }
652
653    pub fn password_hint<T: AsRef<str>>(&mut self, password_hint: T) -> &mut Self {
654        self.inner.password_hint = password_hint.as_ref().to_string();
655        self
656    }
657
658    pub fn has_recovery_email_address(&mut self, has_recovery_email_address: bool) -> &mut Self {
659        self.inner.has_recovery_email_address = has_recovery_email_address;
660        self
661    }
662
663    pub fn recovery_email_address_pattern<T: AsRef<str>>(
664        &mut self,
665        recovery_email_address_pattern: T,
666    ) -> &mut Self {
667        self.inner.recovery_email_address_pattern =
668            recovery_email_address_pattern.as_ref().to_string();
669        self
670    }
671}
672
673impl AsRef<AuthorizationStateWaitPassword> for AuthorizationStateWaitPassword {
674    fn as_ref(&self) -> &AuthorizationStateWaitPassword {
675        self
676    }
677}
678
679impl AsRef<AuthorizationStateWaitPassword> for AuthorizationStateWaitPasswordBuilder {
680    fn as_ref(&self) -> &AuthorizationStateWaitPassword {
681        &self.inner
682    }
683}
684
685/// TDLib needs the user's phone number to authorize. Call `setAuthenticationPhoneNumber` to provide the phone number, or use `requestQrCodeAuthentication`, or `checkAuthenticationBotToken` for other authentication options
686#[derive(Debug, Clone, Default, Serialize, Deserialize)]
687pub struct AuthorizationStateWaitPhoneNumber {
688    #[doc(hidden)]
689    #[serde(rename(serialize = "@extra", deserialize = "@extra"))]
690    extra: Option<String>,
691    #[serde(rename(serialize = "@client_id", deserialize = "@client_id"))]
692    client_id: Option<i32>,
693}
694
695impl RObject for AuthorizationStateWaitPhoneNumber {
696    #[doc(hidden)]
697    fn extra(&self) -> Option<&str> {
698        self.extra.as_deref()
699    }
700    #[doc(hidden)]
701    fn client_id(&self) -> Option<i32> {
702        self.client_id
703    }
704}
705
706impl TDAuthorizationState for AuthorizationStateWaitPhoneNumber {}
707
708impl AuthorizationStateWaitPhoneNumber {
709    pub fn from_json<S: AsRef<str>>(json: S) -> Result<Self> {
710        Ok(serde_json::from_str(json.as_ref())?)
711    }
712    pub fn builder() -> AuthorizationStateWaitPhoneNumberBuilder {
713        let mut inner = AuthorizationStateWaitPhoneNumber::default();
714        inner.extra = Some(Uuid::new_v4().to_string());
715
716        AuthorizationStateWaitPhoneNumberBuilder { inner }
717    }
718}
719
720#[doc(hidden)]
721pub struct AuthorizationStateWaitPhoneNumberBuilder {
722    inner: AuthorizationStateWaitPhoneNumber,
723}
724
725#[deprecated]
726pub type RTDAuthorizationStateWaitPhoneNumberBuilder = AuthorizationStateWaitPhoneNumberBuilder;
727
728impl AuthorizationStateWaitPhoneNumberBuilder {
729    pub fn build(&self) -> AuthorizationStateWaitPhoneNumber {
730        self.inner.clone()
731    }
732}
733
734impl AsRef<AuthorizationStateWaitPhoneNumber> for AuthorizationStateWaitPhoneNumber {
735    fn as_ref(&self) -> &AuthorizationStateWaitPhoneNumber {
736        self
737    }
738}
739
740impl AsRef<AuthorizationStateWaitPhoneNumber> for AuthorizationStateWaitPhoneNumberBuilder {
741    fn as_ref(&self) -> &AuthorizationStateWaitPhoneNumber {
742        &self.inner
743    }
744}
745
746/// The user is unregistered and need to accept terms of service and enter their first name and last name to finish registration
747#[derive(Debug, Clone, Default, Serialize, Deserialize)]
748pub struct AuthorizationStateWaitRegistration {
749    #[doc(hidden)]
750    #[serde(rename(serialize = "@extra", deserialize = "@extra"))]
751    extra: Option<String>,
752    #[serde(rename(serialize = "@client_id", deserialize = "@client_id"))]
753    client_id: Option<i32>,
754    /// Telegram terms of service
755    terms_of_service: TermsOfService,
756}
757
758impl RObject for AuthorizationStateWaitRegistration {
759    #[doc(hidden)]
760    fn extra(&self) -> Option<&str> {
761        self.extra.as_deref()
762    }
763    #[doc(hidden)]
764    fn client_id(&self) -> Option<i32> {
765        self.client_id
766    }
767}
768
769impl TDAuthorizationState for AuthorizationStateWaitRegistration {}
770
771impl AuthorizationStateWaitRegistration {
772    pub fn from_json<S: AsRef<str>>(json: S) -> Result<Self> {
773        Ok(serde_json::from_str(json.as_ref())?)
774    }
775    pub fn builder() -> AuthorizationStateWaitRegistrationBuilder {
776        let mut inner = AuthorizationStateWaitRegistration::default();
777        inner.extra = Some(Uuid::new_v4().to_string());
778
779        AuthorizationStateWaitRegistrationBuilder { inner }
780    }
781
782    pub fn terms_of_service(&self) -> &TermsOfService {
783        &self.terms_of_service
784    }
785}
786
787#[doc(hidden)]
788pub struct AuthorizationStateWaitRegistrationBuilder {
789    inner: AuthorizationStateWaitRegistration,
790}
791
792#[deprecated]
793pub type RTDAuthorizationStateWaitRegistrationBuilder = AuthorizationStateWaitRegistrationBuilder;
794
795impl AuthorizationStateWaitRegistrationBuilder {
796    pub fn build(&self) -> AuthorizationStateWaitRegistration {
797        self.inner.clone()
798    }
799
800    pub fn terms_of_service<T: AsRef<TermsOfService>>(&mut self, terms_of_service: T) -> &mut Self {
801        self.inner.terms_of_service = terms_of_service.as_ref().clone();
802        self
803    }
804}
805
806impl AsRef<AuthorizationStateWaitRegistration> for AuthorizationStateWaitRegistration {
807    fn as_ref(&self) -> &AuthorizationStateWaitRegistration {
808        self
809    }
810}
811
812impl AsRef<AuthorizationStateWaitRegistration> for AuthorizationStateWaitRegistrationBuilder {
813    fn as_ref(&self) -> &AuthorizationStateWaitRegistration {
814        &self.inner
815    }
816}
817
818/// TDLib needs TdlibParameters for initialization
819#[derive(Debug, Clone, Default, Serialize, Deserialize)]
820pub struct AuthorizationStateWaitTdlibParameters {
821    #[doc(hidden)]
822    #[serde(rename(serialize = "@extra", deserialize = "@extra"))]
823    extra: Option<String>,
824    #[serde(rename(serialize = "@client_id", deserialize = "@client_id"))]
825    client_id: Option<i32>,
826}
827
828impl RObject for AuthorizationStateWaitTdlibParameters {
829    #[doc(hidden)]
830    fn extra(&self) -> Option<&str> {
831        self.extra.as_deref()
832    }
833    #[doc(hidden)]
834    fn client_id(&self) -> Option<i32> {
835        self.client_id
836    }
837}
838
839impl TDAuthorizationState for AuthorizationStateWaitTdlibParameters {}
840
841impl AuthorizationStateWaitTdlibParameters {
842    pub fn from_json<S: AsRef<str>>(json: S) -> Result<Self> {
843        Ok(serde_json::from_str(json.as_ref())?)
844    }
845    pub fn builder() -> AuthorizationStateWaitTdlibParametersBuilder {
846        let mut inner = AuthorizationStateWaitTdlibParameters::default();
847        inner.extra = Some(Uuid::new_v4().to_string());
848
849        AuthorizationStateWaitTdlibParametersBuilder { inner }
850    }
851}
852
853#[doc(hidden)]
854pub struct AuthorizationStateWaitTdlibParametersBuilder {
855    inner: AuthorizationStateWaitTdlibParameters,
856}
857
858#[deprecated]
859pub type RTDAuthorizationStateWaitTdlibParametersBuilder =
860    AuthorizationStateWaitTdlibParametersBuilder;
861
862impl AuthorizationStateWaitTdlibParametersBuilder {
863    pub fn build(&self) -> AuthorizationStateWaitTdlibParameters {
864        self.inner.clone()
865    }
866}
867
868impl AsRef<AuthorizationStateWaitTdlibParameters> for AuthorizationStateWaitTdlibParameters {
869    fn as_ref(&self) -> &AuthorizationStateWaitTdlibParameters {
870        self
871    }
872}
873
874impl AsRef<AuthorizationStateWaitTdlibParameters> for AuthorizationStateWaitTdlibParametersBuilder {
875    fn as_ref(&self) -> &AuthorizationStateWaitTdlibParameters {
876        &self.inner
877    }
878}