rtdlib/types/
authorization_state.rs

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