From e9b48b73d454701e35f90ea3b7ef1fef523b2337 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Damir=20Jeli=C4=87?= Date: Wed, 13 May 2020 10:50:58 +0200 Subject: [PATCH] base: Move the AllRooms out of the state_store file. --- matrix_sdk_base/src/state/mod.rs | 19 ++++++++++++++++--- matrix_sdk_base/src/state/state_store.rs | 15 +-------------- 2 files changed, 17 insertions(+), 17 deletions(-) diff --git a/matrix_sdk_base/src/state/mod.rs b/matrix_sdk_base/src/state/mod.rs index c7909bf5..d2e88d12 100644 --- a/matrix_sdk_base/src/state/mod.rs +++ b/matrix_sdk_base/src/state/mod.rs @@ -13,17 +13,18 @@ // See the License for the specific language governing permissions and // limitations under the License. +use std::collections::HashMap; + use serde::{Deserialize, Serialize}; #[cfg(not(target_arch = "wasm32"))] -pub mod state_store; -pub use state_store::AllRooms; +mod state_store; #[cfg(not(target_arch = "wasm32"))] pub use state_store::JsonStore; use crate::client::{BaseClient, Token}; use crate::events::push_rules::Ruleset; -use crate::identifiers::UserId; +use crate::identifiers::{RoomId, UserId}; use crate::{Result, Room, RoomState, Session}; /// `ClientState` holds all the information to restore a `BaseClient` @@ -64,6 +65,18 @@ impl ClientState { } } +/// `JsonStore::load_all_rooms` returns `AllRooms`. +/// +/// `AllRooms` is made of the `joined`, `invited` and `left` room maps. +pub struct AllRooms { + /// The joined room mapping of `RoomId` to `Room`. + pub joined: HashMap, + /// The invited room mapping of `RoomId` to `Room`. + pub invited: HashMap, + /// The left room mapping of `RoomId` to `Room`. + pub left: HashMap, +} + /// Abstraction around the data store to avoid unnecessary request on client initialization. #[async_trait::async_trait] pub trait StateStore: Send + Sync { diff --git a/matrix_sdk_base/src/state/state_store.rs b/matrix_sdk_base/src/state/state_store.rs index 5645d075..4d519617 100644 --- a/matrix_sdk_base/src/state/state_store.rs +++ b/matrix_sdk_base/src/state/state_store.rs @@ -10,22 +10,9 @@ use matrix_sdk_common::locks::RwLock; use tokio::fs as async_fs; use tokio::io::AsyncWriteExt; -use super::{ClientState, StateStore}; -use crate::identifiers::RoomId; +use super::{AllRooms, ClientState, StateStore}; use crate::{Error, Result, Room, RoomState, Session}; -/// `JsonStore::load_all_rooms` returns `AllRooms`. -/// -/// `AllRooms` is made of the `joined`, `invited` and `left` room maps. -pub struct AllRooms { - /// The joined room mapping of `RoomId` to `Room`. - pub joined: HashMap, - /// The invited room mapping of `RoomId` to `Room`. - pub invited: HashMap, - /// The left room mapping of `RoomId` to `Room`. - pub left: HashMap, -} - /// A default `StateStore` implementation that serializes state as json /// and saves it to disk. ///