diff --git a/matrix_sdk_base/Cargo.toml b/matrix_sdk_base/Cargo.toml index 1c25de53..2adcac7a 100644 --- a/matrix_sdk_base/Cargo.toml +++ b/matrix_sdk_base/Cargo.toml @@ -19,13 +19,14 @@ default = [] encryption = ["matrix-sdk-crypto"] sled_state_store = ["sled", "pbkdf2", "hmac", "sha2", "rand", "chacha20poly1305"] sled_cryptostore = ["matrix-sdk-crypto/sled_cryptostore"] -markdown = ["matrix-sdk-common/markdown"] +markdown = ["ruma/markdown"] docs = ["encryption", "sled_cryptostore"] [dependencies] dashmap = "4.0.2" lru = "0.6.5" +ruma = { version = "0.1.2", features = ["client-api-c", "unstable-pre-spec"] } serde = { version = "1.0.122", features = ["rc"] } serde_json = "1.0.61" tracing = "0.1.22" diff --git a/matrix_sdk_base/examples/state_inspector.rs b/matrix_sdk_base/examples/state_inspector.rs index d9d448a9..5944104c 100644 --- a/matrix_sdk_base/examples/state_inspector.rs +++ b/matrix_sdk_base/examples/state_inspector.rs @@ -5,10 +5,10 @@ use atty::Stream; #[cfg(not(target_arch = "wasm32"))] use clap::{App as Argparse, AppSettings as ArgParseSettings, Arg, ArgMatches, SubCommand}; use futures::executor::block_on; -use matrix_sdk_base::{ +use matrix_sdk_base::{RoomInfo, Store}; +use ruma::{ events::EventType, identifiers::{RoomId, UserId}, - RoomInfo, Store, }; #[cfg(not(target_arch = "wasm32"))] use rustyline::{ diff --git a/matrix_sdk_base/src/client.rs b/matrix_sdk_base/src/client.rs index 55cee12d..78853077 100644 --- a/matrix_sdk_base/src/client.rs +++ b/matrix_sdk_base/src/client.rs @@ -22,40 +22,42 @@ use std::{ sync::Arc, }; -#[cfg(feature = "encryption")] use matrix_sdk_common::{ - api::r0::keys::claim_keys::Request as KeysClaimRequest, - events::{ - room::{encrypted::EncryptedEventContent, history_visibility::HistoryVisibility}, - AnyMessageEventContent, AnySyncMessageEvent, - }, - identifiers::DeviceId, - locks::Mutex, - uuid::Uuid, -}; -use matrix_sdk_common::{ - api::r0::{self as api, push::get_notifications::Notification}, deserialized_responses::{ AmbiguityChanges, JoinedRoom, LeftRoom, MemberEvent, MembersResponse, Rooms, StrippedMemberEvent, SyncResponse, SyncRoomEvent, Timeline, }, + instant::Instant, + locks::RwLock, +}; +#[cfg(feature = "encryption")] +use matrix_sdk_common::{locks::Mutex, uuid::Uuid}; +#[cfg(feature = "encryption")] +use matrix_sdk_crypto::{ + store::{CryptoStore, CryptoStoreError}, + Device, EncryptionSettings, IncomingResponse, MegolmError, OlmError, OlmMachine, + OutgoingRequest, Sas, ToDeviceRequest, UserDevices, +}; +#[cfg(feature = "encryption")] +use ruma::{ + api::client::r0::keys::claim_keys::Request as KeysClaimRequest, + events::{ + room::{encrypted::EncryptedEventContent, history_visibility::HistoryVisibility}, + AnyMessageEventContent, AnySyncMessageEvent, + }, + DeviceId, +}; +use ruma::{ + api::client::r0::{self as api, push::get_notifications::Notification}, events::{ room::member::{MemberEventContent, MembershipState}, AnyGlobalAccountDataEvent, AnyRoomAccountDataEvent, AnyStrippedStateEvent, AnySyncEphemeralRoomEvent, AnySyncRoomEvent, AnySyncStateEvent, EventContent, EventType, StateEvent, }, - identifiers::{RoomId, UserId}, - instant::Instant, - locks::RwLock, push::{Action, PushConditionRoomCtx, Ruleset}, - MilliSecondsSinceUnixEpoch, Raw, UInt, -}; -#[cfg(feature = "encryption")] -use matrix_sdk_crypto::{ - store::{CryptoStore, CryptoStoreError}, - Device, EncryptionSettings, IncomingResponse, MegolmError, OlmError, OlmMachine, - OutgoingRequest, Sas, ToDeviceRequest, UserDevices, + serde::Raw, + MilliSecondsSinceUnixEpoch, RoomId, UInt, UserId, }; use tracing::{info, warn}; use zeroize::Zeroizing; @@ -1233,7 +1235,7 @@ impl BaseClient { /// ``` /// # use std::convert::TryFrom; /// # use matrix_sdk_base::BaseClient; - /// # use matrix_sdk_common::identifiers::UserId; + /// # use ruma::UserId; /// # use futures::executor::block_on; /// # let alice = UserId::try_from("@alice:example.org").unwrap(); /// # let client = BaseClient::new().unwrap(); @@ -1290,7 +1292,7 @@ impl BaseClient { /// ```no_run /// # use std::convert::TryFrom; /// # use matrix_sdk_base::BaseClient; - /// # use matrix_sdk_common::identifiers::UserId; + /// # use ruma::UserId; /// # use futures::executor::block_on; /// # let alice = UserId::try_from("@alice:example.org").unwrap(); /// # let client = BaseClient::new().unwrap(); diff --git a/matrix_sdk_base/src/media.rs b/matrix_sdk_base/src/media.rs index 9d075e63..9f06e40e 100644 --- a/matrix_sdk_base/src/media.rs +++ b/matrix_sdk_base/src/media.rs @@ -1,7 +1,7 @@ //! Common types for [media content](https://matrix.org/docs/spec/client_server/r0.6.1#id66). -use matrix_sdk_common::{ - api::r0::media::get_content_thumbnail::Method, +use ruma::{ + api::client::r0::media::get_content_thumbnail::Method, events::{ room::{ message::{ @@ -12,8 +12,7 @@ use matrix_sdk_common::{ }, sticker::StickerEventContent, }, - identifiers::MxcUri, - UInt, + MxcUri, UInt, }; const UNIQUE_SEPARATOR: &str = "_"; diff --git a/matrix_sdk_base/src/rooms/members.rs b/matrix_sdk_base/src/rooms/members.rs index ee35ebbc..4717a9ec 100644 --- a/matrix_sdk_base/src/rooms/members.rs +++ b/matrix_sdk_base/src/rooms/members.rs @@ -14,13 +14,13 @@ use std::sync::Arc; -use matrix_sdk_common::{ +use ruma::{ events::{ presence::PresenceEvent, room::{member::MemberEventContent, power_levels::PowerLevelsEventContent}, SyncStateEvent, }, - identifiers::{MxcUri, UserId}, + MxcUri, UserId, }; use crate::deserialized_responses::MemberEvent; diff --git a/matrix_sdk_base/src/rooms/mod.rs b/matrix_sdk_base/src/rooms/mod.rs index 6dc9ba77..8b417e04 100644 --- a/matrix_sdk_base/src/rooms/mod.rs +++ b/matrix_sdk_base/src/rooms/mod.rs @@ -3,7 +3,9 @@ mod normal; use std::cmp::max; -use matrix_sdk_common::{ +pub use members::RoomMember; +pub use normal::{Room, RoomInfo, RoomType}; +use ruma::{ events::{ room::{ create::CreateEventContent, encryption::EncryptionEventContent, @@ -12,10 +14,8 @@ use matrix_sdk_common::{ }, AnyStateEventContent, }, - identifiers::{MxcUri, RoomAliasId, UserId}, + MxcUri, RoomAliasId, UserId, }; -pub use members::RoomMember; -pub use normal::{Room, RoomInfo, RoomType}; use serde::{Deserialize, Serialize}; /// A base room info struct that is the backbone of normal as well as stripped diff --git a/matrix_sdk_base/src/rooms/normal.rs b/matrix_sdk_base/src/rooms/normal.rs index e0f415de..731dfd22 100644 --- a/matrix_sdk_base/src/rooms/normal.rs +++ b/matrix_sdk_base/src/rooms/normal.rs @@ -21,8 +21,8 @@ use futures::{ future, stream::{self, StreamExt}, }; -use matrix_sdk_common::{ - api::r0::sync::sync_events::RoomSummary as RumaSummary, +use ruma::{ + api::client::r0::sync::sync_events::RoomSummary as RumaSummary, events::{ receipt::Receipt, room::{ @@ -33,8 +33,8 @@ use matrix_sdk_common::{ tag::Tags, AnyRoomAccountDataEvent, AnyStateEventContent, AnySyncStateEvent, EventType, }, - identifiers::{EventId, MxcUri, RoomAliasId, RoomId, UserId}, receipt::ReceiptType, + EventId, MxcUri, RoomAliasId, RoomId, UserId, }; use serde::{Deserialize, Serialize}; use tracing::info; diff --git a/matrix_sdk_base/src/session.rs b/matrix_sdk_base/src/session.rs index 33573637..0bdcb454 100644 --- a/matrix_sdk_base/src/session.rs +++ b/matrix_sdk_base/src/session.rs @@ -15,7 +15,7 @@ //! User sessions. -use matrix_sdk_common::identifiers::{DeviceId, UserId}; +use ruma::{DeviceId, UserId}; use serde::{Deserialize, Serialize}; /// A user session, containing an access token and information about the diff --git a/matrix_sdk_base/src/store/ambiguity_map.rs b/matrix_sdk_base/src/store/ambiguity_map.rs index 6d14c664..79463aff 100644 --- a/matrix_sdk_base/src/store/ambiguity_map.rs +++ b/matrix_sdk_base/src/store/ambiguity_map.rs @@ -14,11 +14,8 @@ use std::collections::{BTreeMap, BTreeSet}; -use matrix_sdk_common::{ - deserialized_responses::{AmbiguityChange, MemberEvent}, - events::room::member::MembershipState, - identifiers::{EventId, RoomId, UserId}, -}; +use matrix_sdk_common::deserialized_responses::{AmbiguityChange, MemberEvent}; +use ruma::{events::room::member::MembershipState, EventId, RoomId, UserId}; use tracing::trace; use super::{Result, StateChanges}; diff --git a/matrix_sdk_base/src/store/memory_store.rs b/matrix_sdk_base/src/store/memory_store.rs index 7d15254a..8bf11358 100644 --- a/matrix_sdk_base/src/store/memory_store.rs +++ b/matrix_sdk_base/src/store/memory_store.rs @@ -19,8 +19,8 @@ use std::{ use dashmap::{DashMap, DashSet}; use lru::LruCache; -use matrix_sdk_common::{ - async_trait, +use matrix_sdk_common::{async_trait, instant::Instant, locks::Mutex}; +use ruma::{ events::{ presence::PresenceEvent, receipt::Receipt, @@ -29,10 +29,8 @@ use matrix_sdk_common::{ AnySyncStateEvent, EventType, }, identifiers::{EventId, MxcUri, RoomId, UserId}, - instant::Instant, - locks::Mutex, receipt::ReceiptType, - Raw, + serde::Raw, }; use tracing::info; @@ -563,7 +561,7 @@ impl StateStore for MemoryStore { #[cfg(not(feature = "sled_state_store"))] mod test { use matrix_sdk_common::{ - api::r0::media::get_content_thumbnail::Method, + api::client::r0::media::get_content_thumbnail::Method, identifiers::{event_id, mxc_uri, room_id, user_id, UserId}, receipt::ReceiptType, uint, diff --git a/matrix_sdk_base/src/store/mod.rs b/matrix_sdk_base/src/store/mod.rs index 45b38ca0..05fadc3f 100644 --- a/matrix_sdk_base/src/store/mod.rs +++ b/matrix_sdk_base/src/store/mod.rs @@ -21,9 +21,9 @@ use std::{ }; use dashmap::DashMap; -use matrix_sdk_common::{ - api::r0::push::get_notifications::Notification, - async_trait, +use matrix_sdk_common::{async_trait, locks::RwLock, AsyncTraitDeps}; +use ruma::{ + api::client::r0::push::get_notifications::Notification, events::{ presence::PresenceEvent, receipt::{Receipt, ReceiptEventContent}, @@ -31,10 +31,9 @@ use matrix_sdk_common::{ AnyGlobalAccountDataEvent, AnyRoomAccountDataEvent, AnyStrippedStateEvent, AnySyncStateEvent, EventContent, EventType, }, - identifiers::{EventId, MxcUri, RoomId, UserId}, - locks::RwLock, receipt::ReceiptType, - AsyncTraitDeps, Raw, + serde::Raw, + EventId, MxcUri, RoomId, UserId, }; #[cfg(feature = "sled_state_store")] use sled::Db; @@ -69,7 +68,7 @@ pub enum StoreError { /// An error happened while deserializing a Matrix identifier, e.g. an user /// id. #[error(transparent)] - Identifier(#[from] matrix_sdk_common::identifiers::Error), + Identifier(#[from] ruma::identifiers::Error), /// The store is locked with a passphrase and an incorrect passphrase was /// given. #[error("The store failed to be unlocked")] diff --git a/matrix_sdk_base/src/store/sled_store/mod.rs b/matrix_sdk_base/src/store/sled_store/mod.rs index 37343c0d..4f3ba8f2 100644 --- a/matrix_sdk_base/src/store/sled_store/mod.rs +++ b/matrix_sdk_base/src/store/sled_store/mod.rs @@ -26,17 +26,17 @@ use futures::{ stream::{self, Stream}, TryStreamExt, }; -use matrix_sdk_common::{ - async_trait, +use matrix_sdk_common::async_trait; +use ruma::{ events::{ presence::PresenceEvent, receipt::Receipt, room::member::{MemberEventContent, MembershipState}, AnyGlobalAccountDataEvent, AnyRoomAccountDataEvent, AnySyncStateEvent, EventType, }, - identifiers::{EventId, MxcUri, RoomId, UserId}, receipt::ReceiptType, - Raw, + serde::Raw, + EventId, MxcUri, RoomId, UserId, }; use serde::{Deserialize, Serialize}; use sled::{ @@ -899,8 +899,9 @@ impl StateStore for SledStore { mod test { use std::convert::TryFrom; - use matrix_sdk_common::{ - api::r0::media::get_content_thumbnail::Method, + use matrix_sdk_test::async_test; + use ruma::{ + api::client::r0::media::get_content_thumbnail::Method, events::{ room::{ member::{MemberEventContent, MembershipState}, @@ -910,9 +911,9 @@ mod test { }, identifiers::{event_id, mxc_uri, room_id, user_id, EventId, UserId}, receipt::ReceiptType, - uint, MilliSecondsSinceUnixEpoch, Raw, + serde::Raw, + uint, MilliSecondsSinceUnixEpoch, }; - use matrix_sdk_test::async_test; use serde_json::json; use super::{SledStore, StateChanges};