rust_tdlib/types/
log_out.rs

1use crate::errors::Result;
2use crate::types::*;
3use uuid::Uuid;
4
5/// Closes the TDLib instance after a proper logout. Requires an available network connection. All local data will be destroyed. After the logout completes, updateAuthorizationState with authorizationStateClosed will be sent
6#[derive(Debug, Clone, Default, Serialize, Deserialize)]
7pub struct LogOut {
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 LogOut {
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 LogOut {}
30
31impl LogOut {
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() -> LogOutBuilder {
36        let mut inner = LogOut::default();
37        inner.extra = Some(Uuid::new_v4().to_string());
38
39        inner.td_type = "logOut".to_string();
40
41        LogOutBuilder { inner }
42    }
43}
44
45#[doc(hidden)]
46pub struct LogOutBuilder {
47    inner: LogOut,
48}
49
50#[deprecated]
51pub type RTDLogOutBuilder = LogOutBuilder;
52
53impl LogOutBuilder {
54    pub fn build(&self) -> LogOut {
55        self.inner.clone()
56    }
57}
58
59impl AsRef<LogOut> for LogOut {
60    fn as_ref(&self) -> &LogOut {
61        self
62    }
63}
64
65impl AsRef<LogOut> for LogOutBuilder {
66    fn as_ref(&self) -> &LogOut {
67        &self.inner
68    }
69}