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
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329

use crate::types::*;
use crate::errors::*;




use std::fmt::Debug;
use serde::de::{Deserialize, Deserializer};



/// TRAIT | Represents the value of a string in a language pack
pub trait TDLanguagePackStringValue: Debug + RObject {}

/// Represents the value of a string in a language pack
#[derive(Debug, Clone, Serialize)]
#[serde(untagged)]
pub enum LanguagePackStringValue {
  #[doc(hidden)] _Default(()),
  /// An ordinary language pack string
  Ordinary(LanguagePackStringValueOrdinary),
  /// A language pack string which has different forms based on the number of some object it mentions. See https://www.unicode.org/cldr/charts/latest/supplemental/language_plural_rules.html for more info
  Pluralized(LanguagePackStringValuePluralized),
  /// A deleted language pack string, the value should be taken from the built-in english language pack
  Deleted(LanguagePackStringValueDeleted),
  /// Returns a string stored in the local database from the specified localization target and language pack by its key. Returns a 404 error if the string is not found. This is an offline method. Can be called before authorization. Can be called synchronously
  GetLanguagePackString(GetLanguagePackString),

}

impl Default for LanguagePackStringValue {
  fn default() -> Self { LanguagePackStringValue::_Default(()) }
}

impl<'de> Deserialize<'de> for LanguagePackStringValue {
  fn deserialize<D>(deserializer: D) -> Result<LanguagePackStringValue, D::Error> where D: Deserializer<'de> {
    use serde::de::Error;
    rtd_enum_deserialize!(
      LanguagePackStringValue,
      (languagePackStringValueOrdinary, Ordinary);
      (languagePackStringValuePluralized, Pluralized);
      (languagePackStringValueDeleted, Deleted);
      (getLanguagePackString, GetLanguagePackString);

    )(deserializer)
  }
}

impl RObject for LanguagePackStringValue {
  #[doc(hidden)] fn td_name(&self) -> &'static str {
    match self {
      LanguagePackStringValue::Ordinary(t) => t.td_name(),
      LanguagePackStringValue::Pluralized(t) => t.td_name(),
      LanguagePackStringValue::Deleted(t) => t.td_name(),
      LanguagePackStringValue::GetLanguagePackString(t) => t.td_name(),

      _ => "-1",
    }
  }
  fn to_json(&self) -> RTDResult<String> { Ok(serde_json::to_string(self)?) }
}

impl LanguagePackStringValue {
  pub fn from_json<S: AsRef<str>>(json: S) -> RTDResult<Self> { Ok(serde_json::from_str(json.as_ref())?) }
  #[doc(hidden)] pub fn _is_default(&self) -> bool { if let LanguagePackStringValue::_Default(_) = self { true } else { false } }

  pub fn is_ordinary(&self) -> bool { if let LanguagePackStringValue::Ordinary(_) = self { true } else { false } }
  pub fn is_pluralized(&self) -> bool { if let LanguagePackStringValue::Pluralized(_) = self { true } else { false } }
  pub fn is_deleted(&self) -> bool { if let LanguagePackStringValue::Deleted(_) = self { true } else { false } }
  pub fn is_get_language_pack_string(&self) -> bool { if let LanguagePackStringValue::GetLanguagePackString(_) = self { true } else { false } }

  pub fn on_ordinary<F: FnOnce(&LanguagePackStringValueOrdinary)>(&self, fnc: F) -> &Self { if let LanguagePackStringValue::Ordinary(t) = self { fnc(t) }; self }
  pub fn on_pluralized<F: FnOnce(&LanguagePackStringValuePluralized)>(&self, fnc: F) -> &Self { if let LanguagePackStringValue::Pluralized(t) = self { fnc(t) }; self }
  pub fn on_deleted<F: FnOnce(&LanguagePackStringValueDeleted)>(&self, fnc: F) -> &Self { if let LanguagePackStringValue::Deleted(t) = self { fnc(t) }; self }
  pub fn on_get_language_pack_string<F: FnOnce(&GetLanguagePackString)>(&self, fnc: F) -> &Self { if let LanguagePackStringValue::GetLanguagePackString(t) = self { fnc(t) }; self }

