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