1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
use crate::errors::*;
use crate::types::*;
use uuid::Uuid;
#[derive(Debug, Clone, Default, Serialize, Deserialize)]
pub struct TdlibParameters {
#[doc(hidden)]
#[serde(rename(serialize = "@extra", deserialize = "@extra"))]
extra: Option<String>,
#[serde(rename(serialize = "@client_id", deserialize = "@client_id"))]
client_id: Option<i32>,
use_test_dc: bool,
database_directory: String,
files_directory: String,
use_file_database: bool,
use_chat_info_database: bool,
use_message_database: bool,
use_secret_chats: bool,
api_id: i32,
api_hash: String,
system_language_code: String,
device_model: String,
system_version: String,
application_version: String,
enable_storage_optimizer: bool,
ignore_file_names: bool,
}
impl RObject for TdlibParameters {
#[doc(hidden)]
fn extra(&self) -> Option<&str> {
self.extra.as_deref()
}
#[doc(hidden)]
fn client_id(&self) -> Option<i32> {
self.client_id
}
}
impl TdlibParameters {
pub fn from_json<S: AsRef<str>>(json: S) -> RTDResult<Self> {
Ok(serde_json::from_str(json.as_ref())?)
}
pub fn builder() -> RTDTdlibParametersBuilder {
let mut inner = TdlibParameters::default();
inner.extra = Some(Uuid::new_v4().to_string());
RTDTdlibParametersBuilder { inner }
}
pub fn use_test_dc(&self) -> bool {
self.use_test_dc
}
pub fn database_directory(&self) -> &String {
&self.database_directory
}
pub fn files_directory(&self) -> &String {
&self.files_directory
}
pub fn use_file_database(&self) -> bool {
self.use_file_database
}
pub fn use_chat_info_database(&self) -> bool {
self.use_chat_info_database
}
pub fn use_message_database(&self) -> bool {
self.use_message_database
}
pub fn use_secret_chats(&self) -> bool {
self.use_secret_chats
}
pub fn api_id(&self) -> i32 {
self.api_id
}
pub fn api_hash(&self) -> &String {
&self.api_hash
}
pub fn system_language_code(&self) -> &String {
&self.system_language_code
}
pub fn device_model(&self) -> &String {
&self.device_model
}
pub fn system_version(&self) -> &String {
&self.system_version
}
pub fn application_version(&self) -> &String {
&self.application_version
}
pub fn enable_storage_optimizer(&self) -> bool {
self.enable_storage_optimizer
}
pub fn ignore_file_names(&self) -> bool {
self.ignore_file_names
}
}
#[doc(hidden)]
pub struct RTDTdlibParametersBuilder {
inner: TdlibParameters,
}
impl RTDTdlibParametersBuilder {
pub fn build(&self) -> TdlibParameters {
self.inner.clone()
}
pub fn use_test_dc(&mut self, use_test_dc: bool) -> &mut Self {
self.inner.use_test_dc = use_test_dc;
self
}
pub fn database_directory<T: AsRef<str>>(&mut self, database_directory: T) -> &mut Self {
self.inner.database_directory = database_directory.as_ref().to_string();
self
}
pub fn files_directory<T: AsRef<str>>(&mut self, files_directory: T) -> &mut Self {
self.inner.files_directory = files_directory.as_ref().to_string();
self
}
pub fn use_file_database(&mut self, use_file_database: bool) -> &mut Self {
self.inner.use_file_database = use_file_database;
self
}
pub fn use_chat_info_database(&mut self, use_chat_info_database: bool) -> &mut Self {
self.inner.use_chat_info_database = use_chat_info_database;
self
}
pub fn use_message_database(&mut self, use_message_database: bool) -> &mut Self {
self.inner.use_message_database = use_message_database;
self
}
pub fn use_secret_chats(&mut self, use_secret_chats: bool) -> &mut Self {
self.inner.use_secret_chats = use_secret_chats;
self
}
pub fn api_id(&mut self, api_id: i32) -> &mut Self {
self.inner.api_id = api_id;
self
}
pub fn api_hash<T: AsRef<str>>(&mut self, api_hash: T) -> &mut Self {
self.inner.api_hash = api_hash.as_ref().to_string();
self
}
pub fn system_language_code<T: AsRef<str>>(&mut self, system_language_code: T) -> &mut Self {
self.inner.system_language_code = system_language_code.as_ref().to_string();
self
}
pub fn device_model<T: AsRef<str>>(&mut self, device_model: T) -> &mut Self {
self.inner.device_model = device_model.as_ref().to_string();
self
}
pub fn system_version<T: AsRef<str>>(&mut self, system_version: T) -> &mut Self {
self.inner.system_version = system_version.as_ref().to_string();
self
}
pub fn application_version<T: AsRef<str>>(&mut self, application_version: T) -> &mut Self {
self.inner.application_version = application_version.as_ref().to_string();
self
}
pub fn enable_storage_optimizer(&mut self, enable_storage_optimizer: bool) -> &mut Self {
self.inner.enable_storage_optimizer = enable_storage_optimizer;
self
}
pub fn ignore_file_names(&mut self, ignore_file_names: bool) -> &mut Self {
self.inner.ignore_file_names = ignore_file_names;
self
}
}
impl AsRef<TdlibParameters> for TdlibParameters {
fn as_ref(&self) -> &TdlibParameters {
self
}
}
impl AsRef<TdlibParameters> for RTDTdlibParametersBuilder {
fn as_ref(&self) -> &TdlibParameters {
&self.inner
}
}