Merge branch 'master' of https://github.com/matrix-org/matrix-rust-sdk into store-room

master
Devin R 2020-05-11 14:17:31 -04:00
commit 22c4a1f2e7
8 changed files with 22 additions and 22 deletions

View File

@ -46,7 +46,7 @@ use crate::identifiers::DeviceId;
use crate::api; use crate::api;
use crate::VERSION; use crate::VERSION;
use crate::{Error, EventEmitter, Result}; 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::Room;
use matrix_sdk_base::Session; use matrix_sdk_base::Session;
use matrix_sdk_base::StateStore; use matrix_sdk_base::StateStore;

View File

@ -88,7 +88,7 @@ pub enum RoomState {
/// This Client is a state machine that receives responses and events and /// This Client is a state machine that receives responses and events and
/// accordingly updates it's state. /// accordingly updates it's state.
#[derive(Clone)] #[derive(Clone)]
pub struct Client { pub struct BaseClient {
/// The current client session containing our user id, device id and access /// The current client session containing our user id, device id and access
/// token. /// token.
session: Arc<RwLock<Option<Session>>>, session: Arc<RwLock<Option<Session>>>,
@ -119,7 +119,7 @@ pub struct Client {
olm: Arc<Mutex<Option<OlmMachine>>>, olm: Arc<Mutex<Option<OlmMachine>>>,
} }
impl fmt::Debug for Client { impl fmt::Debug for BaseClient {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
f.debug_struct("Client") f.debug_struct("Client")
.field("session", &self.session) .field("session", &self.session)
@ -132,7 +132,7 @@ impl fmt::Debug for Client {
} }
} }
impl Client { impl BaseClient {
/// Create a new client. /// Create a new client.
/// ///
/// # Arguments /// # Arguments
@ -140,7 +140,7 @@ impl Client {
/// * `session` - An optional session if the user already has one from a /// * `session` - An optional session if the user already has one from a
/// previous login call. /// previous login call.
pub fn new(session: Option<Session>) -> Result<Self> { pub fn new(session: Option<Session>) -> Result<Self> {
Client::new_helper(session, None) BaseClient::new_helper(session, None)
} }
/// Create a new client. /// Create a new client.
@ -156,7 +156,7 @@ impl Client {
session: Option<Session>, session: Option<Session>,
store: Box<dyn StateStore>, store: Box<dyn StateStore>,
) -> Result<Self> { ) -> 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> { fn new_helper(session: Option<Session>, store: Option<Box<dyn StateStore>>) -> Result<Self> {
@ -166,7 +166,7 @@ impl Client {
None => None, None => None,
}; };
Ok(Client { Ok(BaseClient {
session: Arc::new(RwLock::new(session)), session: Arc::new(RwLock::new(session)),
sync_token: Arc::new(RwLock::new(None)), sync_token: Arc::new(RwLock::new(None)),
joined_rooms: Arc::new(RwLock::new(HashMap::new())), joined_rooms: Arc::new(RwLock::new(HashMap::new())),

View File

@ -285,7 +285,7 @@ mod test {
use crate::api::r0::sync::sync_events::Response as SyncResponse; use crate::api::r0::sync::sync_events::Response as SyncResponse;
use crate::identifiers::UserId; use crate::identifiers::UserId;
use crate::{Client, Session}; use crate::{BaseClient, Session};
use http::Response; use http::Response;
use std::convert::TryFrom; use std::convert::TryFrom;
@ -300,13 +300,13 @@ mod test {
SyncResponse::try_from(response).unwrap() SyncResponse::try_from(response).unwrap()
} }
fn get_client() -> Client { fn get_client() -> BaseClient {
let session = Session { let session = Session {
access_token: "1234".to_owned(), access_token: "1234".to_owned(),
user_id: UserId::try_from("@example:example.com").unwrap(), user_id: UserId::try_from("@example:example.com").unwrap(),
device_id: "DEVICEID".to_owned(), device_id: "DEVICEID".to_owned(),
}; };
Client::new(Some(session)).unwrap() BaseClient::new(Some(session)).unwrap()
} }
#[tokio::test] #[tokio::test]

View File

@ -36,7 +36,7 @@ mod models;
mod session; mod session;
mod state; mod state;
pub use client::{Client, RoomState, RoomStateType}; pub use client::{BaseClient, RoomState, RoomStateType};
pub use event_emitter::EventEmitter; pub use event_emitter::EventEmitter;
#[cfg(feature = "encryption")] #[cfg(feature = "encryption")]
pub use matrix_sdk_crypto::{Device, TrustState}; pub use matrix_sdk_crypto::{Device, TrustState};

View File

@ -524,7 +524,7 @@ mod test {
use crate::api::r0::sync::sync_events::Response as SyncResponse; use crate::api::r0::sync::sync_events::Response as SyncResponse;
use crate::events::room::member::MembershipState; use crate::events::room::member::MembershipState;
use crate::identifiers::UserId; use crate::identifiers::UserId;
use crate::{Client, Session}; use crate::{BaseClient, Session};
use matrix_sdk_test::EventBuilder; use matrix_sdk_test::EventBuilder;
use http::Response; use http::Response;
@ -542,13 +542,13 @@ mod test {
SyncResponse::try_from(response).unwrap() SyncResponse::try_from(response).unwrap()
} }
fn get_client() -> Client { fn get_client() -> BaseClient {
let session = Session { let session = Session {
access_token: "1234".to_owned(), access_token: "1234".to_owned(),
user_id: UserId::try_from("@example:localhost").unwrap(), user_id: UserId::try_from("@example:localhost").unwrap(),
device_id: "DEVICEID".to_owned(), device_id: "DEVICEID".to_owned(),
}; };
Client::new(Some(session)).unwrap() BaseClient::new(Some(session)).unwrap()
} }
fn get_room_id() -> RoomId { fn get_room_id() -> RoomId {
@ -677,7 +677,7 @@ mod test {
user_id: UserId::try_from("@example:localhost").unwrap(), user_id: UserId::try_from("@example:localhost").unwrap(),
device_id: "DEVICEID".to_owned(), 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(); client.receive_sync_response(&mut response).await.unwrap();
let mut room_names = vec![]; let mut room_names = vec![];

View File

@ -204,19 +204,19 @@ mod test {
use crate::events::collections::all::RoomEvent; use crate::events::collections::all::RoomEvent;
use crate::events::room::member::MembershipState; use crate::events::room::member::MembershipState;
use crate::identifiers::{RoomId, UserId}; use crate::identifiers::{RoomId, UserId};
use crate::{Client, Session}; use crate::{BaseClient, Session};
use crate::js_int::Int; use crate::js_int::Int;
use std::convert::TryFrom; use std::convert::TryFrom;
fn get_client() -> Client { fn get_client() -> BaseClient {
let session = Session { let session = Session {
access_token: "1234".to_owned(), access_token: "1234".to_owned(),
user_id: UserId::try_from("@example:localhost").unwrap(), user_id: UserId::try_from("@example:localhost").unwrap(),
device_id: "DEVICEID".to_owned(), device_id: "DEVICEID".to_owned(),
}; };
Client::new(Some(session)).unwrap() BaseClient::new(Some(session)).unwrap()
} }
fn get_room_id() -> RoomId { fn get_room_id() -> RoomId {

View File

@ -19,7 +19,7 @@ use std::collections::HashMap;
pub mod state_store; pub mod state_store;
pub use state_store::JsonStore; 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::events::push_rules::Ruleset;
use crate::identifiers::{RoomId, UserId}; use crate::identifiers::{RoomId, UserId};
use crate::{Result, Room, Session}; use crate::{Result, Room, Session};

View File

@ -145,7 +145,7 @@ mod test {
use crate::api::r0::sync::sync_events::Response as SyncResponse; use crate::api::r0::sync::sync_events::Response as SyncResponse;
use crate::identifiers::{RoomId, UserId}; use crate::identifiers::{RoomId, UserId};
use crate::{Client, Session}; use crate::{BaseClient, Session};
fn sync_response(file: &str) -> SyncResponse { fn sync_response(file: &str) -> SyncResponse {
let mut file = File::open(file).unwrap(); let mut file = File::open(file).unwrap();
@ -229,7 +229,7 @@ mod test {
// a sync response to populate our JSON store // a sync response to populate our JSON store
let store = Box::new(JsonStore::open(path).unwrap()); 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"); 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 // now syncing the client will update from the state store
let store = Box::new(JsonStore::open(path).unwrap()); 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(); client.sync_with_state_store().await.unwrap();
// assert the synced client and the logged in client are equal // assert the synced client and the logged in client are equal