base: Move the AllRooms out of the state_store file.

master
Damir Jelić 2020-05-13 10:50:58 +02:00
parent f1d12ff1f3
commit e9b48b73d4
2 changed files with 17 additions and 17 deletions

View File

@ -13,17 +13,18 @@
// See the License for the specific language governing permissions and // See the License for the specific language governing permissions and
// limitations under the License. // limitations under the License.
use std::collections::HashMap;
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
#[cfg(not(target_arch = "wasm32"))] #[cfg(not(target_arch = "wasm32"))]
pub mod state_store; mod state_store;
pub use state_store::AllRooms;
#[cfg(not(target_arch = "wasm32"))] #[cfg(not(target_arch = "wasm32"))]
pub use state_store::JsonStore; pub use state_store::JsonStore;
use crate::client::{BaseClient, Token}; use crate::client::{BaseClient, Token};
use crate::events::push_rules::Ruleset; use crate::events::push_rules::Ruleset;
use crate::identifiers::UserId; use crate::identifiers::{RoomId, UserId};
use crate::{Result, Room, RoomState, Session}; use crate::{Result, Room, RoomState, Session};
/// `ClientState` holds all the information to restore a `BaseClient` /// `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<RoomId, Room>,
/// The invited room mapping of `RoomId` to `Room`.
pub invited: HashMap<RoomId, Room>,
/// The left room mapping of `RoomId` to `Room`.
pub left: HashMap<RoomId, Room>,
}
/// Abstraction around the data store to avoid unnecessary request on client initialization. /// Abstraction around the data store to avoid unnecessary request on client initialization.
#[async_trait::async_trait] #[async_trait::async_trait]
pub trait StateStore: Send + Sync { pub trait StateStore: Send + Sync {

View File

@ -10,22 +10,9 @@ use matrix_sdk_common::locks::RwLock;
use tokio::fs as async_fs; use tokio::fs as async_fs;
use tokio::io::AsyncWriteExt; use tokio::io::AsyncWriteExt;
use super::{ClientState, StateStore}; use super::{AllRooms, ClientState, StateStore};
use crate::identifiers::RoomId;
use crate::{Error, Result, Room, RoomState, Session}; 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<RoomId, Room>,
/// The invited room mapping of `RoomId` to `Room`.
pub invited: HashMap<RoomId, Room>,
/// The left room mapping of `RoomId` to `Room`.
pub left: HashMap<RoomId, Room>,
}
/// A default `StateStore` implementation that serializes state as json /// A default `StateStore` implementation that serializes state as json
/// and saves it to disk. /// and saves it to disk.
/// ///