  pub fn as_ordinary(&self) -> Option<&LanguagePackStringValueOrdinary> { if let LanguagePackStringValue::Ordinary(t) = self { return Some(t) } None }
  pub fn as_pluralized(&self) -> Option<&LanguagePackStringValuePluralized> { if let LanguagePackStringValue::Pluralized(t) = self { return Some(t) } None }
  pub fn as_deleted(&self) -> Option<&LanguagePackStringValueDeleted> { if let LanguagePackStringValue::Deleted(t) = self { return Some(t) } None }
  pub fn as_get_language_pack_string(&self) -> Option<&GetLanguagePackString> { if let LanguagePackStringValue::GetLanguagePackString(t) = self { return Some(t) } None }



  pub fn ordinary<T: AsRef<LanguagePackStringValueOrdinary>>(t: T) -> Self { LanguagePackStringValue::Ordinary(t.as_ref().clone()) }

  pub fn pluralized<T: AsRef<LanguagePackStringValuePluralized>>(t: T) -> Self { LanguagePackStringValue::Pluralized(t.as_ref().clone()) }

  pub fn deleted<T: AsRef<LanguagePackStringValueDeleted>>(t: T) -> Self { LanguagePackStringValue::Deleted(t.as_ref().clone()) }

  pub fn get_language_pack_string<T: AsRef<GetLanguagePackString>>(t: T) -> Self { LanguagePackStringValue::GetLanguagePackString(t.as_ref().clone()) }

}

impl AsRef<LanguagePackStringValue> for LanguagePackStringValue {
  fn as_ref(&self) -> &LanguagePackStringValue { self }
}







/// An ordinary language pack string
#[derive(Debug, Clone, Default, Serialize, Deserialize)]
pub struct LanguagePackStringValueOrdinary {
  #[doc(hidden)]
  #[serde(rename(serialize = "@type", deserialize = "@type"))]
  td_name: String,
  /// String value
  value: String,
  
}

impl RObject for LanguagePackStringValueOrdinary {
  #[doc(hidden)] fn td_name(&self) -> &'static str { "languagePackStringValueOrdinary" }
  fn to_json(&self) -> RTDResult<String> { Ok(serde_json::to_string(self)?) }
}


impl TDLanguagePackStringValue for LanguagePackStringValueOrdinary {}



impl LanguagePackStringValueOrdinary {
  pub fn from_json<S: AsRef<str>>(json: S) -> RTDResult<Self> { Ok(serde_json::from_str(json.as_ref())?) }
  pub fn builder() -> RTDLanguagePackStringValueOrdinaryBuilder {
    let mut inner = LanguagePackStringValueOrdinary::default();
    inner.td_name = "languagePackStringValueOrdinary".to_string();
    RTDLanguagePackStringValueOrdinaryBuilder { inner }
  }

  pub fn value(&self) -> &String { &self.value }

}

#[doc(hidden)]
pub struct RTDLanguagePackStringValueOrdinaryBuilder {
  inner: LanguagePackStringValueOrdinary
}

impl RTDLanguagePackStringValueOrdinaryBuilder {
  pub fn build(&self) -> LanguagePackStringValueOrdinary { self.inner.clone() }

   
  pub fn value<T: AsRef<str>>(&mut self, value: T) -> &mut Self {
    self.inner.value = value.as_ref().to_string();
    self
  }

}

impl AsRef<LanguagePackStringValueOrdinary> for LanguagePackStringValueOrdinary {
  fn as_ref(&self) -> &LanguagePackStringValueOrdinary { self }
}

impl AsRef<LanguagePackStringValueOrdinary> for RTDLanguagePackStringValueOrdinaryBuilder {
  fn as_ref(&self) -> &LanguagePackStringValueOrdinary { &self.inner }
}







/// A language pack string which has different forms based on the number of some object it mentions. See https://www.unicode.org/cldr/charts/latest/supplemental/language_plural_rules.html for more info
#[derive(Debug, Clone, Default, Serialize, Deserialize)]
pub struct LanguagePackStringValuePluralized {
  #[doc(hidden)]
  #[serde(rename(serialize = "@type", deserialize = "@type"))]
  td_name: String,
  /// Value for zero objects
  zero_value: String,
  /// Value for one object
  one_value: String,
  /// Value for two objects
  two_value: String,
  /// Value for few objects
  few_value: String,
  /// Value for many objects
  many_value: String,
  /// Default value
  other_value: String,
  
}

impl RObject for LanguagePackStringValuePluralized {
  #[doc(hidden)] fn td_name(&self) -> &'static str { "languagePackStringValuePluralized" }
  fn to_json(&self) -> RTDResult<String> { Ok(serde_json::to_string(self)?) }
}


impl TDLanguagePackStringValue for LanguagePackStringValuePluralized {}



