ruma_client_api/sync/
sync_events.rs1use js_int::UInt;
6use ruma_common::OwnedUserId;
7use serde::{self, Deserialize, Serialize};
8
9pub mod v3;
10
11#[cfg(feature = "unstable-msc3575")]
12pub mod v4;
13
14#[cfg(feature = "unstable-msc4186")]
15pub mod v5;
16
17#[derive(Clone, Debug, Default, Deserialize, Serialize)]
19#[cfg_attr(not(ruma_unstable_exhaustive_types), non_exhaustive)]
20pub struct UnreadNotificationsCount {
21 #[serde(skip_serializing_if = "Option::is_none")]
23 pub highlight_count: Option<UInt>,
24
25 #[serde(skip_serializing_if = "Option::is_none")]
27 pub notification_count: Option<UInt>,
28}
29
30impl UnreadNotificationsCount {
31 pub fn new() -> Self {
33 Default::default()
34 }
35
36 pub fn is_empty(&self) -> bool {
38 self.highlight_count.is_none() && self.notification_count.is_none()
39 }
40}
41
42#[derive(Clone, Debug, Default, Deserialize, Serialize)]
44#[cfg_attr(not(ruma_unstable_exhaustive_types), non_exhaustive)]
45pub struct DeviceLists {
46 #[serde(default, skip_serializing_if = "Vec::is_empty")]
49 pub changed: Vec<OwnedUserId>,
50
51 #[serde(default, skip_serializing_if = "Vec::is_empty")]
54 pub left: Vec<OwnedUserId>,
55}
56
57impl DeviceLists {
58 pub fn new() -> Self {
60 Default::default()
61 }
62
63 pub fn is_empty(&self) -> bool {
65 self.changed.is_empty() && self.left.is_empty()
66 }
67}