rtdlib/types/
auto_download_settings_presets.rs

1
2use crate::types::*;
3use crate::errors::*;
4use uuid::Uuid;
5
6
7
8
9/// Contains auto-download settings presets for the current user
10#[derive(Debug, Clone, Default, Serialize, Deserialize)]
11pub struct AutoDownloadSettingsPresets {
12  #[doc(hidden)]
13  #[serde(rename(serialize = "@type", deserialize = "@type"))]
14  td_name: String,
15  #[doc(hidden)]
16  #[serde(rename(serialize = "@extra", deserialize = "@extra"))]
17  extra: Option<String>,
18  /// Preset with lowest settings; supposed to be used by default when roaming
19  low: AutoDownloadSettings,
20  /// Preset with medium settings; supposed to be used by default when using mobile data
21  medium: AutoDownloadSettings,
22  /// Preset with highest settings; supposed to be used by default when connected on Wi-Fi
23  high: AutoDownloadSettings,
24  
25}
26
27impl RObject for AutoDownloadSettingsPresets {
28  #[doc(hidden)] fn td_name(&self) -> &'static str { "autoDownloadSettingsPresets" }
29  #[doc(hidden)] fn extra(&self) -> Option<String> { self.extra.clone() }
30  fn to_json(&self) -> RTDResult<String> { Ok(serde_json::to_string(self)?) }
31}
32
33
34
35impl AutoDownloadSettingsPresets {
36  pub fn from_json<S: AsRef<str>>(json: S) -> RTDResult<Self> { Ok(serde_json::from_str(json.as_ref())?) }
37  pub fn builder() -> RTDAutoDownloadSettingsPresetsBuilder {
38    let mut inner = AutoDownloadSettingsPresets::default();
39    inner.td_name = "autoDownloadSettingsPresets".to_string();
40    inner.extra = Some(Uuid::new_v4().to_string());
41    RTDAutoDownloadSettingsPresetsBuilder { inner }
42  }
43
44  pub fn low(&self) -> &AutoDownloadSettings { &self.low }
45
46  pub fn medium(&self) -> &AutoDownloadSettings { &self.medium }
47
48  pub fn high(&self) -> &AutoDownloadSettings { &self.high }
49
50}
51
52#[doc(hidden)]
53pub struct RTDAutoDownloadSettingsPresetsBuilder {
54  inner: AutoDownloadSettingsPresets
55}
56
57impl RTDAutoDownloadSettingsPresetsBuilder {
58  pub fn build(&self) -> AutoDownloadSettingsPresets { self.inner.clone() }
59
60   
61  pub fn low<T: AsRef<AutoDownloadSettings>>(&mut self, low: T) -> &mut Self {
62    self.inner.low = low.as_ref().clone();
63    self
64  }
65
66   
67  pub fn medium<T: AsRef<AutoDownloadSettings>>(&mut self, medium: T) -> &mut Self {
68    self.inner.medium = medium.as_ref().clone();
69    self
70  }
71
72   
73  pub fn high<T: AsRef<AutoDownloadSettings>>(&mut self, high: T) -> &mut Self {
74    self.inner.high = high.as_ref().clone();
75    self
76  }
77
78}
79
80impl AsRef<AutoDownloadSettingsPresets> for AutoDownloadSettingsPresets {
81  fn as_ref(&self) -> &AutoDownloadSettingsPresets { self }
82}
83
84impl AsRef<AutoDownloadSettingsPresets> for RTDAutoDownloadSettingsPresetsBuilder {
85  fn as_ref(&self) -> &AutoDownloadSettingsPresets { &self.inner }
86}
87
88
89