Merge branch 'master' of https://github.com/matrix-org/matrix-rust-sdk into store-room
commit
22c4a1f2e7
|
@ -46,7 +46,7 @@ use crate::identifiers::DeviceId;
|
|||
use crate::api;
|
||||
use crate::VERSION;
|
||||
use crate::{Error, EventEmitter, Result};
|
||||
use matrix_sdk_base::Client as BaseClient;
|
||||
use matrix_sdk_base::BaseClient;
|
||||
use matrix_sdk_base::Room;
|
||||
use matrix_sdk_base::Session;
|
||||
use matrix_sdk_base::StateStore;
|
||||
|
|
|
@ -88,7 +88,7 @@ pub enum RoomState {
|
|||
/// This Client is a state machine that receives responses and events and
|
||||
/// accordingly updates it's state.
|
||||
#[derive(Clone)]
|
||||
pub struct Client {
|
||||
pub struct BaseClient {
|
||||
/// The current client session containing our user id, device id and access
|
||||
/// token.
|
||||
session: Arc<RwLock<Option<Session>>>,
|
||||
|
@ -119,7 +119,7 @@ pub struct Client {
|
|||
olm: Arc<Mutex<Option<OlmMachine>>>,
|
||||
}
|
||||
|
||||
impl fmt::Debug for Client {
|
||||
impl fmt::Debug for BaseClient {
|
||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
f.debug_struct("Client")
|
||||
.field("session", &self.session)
|
||||
|
@ -132,7 +132,7 @@ impl fmt::Debug for Client {
|
|||
}
|
||||
}
|
||||
|
||||
impl Client {
|
||||
impl BaseClient {
|
||||
/// Create a new client.
|
||||
///
|
||||
/// # Arguments
|
||||
|
@ -140,7 +140,7 @@ impl Client {
|
|||
/// * `session` - An optional session if the user already has one from a
|
||||
/// previous login call.
|
||||
pub fn new(session: Option<Session>) -> Result<Self> {
|
||||
Client::new_helper(session, None)
|
||||
BaseClient::new_helper(session, None)
|
||||
}
|
||||
|
||||
/// Create a new client.
|
||||
|
@ -156,7 +156,7 @@ impl Client {
|
|||
session: Option<Session>,
|
||||
store: Box<dyn StateStore>,
|
||||
) -> Result<Self> {
|
||||
Client::new_helper(session, Some(store))
|
||||
BaseClient::new_helper(session, Some(store))
|
||||
}
|
||||
|
||||
fn new_helper(session: Option<Session>, store: Option<Box<dyn StateStore>>) -> Result<Self> {
|
||||
|
@ -166,7 +166,7 @@ impl Client {
|
|||
None => None,
|
||||
};
|
||||
|
||||
Ok(Client {
|
||||
Ok(BaseClient {
|
||||
session: Arc::new(RwLock::new(session)),
|
||||
sync_token: Arc::new(RwLock::new(None)),
|
||||
joined_rooms: Arc::new(RwLock::new(HashMap::new())),
|
||||
|
|
|
@ -285,7 +285,7 @@ mod test {
|
|||
|
||||
use crate::api::r0::sync::sync_events::Response as SyncResponse;
|
||||
use crate::identifiers::UserId;
|
||||
use crate::{Client, Session};
|
||||
use crate::{BaseClient, Session};
|
||||
|
||||
use http::Response;
|
||||
use std::convert::TryFrom;
|
||||
|
@ -300,13 +300,13 @@ mod test {
|
|||
SyncResponse::try_from(response).unwrap()
|
||||
}
|
||||
|
||||
fn get_client() -> Client {
|
||||
fn get_client() -> BaseClient {
|
||||
let session = Session {
|
||||
access_token: "1234".to_owned(),
|
||||
user_id: UserId::try_from("@example:example.com").unwrap(),
|
||||
device_id: "DEVICEID".to_owned(),
|
||||
};
|
||||
Client::new(Some(session)).unwrap()
|
||||
BaseClient::new(Some(session)).unwrap()
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
|
|
|
@ -36,7 +36,7 @@ mod models;
|
|||
mod session;
|
||||
mod state;
|
||||
|
||||
pub use client::{Client, RoomState, RoomStateType};
|
||||
pub use client::{BaseClient, RoomState, RoomStateType};
|
||||
pub use event_emitter::EventEmitter;
|
||||
#[cfg(feature = "encryption")]
|
||||
pub use matrix_sdk_crypto::{Device, TrustState};
|
||||
|
|
|
@ -524,7 +524,7 @@ mod test {
|
|||
use crate::api::r0::sync::sync_events::Response as SyncResponse;
|
||||
use crate::events::room::member::MembershipState;
|
||||
use crate::identifiers::UserId;
|
||||
use crate::{Client, Session};
|
||||
use crate::{BaseClient, Session};
|
||||
use matrix_sdk_test::EventBuilder;
|
||||
|
||||
use http::Response;
|
||||
|
@ -542,13 +542,13 @@ mod test {
|
|||
SyncResponse::try_from(response).unwrap()
|
||||
}
|
||||
|
||||
fn get_client() -> Client {
|
||||
fn get_client() -> BaseClient {
|
||||
let session = Session {
|
||||
access_token: "1234".to_owned(),
|
||||
user_id: UserId::try_from("@example:localhost").unwrap(),
|
||||
device_id: "DEVICEID".to_owned(),
|
||||
};
|
||||
Client::new(Some(session)).unwrap()
|
||||
BaseClient::new(Some(session)).unwrap()
|
||||
}
|
||||
|
||||
fn get_room_id() -> RoomId {
|
||||
|
@ -677,7 +677,7 @@ mod test {
|
|||
user_id: UserId::try_from("@example:localhost").unwrap(),
|
||||
device_id: "DEVICEID".to_owned(),
|
||||
};
|
||||
let client = Client::new(Some(session)).unwrap();
|
||||
let client = BaseClient::new(Some(session)).unwrap();
|
||||
client.receive_sync_response(&mut response).await.unwrap();
|
||||
|
||||
let mut room_names = vec![];
|
||||
|
|
|
@ -204,19 +204,19 @@ mod test {
|
|||
use crate::events::collections::all::RoomEvent;
|
||||
use crate::events::room::member::MembershipState;
|
||||
use crate::identifiers::{RoomId, UserId};
|
||||
use crate::{Client, Session};
|
||||
use crate::{BaseClient, Session};
|
||||
|
||||
use crate::js_int::Int;
|
||||
|
||||
use std::convert::TryFrom;
|
||||
|
||||
fn get_client() -> Client {
|
||||
fn get_client() -> BaseClient {
|
||||
let session = Session {
|
||||
access_token: "1234".to_owned(),
|
||||
user_id: UserId::try_from("@example:localhost").unwrap(),
|
||||
device_id: "DEVICEID".to_owned(),
|
||||
};
|
||||
Client::new(Some(session)).unwrap()
|
||||
BaseClient::new(Some(session)).unwrap()
|
||||
}
|
||||
|
||||
fn get_room_id() -> RoomId {
|
||||
|
|
|
@ -19,7 +19,7 @@ use std::collections::HashMap;
|
|||
pub mod state_store;
|
||||
pub use state_store::JsonStore;
|
||||
|
||||
use crate::client::{Client as BaseClient, Token};
|
||||
use crate::client::{BaseClient, Token};
|
||||
use crate::events::push_rules::Ruleset;
|
||||
use crate::identifiers::{RoomId, UserId};
|
||||
use crate::{Result, Room, Session};
|
||||
|
|
|
@ -145,7 +145,7 @@ mod test {
|
|||
|
||||
use crate::api::r0::sync::sync_events::Response as SyncResponse;
|
||||
use crate::identifiers::{RoomId, UserId};
|
||||
use crate::{Client, Session};
|
||||
use crate::{BaseClient, Session};
|
||||
|
||||
fn sync_response(file: &str) -> SyncResponse {
|
||||
let mut file = File::open(file).unwrap();
|
||||
|
@ -229,7 +229,7 @@ mod test {
|
|||
|
||||
// a sync response to populate our JSON store
|
||||
let store = Box::new(JsonStore::open(path).unwrap());
|
||||
let client = Client::new_with_state_store(Some(session.clone()), store).unwrap();
|
||||
let client = BaseClient::new_with_state_store(Some(session.clone()), store).unwrap();
|
||||
|
||||
let mut response = sync_response("../test_data/sync.json");
|
||||
|
||||
|
@ -238,7 +238,7 @@ mod test {
|
|||
|
||||
// now syncing the client will update from the state store
|
||||
let store = Box::new(JsonStore::open(path).unwrap());
|
||||
let client = Client::new_with_state_store(Some(session.clone()), store).unwrap();
|
||||
let client = BaseClient::new_with_state_store(Some(session.clone()), store).unwrap();
|
||||
client.sync_with_state_store().await.unwrap();
|
||||
|
||||
// assert the synced client and the logged in client are equal
|
||||
|
|
Loading…
Reference in New Issue