rust_tdlib/types/
edit_custom_language_pack_info.rs

1use crate::errors::Result;
2use crate::types::*;
3use uuid::Uuid;
4
5/// Edits information about a custom local language pack in the current localization target. Can be called before authorization
6#[derive(Debug, Clone, Default, Serialize, Deserialize)]
7pub struct EditCustomLanguagePackInfo {
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    /// New information about the custom local language pack
14    info: LanguagePackInfo,
15
16    #[serde(rename(serialize = "@type"))]
17    td_type: String,
18}
19
20impl RObject for EditCustomLanguagePackInfo {
21    #[doc(hidden)]
22    fn extra(&self) -> Option<&str> {
23        self.extra.as_deref()
24    }
25    #[doc(hidden)]
26    fn client_id(&self) -> Option<i32> {
27        self.client_id
28    }
29}
30
31impl RFunction for EditCustomLanguagePackInfo {}
32
33impl EditCustomLanguagePackInfo {
34    pub fn from_json<S: AsRef<str>>(json: S) -> Result<Self> {
35        Ok(serde_json::from_str(json.as_ref())?)
36    }
37    pub fn builder() -> EditCustomLanguagePackInfoBuilder {
38        let mut inner = EditCustomLanguagePackInfo::default();
39        inner.extra = Some(Uuid::new_v4().to_string());
40
41        inner.td_type = "editCustomLanguagePackInfo".to_string();
42
43        EditCustomLanguagePackInfoBuilder { inner }
44    }
45
46    pub fn info(&self) -> &LanguagePackInfo {
47        &self.info
48    }
49}
50
51#[doc(hidden)]
52pub struct EditCustomLanguagePackInfoBuilder {
53    inner: EditCustomLanguagePackInfo,
54}
55
56#[deprecated]
57pub type RTDEditCustomLanguagePackInfoBuilder = EditCustomLanguagePackInfoBuilder;
58
59impl EditCustomLanguagePackInfoBuilder {
60    pub fn build(&self) -> EditCustomLanguagePackInfo {
61        self.inner.clone()
62    }
63
64    pub fn info<T: AsRef<LanguagePackInfo>>(&mut self, info: T) -> &mut Self {
65        self.inner.info = info.as_ref().clone();
66        self
67    }
68}
69
70impl AsRef<EditCustomLanguagePackInfo> for EditCustomLanguagePackInfo {
71    fn as_ref(&self) -> &EditCustomLanguagePackInfo {
72        self
73    }
74}
75
76impl AsRef<EditCustomLanguagePackInfo> for EditCustomLanguagePackInfoBuilder {
77    fn as_ref(&self) -> &EditCustomLanguagePackInfo {
78        &self.inner
79    }
80}