impl LanguagePackStringValuePluralized {
  pub fn from_json<S: AsRef<str>>(json: S) -> RTDResult<Self> { Ok(serde_json::from_str(json.as_ref())?) }
  pub fn builder() -> RTDLanguagePackStringValuePluralizedBuilder {
    let mut inner = LanguagePackStringValuePluralized::default();
    inner.td_name = "languagePackStringValuePluralized".to_string();
    RTDLanguagePackStringValuePluralizedBuilder { inner }
  }

  pub fn zero_value(&self) -> &String { &self.zero_value }

  pub fn one_value(&self) -> &String { &self.one_value }

  pub fn two_value(&self) -> &String { &self.two_value }

  pub fn few_value(&self) -> &String { &self.few_value }

  pub fn many_value(&self) -> &String { &self.many_value }

  pub fn other_value(&self) -> &String { &self.other_value }

}

#[doc(hidden)]
pub struct RTDLanguagePackStringValuePluralizedBuilder {
  inner: LanguagePackStringValuePluralized
}

impl RTDLanguagePackStringValuePluralizedBuilder {
  pub fn build(&self) -> LanguagePackStringValuePluralized { self.inner.clone() }

   
  pub fn zero_value<T: AsRef<str>>(&mut self, zero_value: T) -> &mut Self {
    self.inner.zero_value = zero_value.as_ref().to_string();
    self
  }

   
  pub fn one_value<T: AsRef<str>>(&mut self, one_value: T) -> &mut Self {
    self.inner.one_value = one_value.as_ref().to_string();
    self
  }

   
  pub fn two_value<T: AsRef<str>>(&mut self, two_value: T) -> &mut Self {
    self.inner.two_value = two_value.as_ref().to_string();
    self
  }

   
  pub fn few_value<T: AsRef<str>>(&mut self, few_value: T) -> &mut Self {
    self.inner.few_value = few_value.as_ref().to_string();
    self
  }

   
  pub fn many_value<T: AsRef<str>>(&mut self, many_value: T) -> &mut Self {
    self.inner.many_value = many_value.as_ref().to_string();
    self
  }

   
  pub fn other_value<T: AsRef<str>>(&mut self, other_value: T) -> &mut Self {
    self.inner.other_value = other_value.as_ref().to_string();
    self
  }

}

impl AsRef<LanguagePackStringValuePluralized> for LanguagePackStringValuePluralized {
  fn as_ref(&self) -> &LanguagePackStringValuePluralized { self }
}

impl AsRef<LanguagePackStringValuePluralized> for RTDLanguagePackStringValuePluralizedBuilder {
  fn as_ref(&self) -> &LanguagePackStringValuePluralized { &self.inner }
}







/// A deleted language pack string, the value should be taken from the built-in english language pack
#[derive(Debug, Clone, Default, Serialize, Deserialize)]
pub struct LanguagePackStringValueDeleted {
  #[doc(hidden)]
  #[serde(rename(serialize = "@type", deserialize = "@type"))]
  td_name: String,
  
}

impl RObject for LanguagePackStringValueDeleted {
  #[doc(hidden)] fn td_name(&self) -> &'static str { "languagePackStringValueDeleted" }
  fn to_json(&self) -> RTDResult<String> { Ok(serde_json::to_string(self)?) }
}


impl TDLanguagePackStringValue for LanguagePackStringValueDeleted {}



impl LanguagePackStringValueDeleted {
  pub fn from_json<S: AsRef<str>>(json: S) -> RTDResult<Self> { Ok(serde_json::from_str(json.as_ref())?) }
  pub fn builder() -> RTDLanguagePackStringValueDeletedBuilder {
    let mut inner = LanguagePackStringValueDeleted::default();
    inner.td_name = "languagePackStringValueDeleted".to_string();
    RTDLanguagePackStringValueDeletedBuilder { inner }
  }

}

#[doc(hidden)]
pub struct RTDLanguagePackStringValueDeletedBuilder {
  inner: LanguagePackStringValueDeleted
}

impl RTDLanguagePackStringValueDeletedBuilder {
  pub fn build(&self) -> LanguagePackStringValueDeleted { self.inner.clone() }

}

impl AsRef<LanguagePackStringValueDeleted> for LanguagePackStringValueDeleted {
  fn as_ref(&self) -> &LanguagePackStringValueDeleted { self }
}

impl AsRef<LanguagePackStringValueDeleted> for RTDLanguagePackStringValueDeletedBuilder {
  fn as_ref(&self) -> &LanguagePackStringValueDeleted { &self.inner }
}