7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1 | // Copyright 2022 The Matrix.org Foundation C.I.C. |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 2 | // |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 3 | // Licensed under the Apache License, Version 2.0 (the "License"); |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 4 | // you may not use this file except in compliance with the License. |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 5 | // You may obtain a copy of the License at |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 6 | // |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 7 | // http://www.apache.org/licenses/LICENSE-2.0 |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 8 | // |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 9 | // Unless required by applicable law or agreed to in writing, software |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 10 | // distributed under the License is distributed on an "AS IS" BASIS, |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 12 | // See the License for the specific language governing permissions and |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 13 | // limitations under the License. |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 14 | |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 15 | //! The SDK's representation of the result of a `/sync` request. |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 16 | |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 17 | use std::{collections::BTreeMap, fmt}; |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 18 | |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 19 | use matrix_sdk_common::{ |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 20 | debug::DebugRawEvent, |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 21 | deserialized_responses::{ProcessedToDeviceEvent, TimelineEvent}, |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 22 | }; |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 23 | pub use ruma::api::client::sync::sync_events::v3::{ |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 24 | InvitedRoom as InvitedRoomUpdate, KnockedRoom as KnockedRoomUpdate, |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 25 | }; |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 26 | use ruma::{ |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 27 | OwnedEventId, OwnedMxcUri, OwnedRoomId, OwnedUserId, |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 28 | api::client::sync::sync_events::UnreadNotificationsCount as RumaUnreadNotificationsCount, |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 29 | events::{ |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 30 | AnyGlobalAccountDataEvent, AnyRoomAccountDataEvent, AnySyncEphemeralRoomEvent, |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 31 | AnySyncStateEvent, presence::PresenceEvent, |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 32 | }, |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 33 | push::Action, |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 34 | serde::Raw, |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 35 | }; |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 36 | use serde::{Deserialize, Serialize}; |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 37 | |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 38 | use crate::{ |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 39 | debug::{ |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 40 | DebugInvitedRoom, DebugKnockedRoom, DebugListOfProcessedToDeviceEvents, |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 41 | DebugListOfRawEvents, DebugListOfRawEventsNoId, |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 42 | }, |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 43 | deserialized_responses::{AmbiguityChange, RawAnySyncOrStrippedTimelineEvent}, |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 44 | }; |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 45 | |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 46 | /// Generalized representation of a `/sync` response. |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 47 | /// |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 48 | /// This type is intended to be applicable regardless of the endpoint used for |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 49 | /// syncing. |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 50 | #[derive(Clone, Default)] |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 51 | pub struct SyncResponse { |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 52 | /// Updates to rooms. |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 53 | pub rooms: RoomUpdates, |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 54 | /// Updates to the presence status of other users. |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 55 | pub presence: Vec<Raw<PresenceEvent>>, |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 56 | /// The global private data created by this user. |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 57 | pub account_data: Vec<Raw<AnyGlobalAccountDataEvent>>, |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 58 | /// Messages sent directly between devices. |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 59 | pub to_device: Vec<ProcessedToDeviceEvent>, |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 60 | /// New notifications per room. |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 61 | pub notifications: BTreeMap<OwnedRoomId, Vec<Notification>>, |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 62 | } |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 63 | |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 64 | #[cfg(not(tarpaulin_include))] |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 65 | impl fmt::Debug for SyncResponse { |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 66 | fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 67 | f.debug_struct("SyncResponse") |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 68 | .field("rooms", &self.rooms) |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 69 | .field("account_data", &DebugListOfRawEventsNoId(&self.account_data)) |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 70 | .field("to_device", &DebugListOfProcessedToDeviceEvents(&self.to_device)) |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 71 | .field("notifications", &self.notifications) |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 72 | .finish_non_exhaustive() |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 73 | } |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 74 | } |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 75 | |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 76 | /// Updates to rooms in a [`SyncResponse`]. |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 77 | #[derive(Clone, Default)] |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 78 | pub struct RoomUpdates { |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 79 | /// The rooms that the user has left or been banned from. |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 80 | pub left: BTreeMap<OwnedRoomId, LeftRoomUpdate>, |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 81 | /// The rooms that the user has joined. |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 82 | pub joined: BTreeMap<OwnedRoomId, JoinedRoomUpdate>, |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 83 | /// The rooms that the user has been invited to. |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 84 | pub invited: BTreeMap<OwnedRoomId, InvitedRoomUpdate>, |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 85 | /// The rooms that the user has knocked on. |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 86 | pub knocked: BTreeMap<OwnedRoomId, KnockedRoomUpdate>, |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 87 | } |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 88 | |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 89 | impl RoomUpdates { |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 90 | /// Iterate over all room IDs, from [`RoomUpdates::left`], |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 91 | /// [`RoomUpdates::joined`], [`RoomUpdates::invited`] and |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 92 | /// [`RoomUpdates::knocked`]. |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 93 | pub fn iter_all_room_ids(&self) -> impl Iterator<Item = &OwnedRoomId> { |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 94 | self.left |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 95 | .keys() |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 96 | .chain(self.joined.keys()) |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 97 | .chain(self.invited.keys()) |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 98 | .chain(self.knocked.keys()) |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 99 | } |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 100 | |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 101 | /// Returns whether or not this update contains any changes to the list |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 102 | /// of invited, joined, knocked or left rooms. |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 103 | pub fn is_empty(&self) -> bool { |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 104 | self.invited.is_empty() |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 105 | && self.joined.is_empty() |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 106 | && self.knocked.is_empty() |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 107 | && self.left.is_empty() |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 108 | } |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 109 | } |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 110 | |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 111 | #[cfg(test)] |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 112 | mod tests { |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 113 | use std::collections::BTreeMap; |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 114 | |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 115 | use assert_matches::assert_matches; |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 116 | use ruma::room_id; |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 117 | |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 118 | use super::{ |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 119 | InvitedRoomUpdate, JoinedRoomUpdate, KnockedRoomUpdate, LeftRoomUpdate, RoomUpdates, |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 120 | }; |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 121 | |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 122 | #[test] |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 123 | fn test_room_updates_iter_all_room_ids() { |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 124 | let room_id_0 = room_id!("!r0"); |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 125 | let room_id_1 = room_id!("!r1"); |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 126 | let room_id_2 = room_id!("!r2"); |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 127 | let room_id_3 = room_id!("!r3"); |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 128 | let room_id_4 = room_id!("!r4"); |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 129 | let room_id_5 = room_id!("!r5"); |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 130 | let room_id_6 = room_id!("!r6"); |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 131 | let room_id_7 = room_id!("!r7"); |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 132 | let room_updates = RoomUpdates { |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 133 | left: { |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 134 | let mut left = BTreeMap::new(); |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 135 | left.insert(room_id_0.to_owned(), LeftRoomUpdate::default()); |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 136 | left.insert(room_id_1.to_owned(), LeftRoomUpdate::default()); |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 137 | left |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 138 | }, |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 139 | joined: { |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 140 | let mut joined = BTreeMap::new(); |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 141 | joined.insert(room_id_2.to_owned(), JoinedRoomUpdate::default()); |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 142 | joined.insert(room_id_3.to_owned(), JoinedRoomUpdate::default()); |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 143 | joined |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 144 | }, |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 145 | invited: { |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 146 | let mut invited = BTreeMap::new(); |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 147 | invited.insert(room_id_4.to_owned(), InvitedRoomUpdate::default()); |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 148 | invited.insert(room_id_5.to_owned(), InvitedRoomUpdate::default()); |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 149 | invited |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 150 | }, |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 151 | knocked: { |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 152 | let mut knocked = BTreeMap::new(); |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 153 | knocked.insert(room_id_6.to_owned(), KnockedRoomUpdate::default()); |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 154 | knocked.insert(room_id_7.to_owned(), KnockedRoomUpdate::default()); |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 155 | knocked |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 156 | }, |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 157 | }; |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 158 | |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 159 | let mut iter = room_updates.iter_all_room_ids(); |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 160 | assert_matches!(iter.next(), Some(room_id) => assert_eq!(room_id, room_id_0)); |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 161 | assert_matches!(iter.next(), Some(room_id) => assert_eq!(room_id, room_id_1)); |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 162 | assert_matches!(iter.next(), Some(room_id) => assert_eq!(room_id, room_id_2)); |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 163 | assert_matches!(iter.next(), Some(room_id) => assert_eq!(room_id, room_id_3)); |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 164 | assert_matches!(iter.next(), Some(room_id) => assert_eq!(room_id, room_id_4)); |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 165 | assert_matches!(iter.next(), Some(room_id) => assert_eq!(room_id, room_id_5)); |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 166 | assert_matches!(iter.next(), Some(room_id) => assert_eq!(room_id, room_id_6)); |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 167 | assert_matches!(iter.next(), Some(room_id) => assert_eq!(room_id, room_id_7)); |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 168 | assert!(iter.next().is_none()); |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 169 | } |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 170 | |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 171 | #[test] |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 172 | fn test_empty_room_updates() { |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 173 | let room_updates = RoomUpdates::default(); |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 174 | |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 175 | let mut iter = room_updates.iter_all_room_ids(); |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 176 | assert!(iter.next().is_none()); |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 177 | |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 178 | assert!(room_updates.is_empty()); |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 179 | } |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 180 | } |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 181 | |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 182 | #[cfg(not(tarpaulin_include))] |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 183 | impl fmt::Debug for RoomUpdates { |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 184 | fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 185 | f.debug_struct("RoomUpdates") |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 186 | .field("left", &self.left) |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 187 | .field("joined", &self.joined) |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 188 | .field("invited", &DebugInvitedRoomUpdates(&self.invited)) |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 189 | .field("knocked", &DebugKnockedRoomUpdates(&self.knocked)) |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 190 | .finish() |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 191 | } |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 192 | } |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 193 | |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 194 | /// Updates to joined rooms. |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 195 | #[derive(Clone, Default)] |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 196 | pub struct JoinedRoomUpdate { |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 197 | /// Counts of unread notifications for this room. |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 198 | pub unread_notifications: UnreadNotificationsCount, |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 199 | /// The timeline of messages and state changes in the room. |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 200 | pub timeline: Timeline, |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 201 | /// Updates to the state. |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 202 | /// |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 203 | /// If `since` is missing or `full_state` is true, the start point of the |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 204 | /// update is the beginning of the timeline. Otherwise, the start point |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 205 | /// is the time specified in `since`. |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 206 | /// |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 207 | /// If `state_after` was used, the end point of the update is the end of the |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 208 | /// `timeline`. Otherwise, the end point of these updates is the start of |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 209 | /// the `timeline`, and to calculate room state we must scan the `timeline` |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 210 | /// for state events as well as using this information in this property. |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 211 | pub state: State, |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 212 | /// The private data that this user has attached to this room. |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 213 | pub account_data: Vec<Raw<AnyRoomAccountDataEvent>>, |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 214 | /// The ephemeral events in the room that aren't recorded in the timeline or |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 215 | /// state of the room. e.g. typing. |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 216 | pub ephemeral: Vec<Raw<AnySyncEphemeralRoomEvent>>, |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 217 | /// Collection of ambiguity changes that room member events trigger. |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 218 | /// |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 219 | /// This is a map of event ID of the `m.room.member` event to the |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 220 | /// details of the ambiguity change. |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 221 | pub ambiguity_changes: BTreeMap<OwnedEventId, AmbiguityChange>, |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 222 | /// Collection of avatar changes that room member events trigger. |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 223 | pub avatar_changes: Option<BTreeMap<OwnedUserId, Option<OwnedMxcUri>>>, |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 224 | } |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 225 | |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 226 | #[cfg(not(tarpaulin_include))] |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 227 | impl fmt::Debug for JoinedRoomUpdate { |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 228 | fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 229 | f.debug_struct("JoinedRoomUpdate") |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 230 | .field("unread_notifications", &self.unread_notifications) |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 231 | .field("timeline", &self.timeline) |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 232 | .field("state", &self.state) |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 233 | .field("account_data", &DebugListOfRawEventsNoId(&self.account_data)) |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 234 | .field("ephemeral", &self.ephemeral) |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 235 | .field("ambiguity_changes", &self.ambiguity_changes) |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 236 | .finish() |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 237 | } |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 238 | } |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 239 | |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 240 | impl JoinedRoomUpdate { |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 241 | pub(crate) fn new( |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 242 | timeline: Timeline, |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 243 | state: State, |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 244 | account_data: Vec<Raw<AnyRoomAccountDataEvent>>, |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 245 | ephemeral: Vec<Raw<AnySyncEphemeralRoomEvent>>, |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 246 | unread_notifications: UnreadNotificationsCount, |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 247 | ambiguity_changes: BTreeMap<OwnedEventId, AmbiguityChange>, |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 248 | avatar_changes: Option<BTreeMap<OwnedUserId, Option<OwnedMxcUri>>>, |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 249 | ) -> Self { |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 250 | Self { |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 251 | unread_notifications, |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 252 | timeline, |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 253 | state, |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 254 | account_data, |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 255 | ephemeral, |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 256 | ambiguity_changes, |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 257 | avatar_changes, |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 258 | } |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 259 | } |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 260 | } |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 261 | |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 262 | /// Counts of unread notifications for a room. |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 263 | #[derive(Copy, Clone, Debug, Default, Deserialize, Serialize, PartialEq)] |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 264 | pub struct UnreadNotificationsCount { |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 265 | /// The number of unread notifications for this room with the highlight flag |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 266 | /// set. |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 267 | pub highlight_count: u64, |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 268 | /// The total number of unread notifications for this room. |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 269 | pub notification_count: u64, |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 270 | } |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 271 | |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 272 | impl From<RumaUnreadNotificationsCount> for UnreadNotificationsCount { |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 273 | fn from(notifications: RumaUnreadNotificationsCount) -> Self { |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 274 | Self { |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 275 | highlight_count: notifications.highlight_count.map(|c| c.into()).unwrap_or(0), |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 276 | notification_count: notifications.notification_count.map(|c| c.into()).unwrap_or(0), |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 277 | } |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 278 | } |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 279 | } |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 280 | |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 281 | /// Updates to left rooms. |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 282 | #[derive(Clone, Default)] |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 283 | pub struct LeftRoomUpdate { |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 284 | /// The timeline of messages and state changes in the room up to the point |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 285 | /// when the user left. |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 286 | pub timeline: Timeline, |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 287 | /// Updates to the state. |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 288 | /// |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 289 | /// If `since` is missing or `full_state` is true, the start point of the |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 290 | /// update is the beginning of the timeline. Otherwise, the start point |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 291 | /// is the time specified in `since`. |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 292 | /// |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 293 | /// If `state_after` was used, the end point of the update is the end of the |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 294 | /// `timeline`. Otherwise, the end point of these updates is the start of |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 295 | /// the `timeline`, and to calculate room state we must scan the `timeline` |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 296 | /// for state events as well as using this information in this property. |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 297 | pub state: State, |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 298 | /// The private data that this user has attached to this room. |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 299 | pub account_data: Vec<Raw<AnyRoomAccountDataEvent>>, |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 300 | /// Collection of ambiguity changes that room member events trigger. |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 301 | /// |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 302 | /// This is a map of event ID of the `m.room.member` event to the |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 303 | /// details of the ambiguity change. |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 304 | pub ambiguity_changes: BTreeMap<OwnedEventId, AmbiguityChange>, |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 305 | } |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 306 | |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 307 | impl LeftRoomUpdate { |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 308 | pub(crate) fn new( |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 309 | timeline: Timeline, |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 310 | state: State, |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 311 | account_data: Vec<Raw<AnyRoomAccountDataEvent>>, |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 312 | ambiguity_changes: BTreeMap<OwnedEventId, AmbiguityChange>, |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 313 | ) -> Self { |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 314 | Self { timeline, state, account_data, ambiguity_changes } |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 315 | } |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 316 | } |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 317 | |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 318 | #[cfg(not(tarpaulin_include))] |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 319 | impl fmt::Debug for LeftRoomUpdate { |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 320 | fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 321 | f.debug_struct("LeftRoomUpdate") |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 322 | .field("timeline", &self.timeline) |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 323 | .field("state", &self.state) |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 324 | .field("account_data", &DebugListOfRawEventsNoId(&self.account_data)) |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 325 | .field("ambiguity_changes", &self.ambiguity_changes) |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 326 | .finish() |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 327 | } |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 328 | } |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 329 | |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 330 | /// Events in the room. |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 331 | #[derive(Clone, Debug, Default)] |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 332 | pub struct Timeline { |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 333 | /// True if the number of events returned was limited by the `limit` on the |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 334 | /// filter. |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 335 | pub limited: bool, |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 336 | |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 337 | /// A token that can be supplied to to the `from` parameter of the |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 338 | /// `/rooms/{roomId}/messages` endpoint. |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 339 | pub prev_batch: Option<String>, |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 340 | |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 341 | /// A list of events. |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 342 | pub events: Vec<TimelineEvent>, |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 343 | } |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 344 | |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 345 | impl Timeline { |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 346 | pub(crate) fn new(limited: bool, prev_batch: Option<String>) -> Self { |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 347 | Self { limited, prev_batch, ..Default::default() } |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 348 | } |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 349 | } |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 350 | |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 351 | /// State changes in the room. |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 352 | #[derive(Clone)] |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 353 | pub enum State { |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 354 | /// The state changes between the previous sync and the start of the |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 355 | /// timeline. |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 356 | /// |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 357 | /// To get the full list of state changes since the previous sync, the state |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 358 | /// events in [`Timeline`] must be added to these events to update the local |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 359 | /// state. |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 360 | Before(Vec<Raw<AnySyncStateEvent>>), |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 361 | |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 362 | /// The state changes between the previous sync and the end of the timeline. |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 363 | /// |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 364 | /// This contains the full list of state changes since the previous sync. |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 365 | /// State events in [`Timeline`] must be ignored to update the local state. |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 366 | After(Vec<Raw<AnySyncStateEvent>>), |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 367 | } |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 368 | |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 369 | impl Default for State { |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 370 | fn default() -> Self { |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 371 | Self::Before(vec![]) |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 372 | } |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 373 | } |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 374 | |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 375 | #[cfg(not(tarpaulin_include))] |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 376 | impl fmt::Debug for State { |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 377 | fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 378 | match self { |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 379 | Self::Before(events) => { |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 380 | f.debug_tuple("Before").field(&DebugListOfRawEvents(events)).finish() |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 381 | } |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 382 | Self::After(events) => { |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 383 | f.debug_tuple("After").field(&DebugListOfRawEvents(events)).finish() |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 384 | } |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 385 | } |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 386 | } |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 387 | } |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 388 | |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 389 | struct DebugInvitedRoomUpdates<'a>(&'a BTreeMap<OwnedRoomId, InvitedRoomUpdate>); |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 390 | |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 391 | #[cfg(not(tarpaulin_include))] |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 392 | impl fmt::Debug for DebugInvitedRoomUpdates<'_> { |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 393 | fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 394 | f.debug_map().entries(self.0.iter().map(|(k, v)| (k, DebugInvitedRoom(v)))).finish() |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 395 | } |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 396 | } |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 397 | |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 398 | struct DebugKnockedRoomUpdates<'a>(&'a BTreeMap<OwnedRoomId, KnockedRoomUpdate>); |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 399 | |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 400 | #[cfg(not(tarpaulin_include))] |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 401 | impl fmt::Debug for DebugKnockedRoomUpdates<'_> { |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 402 | fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 403 | f.debug_map().entries(self.0.iter().map(|(k, v)| (k, DebugKnockedRoom(v)))).finish() |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 404 | } |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 405 | } |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 406 | |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 407 | /// A notification triggered by a sync response. |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 408 | #[derive(Clone)] |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 409 | pub struct Notification { |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 410 | /// The actions to perform when the conditions for this rule are met. |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 411 | pub actions: Vec<Action>, |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 412 | |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 413 | /// The event that triggered the notification. |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 414 | pub event: RawAnySyncOrStrippedTimelineEvent, |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 415 | } |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 416 | |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 417 | #[cfg(not(tarpaulin_include))] |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 418 | impl fmt::Debug for Notification { |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 419 | fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 420 | let event_debug = match &self.event { |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 421 | RawAnySyncOrStrippedTimelineEvent::Sync(ev) => DebugRawEvent(ev), |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 422 | RawAnySyncOrStrippedTimelineEvent::Stripped(ev) => { |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 423 | DebugRawEvent(ev.cast_ref_unchecked()) |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 424 | } |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 425 | }; |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 426 | |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 427 | f.debug_struct("Notification") |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 428 | .field("actions", &self.actions) |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 429 | .field("event", &event_debug) |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 430 | .finish() |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 431 | } |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 432 | } |