From 5f159d4418f3009b62c44ead5ce49cded620bb43 Mon Sep 17 00:00:00 2001 From: Ivan Enderlin Date: Wed, 21 Aug 2024 17:54:30 +0200 Subject: [PATCH] feat(sdk): Add `RoomSubscriptionState`. This patch introduces the `RoomSubscriptionState` type, to represent whether a room subscription has already been correctly sent to the server. --- crates/matrix-sdk/src/sliding_sync/mod.rs | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/crates/matrix-sdk/src/sliding_sync/mod.rs b/crates/matrix-sdk/src/sliding_sync/mod.rs index 7d006de08..756b48740 100644 --- a/crates/matrix-sdk/src/sliding_sync/mod.rs +++ b/crates/matrix-sdk/src/sliding_sync/mod.rs @@ -898,6 +898,22 @@ pub struct UpdateSummary { pub rooms: Vec, } +/// A very basic bool-ish enum to represent the state of a +/// [`http::request::RoomSubscription`]. A `RoomSubscription` that has been sent +/// once should ideally not being sent again, to mostly save bandwidth. +#[derive(Debug, Default)] +enum RoomSubscriptionState { + /// The `RoomSubscription` has not been sent or received correctly from the + /// server, i.e. the `RoomSubscription` —which is part of the sticky + /// parameters— has not been committed. + #[default] + Pending, + + /// The `RoomSubscription` has been sent and received correctly by the + /// server. + Applied, +} + /// The set of sticky parameters owned by the `SlidingSyncInner` instance, and /// sent in the request. #[derive(Debug)]