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