rtdlib/types/
database_statistics.rs

1
2use crate::types::*;
3use crate::errors::*;
4use uuid::Uuid;
5
6
7
8
9/// Contains database statistics
10#[derive(Debug, Clone, Default, Serialize, Deserialize)]
11pub struct DatabaseStatistics {
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  /// Database statistics in an unspecified human-readable format
19  statistics: String,
20  
21}
22
23impl RObject for DatabaseStatistics {
24  #[doc(hidden)] fn td_name(&self) -> &'static str { "databaseStatistics" }
25  #[doc(hidden)] fn extra(&self) -> Option<String> { self.extra.clone() }
26  fn to_json(&self) -> RTDResult<String> { Ok(serde_json::to_string(self)?) }
27}
28
29
30
31impl DatabaseStatistics {
32  pub fn from_json<S: AsRef<str>>(json: S) -> RTDResult<Self> { Ok(serde_json::from_str(json.as_ref())?) }
33  pub fn builder() -> RTDDatabaseStatisticsBuilder {
34    let mut inner = DatabaseStatistics::default();
35    inner.td_name = "databaseStatistics".to_string();
36    inner.extra = Some(Uuid::new_v4().to_string());
37    RTDDatabaseStatisticsBuilder { inner }
38  }
39
40  pub fn statistics(&self) -> &String { &self.statistics }
41
42}
43
44#[doc(hidden)]
45pub struct RTDDatabaseStatisticsBuilder {
46  inner: DatabaseStatistics
47}
48
49impl RTDDatabaseStatisticsBuilder {
50  pub fn build(&self) -> DatabaseStatistics { self.inner.clone() }
51
52   
53  pub fn statistics<T: AsRef<str>>(&mut self, statistics: T) -> &mut Self {
54    self.inner.statistics = statistics.as_ref().to_string();
55    self
56  }
57
58}
59
60impl AsRef<DatabaseStatistics> for DatabaseStatistics {
61  fn as_ref(&self) -> &DatabaseStatistics { self }
62}
63
64impl AsRef<DatabaseStatistics> for RTDDatabaseStatisticsBuilder {
65  fn as_ref(&self) -> &DatabaseStatistics { &self.inner }
66}
67
68
69