ruma_client_api/sync/
sync_events.rs

1//! `GET /_matrix/client/*/sync`
2//!
3//! Get all new events from all rooms since the last sync or a given point in time.
4
5use 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/// Unread notifications count.
18#[derive(Clone, Debug, Default, Deserialize, Serialize)]
19#[cfg_attr(not(ruma_unstable_exhaustive_types), non_exhaustive)]
20pub struct UnreadNotificationsCount {
21    /// The number of unread notifications with the highlight flag set.
22    #[serde(skip_serializing_if = "Option::is_none")]
23    pub highlight_count: Option<UInt>,
24
25    /// The total number of unread notifications.
26    #[serde(skip_serializing_if = "Option::is_none")]
27    pub notification_count: Option<UInt>,
28}
29
30impl UnreadNotificationsCount {
31    /// Creates an empty `UnreadNotificationsCount`.
32    pub fn new() -> Self {
33        Default::default()
34    }
35
36    /// Returns true if there are no notification count updates.
37    pub fn is_empty(&self) -> bool {
38        self.highlight_count.is_none() && self.notification_count.is_none()
39    }
40}
41
42/// Information on E2E device updates.
43#[derive(Clone, Debug, Default, Deserialize, Serialize)]
44#[cfg_attr(not(ruma_unstable_exhaustive_types), non_exhaustive)]
45pub struct DeviceLists {
46    /// List of users who have updated their device identity keys or who now
47    /// share an encrypted room with the client since the previous sync.
48    #[serde(default, skip_serializing_if = "Vec::is_empty")]
49    pub changed: Vec<OwnedUserId>,
50
51    /// List of users who no longer share encrypted rooms since the previous sync
52    /// response.
53    #[serde(default, skip_serializing_if = "Vec::is_empty")]
54    pub left: Vec<OwnedUserId>,
55}
56
57impl DeviceLists {
58    /// Creates an empty `DeviceLists`.
59    pub fn new() -> Self {
60        Default::default()
61    }
62
63    /// Returns true if there are no device list updates.
64    pub fn is_empty(&self) -> bool {
65        self.changed.is_empty() && self.left.is_empty()
66    }
67}