1
2use crate::types::*;
3use crate::errors::*;
4use uuid::Uuid;
5
6
7
8
9#[derive(Debug, Clone, Default, Serialize, Deserialize)]
11pub struct Sessions {
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 sessions: Vec<Session>,
20 inactive_session_ttl_days: i64,
22
23}
24
25impl RObject for Sessions {
26 #[doc(hidden)] fn td_name(&self) -> &'static str { "sessions" }
27 #[doc(hidden)] fn extra(&self) -> Option<String> { self.extra.clone() }
28 fn to_json(&self) -> RTDResult<String> { Ok(serde_json::to_string(self)?) }
29}
30
31
32
33impl Sessions {
34 pub fn from_json<S: AsRef<str>>(json: S) -> RTDResult<Self> { Ok(serde_json::from_str(json.as_ref())?) }
35 pub fn builder() -> RTDSessionsBuilder {
36 let mut inner = Sessions::default();
37 inner.td_name = "sessions".to_string();
38 inner.extra = Some(Uuid::new_v4().to_string());
39 RTDSessionsBuilder { inner }
40 }
41
42 pub fn sessions(&self) -> &Vec<Session> { &self.sessions }
43
44 pub fn inactive_session_ttl_days(&self) -> i64 { self.inactive_session_ttl_days }
45
46}
47
48#[doc(hidden)]
49pub struct RTDSessionsBuilder {
50 inner: Sessions
51}
52
53impl RTDSessionsBuilder {
54 pub fn build(&self) -> Sessions { self.inner.clone() }
55
56
57 pub fn sessions(&mut self, sessions: Vec<Session>) -> &mut Self {
58 self.inner.sessions = sessions;
59 self
60 }
61
62
63 pub fn inactive_session_ttl_days(&mut self, inactive_session_ttl_days: i64) -> &mut Self {
64 self.inner.inactive_session_ttl_days = inactive_session_ttl_days;
65 self
66 }
67
68}
69
70impl AsRef<Sessions> for Sessions {
71 fn as_ref(&self) -> &Sessions { self }
72}
73
74impl AsRef<Sessions> for RTDSessionsBuilder {
75 fn as_ref(&self) -> &Sessions { &self.inner }
76}
77
78
79