diff --git a/Cargo.toml b/Cargo.toml index fc993d0a..57e18193 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -6,5 +6,4 @@ members = [ "matrix_sdk_test_macros", "matrix_sdk_crypto", "matrix_sdk_common", - "matrix_sdk_common_macros", ] diff --git a/matrix_sdk/Cargo.toml b/matrix_sdk/Cargo.toml index 119a99f0..62ed6540 100644 --- a/matrix_sdk/Cargo.toml +++ b/matrix_sdk/Cargo.toml @@ -28,18 +28,16 @@ socks = ["reqwest/socks"] docs = ["encryption", "sqlite_cryptostore", "messages"] [dependencies] -async-trait = "0.1.41" -dashmap = { version = "3.11.10", optional = true } -futures = "0.3.6" -http = "0.2.1" -serde_json = "1.0.59" -thiserror = "1.0.21" -tracing = "0.1.21" -url = "2.1.1" -zeroize = "1.1.1" +dashmap = { version = "4.0.1", optional = true } +futures = "0.3.8" +http = "0.2.2" +serde_json = "1.0.61" +thiserror = "1.0.23" +tracing = "0.1.22" +url = "2.2.0" +zeroize = "1.2.0" mime = "0.3.16" -matrix-sdk-common-macros = { version = "0.1.0", path = "../matrix_sdk_common_macros" } matrix-sdk-common = { version = "0.1.0", path = "../matrix_sdk_common" } [dependencies.matrix-sdk-base] @@ -48,7 +46,7 @@ path = "../matrix_sdk_base" default_features = false [dependencies.reqwest] -version = "0.10.8" +version = "0.10.10" default_features = false [dependencies.tracing-futures] @@ -60,7 +58,7 @@ features = ["std", "std-future"] futures-timer = "3.0.2" [target.'cfg(not(target_arch = "wasm32"))'.dependencies.tokio] -version = "0.2.22" +version = "0.2.24" default-features = false features = ["fs", "blocking"] @@ -69,15 +67,14 @@ version = "3.0.2" features = ["wasm-bindgen"] [dev-dependencies] -async-trait = "0.1.41" -async-std = { version = "1.6.5", features = ["unstable"] } +async-std = { version = "1.8.0", features = ["unstable"] } dirs = "3.0.1" matrix-sdk-test = { version = "0.1.0", path = "../matrix_sdk_test" } -tokio = { version = "0.2.22", default-features = false, features = ["rt-threaded", "macros"] } -serde_json = "1.0.59" -tracing-subscriber = "0.2.13" +tokio = { version = "0.2.24", default-features = false, features = ["rt-threaded", "macros"] } +serde_json = "1.0.61" +tracing-subscriber = "0.2.15" tempfile = "3.1.0" -mockito = "0.27.0" +mockito = "0.28.0" lazy_static = "1.4.0" [[example]] diff --git a/matrix_sdk/examples/autojoin.rs b/matrix_sdk/examples/autojoin.rs index 76f9938f..94a513aa 100644 --- a/matrix_sdk/examples/autojoin.rs +++ b/matrix_sdk/examples/autojoin.rs @@ -2,11 +2,10 @@ use std::{env, process::exit}; use tokio::time::{delay_for, Duration}; use matrix_sdk::{ - self, + self, async_trait, events::{room::member::MemberEventContent, StrippedStateEvent}, Client, ClientConfig, EventEmitter, RoomState, SyncSettings, }; -use matrix_sdk_common_macros::async_trait; use url::Url; struct AutoJoinBot { diff --git a/matrix_sdk/examples/command_bot.rs b/matrix_sdk/examples/command_bot.rs index 2a103789..a3f12d36 100644 --- a/matrix_sdk/examples/command_bot.rs +++ b/matrix_sdk/examples/command_bot.rs @@ -1,14 +1,13 @@ use std::{env, process::exit}; use matrix_sdk::{ - self, + self, async_trait, events::{ room::message::{MessageEventContent, TextMessageEventContent}, AnyMessageEventContent, SyncMessageEvent, }, Client, ClientConfig, EventEmitter, RoomState, SyncSettings, }; -use matrix_sdk_common_macros::async_trait; use url::Url; struct CommandBot { diff --git a/matrix_sdk/examples/image_bot.rs b/matrix_sdk/examples/image_bot.rs index 106c20c1..b23840c1 100644 --- a/matrix_sdk/examples/image_bot.rs +++ b/matrix_sdk/examples/image_bot.rs @@ -9,14 +9,13 @@ use std::{ use tokio::sync::Mutex; use matrix_sdk::{ - self, + self, async_trait, events::{ room::message::{MessageEventContent, TextMessageEventContent}, SyncMessageEvent, }, Client, ClientConfig, EventEmitter, RoomState, SyncSettings, }; -use matrix_sdk_common_macros::async_trait; use url::Url; struct ImageBot { diff --git a/matrix_sdk/examples/login.rs b/matrix_sdk/examples/login.rs index 39407afb..8a13b1d6 100644 --- a/matrix_sdk/examples/login.rs +++ b/matrix_sdk/examples/login.rs @@ -2,14 +2,13 @@ use std::{env, process::exit}; use url::Url; use matrix_sdk::{ - self, + self, async_trait, events::{ room::message::{MessageEventContent, TextMessageEventContent}, SyncMessageEvent, }, Client, ClientConfig, EventEmitter, RoomState, SyncSettings, }; -use matrix_sdk_common_macros::async_trait; struct EventCallback; diff --git a/matrix_sdk/src/client.rs b/matrix_sdk/src/client.rs index 48b393a0..ecfc118f 100644 --- a/matrix_sdk/src/client.rs +++ b/matrix_sdk/src/client.rs @@ -103,10 +103,9 @@ use matrix_sdk_common::{ }, identifiers::{DeviceIdBox, EventId, RoomId, RoomIdOrAliasId, ServerName, UserId}, instant::{Duration, Instant}, - js_int::UInt, presence::PresenceState, uuid::Uuid, - FromHttpResponseError, + FromHttpResponseError, UInt, }; #[cfg(feature = "encryption")] @@ -1025,7 +1024,6 @@ impl Client { /// # use matrix_sdk::api::r0::filter::RoomEventFilter; /// # use matrix_sdk::api::r0::message::get_message_events::Request as MessagesRequest; /// # use url::Url; - /// # use matrix_sdk::js_int::UInt; /// /// # let homeserver = Url::parse("http://example.com").unwrap(); /// let room_id = room_id!("!roomid:example.com"); diff --git a/matrix_sdk/src/http_client.rs b/matrix_sdk/src/http_client.rs index 67c9fee4..0f5adf92 100644 --- a/matrix_sdk/src/http_client.rs +++ b/matrix_sdk/src/http_client.rs @@ -20,9 +20,8 @@ use tracing::trace; use url::Url; use matrix_sdk_common::{ - api::r0::media::create_content, locks::RwLock, AuthScheme, FromHttpResponseError, + api::r0::media::create_content, async_trait, locks::RwLock, AuthScheme, FromHttpResponseError, }; -use matrix_sdk_common_macros::async_trait; use crate::{ClientConfig, Error, OutgoingRequest, Result, Session}; @@ -42,8 +41,7 @@ pub trait HttpSend: Sync + Send + Debug { /// /// ``` /// use std::convert::TryFrom; - /// use matrix_sdk::{HttpSend, Result}; - /// use matrix_sdk_common_macros::async_trait; + /// use matrix_sdk::{HttpSend, Result, async_trait}; /// /// #[derive(Debug)] /// struct Client(reqwest::Client); diff --git a/matrix_sdk_base/Cargo.toml b/matrix_sdk_base/Cargo.toml index 99712d1b..4ef22833 100644 --- a/matrix_sdk_base/Cargo.toml +++ b/matrix_sdk_base/Cargo.toml @@ -24,33 +24,31 @@ unstable-synapse-quirks = ["matrix-sdk-common/unstable-synapse-quirks"] docs = ["encryption", "sqlite_cryptostore", "messages"] [dependencies] -async-trait = "0.1.41" -serde = { version = "1.0.117", features = ["rc"]} -dashmap= "*" -serde_json = "1.0.59" -zeroize = "1.1.1" -tracing = "0.1.21" +dashmap= "4.0.1" +serde = { version = "1.0.118", features = ["rc"]} +serde_json = "1.0.61" +zeroize = "1.2.0" +tracing = "0.1.22" -matrix-sdk-common-macros = { version = "0.1.0", path = "../matrix_sdk_common_macros" } matrix-sdk-common = { version = "0.1.0", path = "../matrix_sdk_common" } matrix-sdk-crypto = { version = "0.1.0", path = "../matrix_sdk_crypto", optional = true } # Misc dependencies -thiserror = "1.0.21" -sled = "0.34.4" -futures = "0.3.6" +thiserror = "1.0.23" +sled = "0.34.6" +futures = "0.3.8" [target.'cfg(not(target_arch = "wasm32"))'.dependencies.tokio] -version = "0.2.22" +version = "0.2.24" default-features = false features = ["sync", "fs"] [dev-dependencies] matrix-sdk-test = { version = "0.1.0", path = "../matrix_sdk_test" } -http = "0.2.1" -tracing-subscriber = "0.2.13" +http = "0.2.2" +tracing-subscriber = "0.2.15" tempfile = "3.1.0" -mockito = "0.27.0" +mockito = "0.28.0" rustyline = "7.0.0" rustyline-derive = "0.4.0" atty = "0.2" @@ -58,7 +56,7 @@ clap = "2.33.3" syntect = "4.4.0" [target.'cfg(not(target_arch = "wasm32"))'.dev-dependencies] -tokio = { version = "0.2.22", default-features = false, features = ["rt-threaded", "macros"] } +tokio = { version = "0.2.24", default-features = false, features = ["rt-threaded", "macros"] } [target.'cfg(target_arch = "wasm32")'.dev-dependencies] -wasm-bindgen-test = "0.3.18" +wasm-bindgen-test = "0.3.19" diff --git a/matrix_sdk_base/src/event_emitter/mod.rs b/matrix_sdk_base/src/event_emitter/mod.rs index d9a0563a..f457d4cc 100644 --- a/matrix_sdk_base/src/event_emitter/mod.rs +++ b/matrix_sdk_base/src/event_emitter/mod.rs @@ -50,7 +50,7 @@ use crate::{ rooms::RoomState, Store, }; -use matrix_sdk_common_macros::async_trait; +use matrix_sdk_common::async_trait; pub(crate) struct Emitter { pub(crate) inner: Box, @@ -278,8 +278,7 @@ pub enum CustomEvent<'c> { /// # }, /// # EventEmitter, RoomState /// # }; -/// # use matrix_sdk_common::locks::RwLock; -/// # use matrix_sdk_common_macros::async_trait; +/// # use matrix_sdk_common::{async_trait, locks::RwLock}; /// /// struct EventCallback; /// @@ -303,7 +302,8 @@ pub enum CustomEvent<'c> { /// } /// } /// ``` -#[async_trait] +#[cfg_attr(target_arch = "wasm32", async_trait(?Send))] +#[cfg_attr(not(target_arch = "wasm32"), async_trait)] pub trait EventEmitter: Send + Sync { // ROOM EVENTS from `IncomingTimeline` /// Fires when `Client` receives a `RoomEvent::RoomMember` event. @@ -488,8 +488,7 @@ pub trait EventEmitter: Send + Sync { #[cfg(test)] mod test { use super::*; - use matrix_sdk_common::locks::Mutex; - use matrix_sdk_common_macros::async_trait; + use matrix_sdk_common::{async_trait, locks::Mutex}; use matrix_sdk_test::{async_test, sync_response, SyncResponseFile}; use std::sync::Arc; @@ -499,7 +498,8 @@ mod test { #[derive(Clone)] pub struct EvEmitterTest(Arc>>); - #[async_trait] + #[cfg_attr(target_arch = "wasm32", async_trait(?Send))] + #[cfg_attr(not(target_arch = "wasm32"), async_trait)] impl EventEmitter for EvEmitterTest { async fn on_room_member(&self, _: RoomState, _: &SyncStateEvent) { self.0.lock().await.push("member".to_string()) diff --git a/matrix_sdk_base/src/state/json_store.rs b/matrix_sdk_base/src/state/json_store.rs index 2556e96e..2e4b43b1 100644 --- a/matrix_sdk_base/src/state/json_store.rs +++ b/matrix_sdk_base/src/state/json_store.rs @@ -8,7 +8,7 @@ use std::{ }, }; -use matrix_sdk_common::{identifiers::RoomId, locks::RwLock}; +use matrix_sdk_common::{async_trait, identifiers::RoomId, locks::RwLock}; use tokio::{fs as async_fs, io::AsyncWriteExt}; use super::{AllRooms, ClientState, StateStore}; @@ -78,7 +78,7 @@ impl fmt::Debug for JsonStore { } } -#[async_trait::async_trait] +#[async_trait] impl StateStore for JsonStore { async fn load_client_state(&self, sess: &Session) -> Result> { if !self.user_path_set.load(Ordering::SeqCst) { diff --git a/matrix_sdk_base/src/state/mod.rs b/matrix_sdk_base/src/state/mod.rs index de724220..96ddcb8a 100644 --- a/matrix_sdk_base/src/state/mod.rs +++ b/matrix_sdk_base/src/state/mod.rs @@ -16,8 +16,10 @@ use std::collections::HashMap; use matrix_sdk_common::{ + async_trait, identifiers::{RoomId, UserId}, push::Ruleset, + AsyncTraitDeps, }; use serde::{Deserialize, Serialize}; @@ -31,9 +33,6 @@ use crate::{ Result, Room, RoomState, Session, }; -#[cfg(not(target_arch = "wasm32"))] -use matrix_sdk_common_macros::send_sync; - /// `ClientState` holds all the information to restore a `BaseClient` /// except the `access_token` as the default store is not secure. /// @@ -70,9 +69,9 @@ pub struct AllRooms { } /// Abstraction around the data store to avoid unnecessary request on client initialization. -#[async_trait::async_trait] -#[cfg_attr(not(target_arch = "wasm32"), send_sync)] -pub trait StateStore { +#[cfg_attr(target_arch = "wasm32", async_trait(?Send))] +#[cfg_attr(not(target_arch = "wasm32"), async_trait)] +pub trait StateStore: AsyncTraitDeps { /// Loads the state of `BaseClient` through `ClientState` type. /// /// An `Option::None` should be returned only if the `StateStore` tries to diff --git a/matrix_sdk_common/Cargo.toml b/matrix_sdk_common/Cargo.toml index 703dbafa..4421859e 100644 --- a/matrix_sdk_common/Cargo.toml +++ b/matrix_sdk_common/Cargo.toml @@ -14,9 +14,8 @@ version = "0.1.0" unstable-synapse-quirks = ["ruma/unstable-synapse-quirks"] [dependencies] -assign = "1.1.0" -instant = { version = "0.1.7", features = ["wasm-bindgen", "now"] } -js_int = "0.1.9" +instant = { version = "0.1.9", features = ["wasm-bindgen", "now"] } +async-trait = "0.1.42" [dependencies.ruma] version = "0.0.2" @@ -26,7 +25,7 @@ features = ["client-api", "unstable-pre-spec"] uuid = { version = "0.8.1", default-features = false, features = ["v4", "serde"] } [target.'cfg(not(target_arch = "wasm32"))'.dependencies.tokio] -version = "0.2.22" +version = "0.2.24" default-features = false features = ["sync"] diff --git a/matrix_sdk_common/src/lib.rs b/matrix_sdk_common/src/lib.rs index c7a83c90..b157defd 100644 --- a/matrix_sdk_common/src/lib.rs +++ b/matrix_sdk_common/src/lib.rs @@ -1,4 +1,4 @@ -pub use assign::assign; +pub use async_trait::async_trait; pub use instant; pub use ruma::{ api::{ @@ -6,13 +6,27 @@ pub use ruma::{ error::{FromHttpRequestError, FromHttpResponseError, IntoHttpError, ServerError}, AuthScheme, EndpointError, OutgoingRequest, }, - directory, encryption, events, - events::exports::js_int, - identifiers, presence, push, + assign, directory, encryption, events, identifiers, int, presence, push, serde::{CanonicalJsonValue, Raw}, - thirdparty, Outgoing, + thirdparty, uint, Int, Outgoing, UInt, }; pub use uuid; pub mod locks; + +/// Super trait that is used for our store traits, this trait will differ if +/// it's used on WASM. WASM targets will not require `Send` and `Sync` to have +/// implemented, while other targets will. +#[cfg(not(target_arch = "wasm32"))] +pub trait AsyncTraitDeps: std::fmt::Debug + Send + Sync {} +#[cfg(not(target_arch = "wasm32"))] +impl AsyncTraitDeps for T {} + +/// Super trait that is used for our store traits, this trait will differ if +/// it's used on WASM. WASM targets will not require `Send` and `Sync` to have +/// implemented, while other targets will. +#[cfg(target_arch = "wasm32")] +pub trait AsyncTraitDeps: std::fmt::Debug + Send + Sync {} +#[cfg(target_arch = "wasm32")] +impl AsyncTraitDeps for T {} diff --git a/matrix_sdk_common_macros/Cargo.toml b/matrix_sdk_common_macros/Cargo.toml deleted file mode 100644 index d8219ac7..00000000 --- a/matrix_sdk_common_macros/Cargo.toml +++ /dev/null @@ -1,18 +0,0 @@ -[package] -description = "Helper macros for the Matrix SDK" -authors = ["MTRnord "] -edition = "2018" -homepage = "https://github.com/matrix-org/matrix-rust-sdk" -keywords = ["matrix", "chat", "messaging", "ruma"] -license = "Apache-2.0" -name = "matrix-sdk-common-macros" -readme = "README.md" -repository = "https://github.com/matrix-org/matrix-rust-sdk" -version = "0.1.0" - -[lib] -proc-macro = true - -[dependencies] -syn = { version = "1.0.45", features = ["proc-macro"], default-features = false } -quote = "1.0.7" diff --git a/matrix_sdk_common_macros/src/lib.rs b/matrix_sdk_common_macros/src/lib.rs deleted file mode 100644 index 31564805..00000000 --- a/matrix_sdk_common_macros/src/lib.rs +++ /dev/null @@ -1,30 +0,0 @@ -use proc_macro::TokenStream; -use quote::quote; -use syn::{parse_macro_input, parse_quote, ItemTrait}; - -/// Attribute to use `Send + Sync` for everything but wasm32 -#[proc_macro_attribute] -pub fn send_sync(_attr: TokenStream, input: TokenStream) -> TokenStream { - // Parse the input tokens into a syntax tree - let mut input = parse_macro_input!(input as ItemTrait); - - let send_trait_bound = parse_quote!(std::marker::Send); - let sync_trait_bound = parse_quote!(std::marker::Sync); - input.supertraits.push(send_trait_bound); - input.supertraits.push(sync_trait_bound); - - TokenStream::from(quote!(#input)) -} - -/// A wasm32 compatible wrapper for the async_trait::async_trait macro -#[proc_macro_attribute] -pub fn async_trait(_attr: TokenStream, item: TokenStream) -> TokenStream { - let attrs = r#" - #[cfg_attr(target_arch = "wasm32", async_trait::async_trait(?Send))] - #[cfg_attr(not(target_arch = "wasm32"), async_trait::async_trait)] - "#; - - let mut out: TokenStream = attrs.parse().unwrap(); - out.extend(item); - out -} diff --git a/matrix_sdk_crypto/Cargo.toml b/matrix_sdk_crypto/Cargo.toml index 9c46d866..c92e54ac 100644 --- a/matrix_sdk_crypto/Cargo.toml +++ b/matrix_sdk_crypto/Cargo.toml @@ -20,24 +20,21 @@ sqlite_cryptostore = ["sqlx"] docs = ["sqlite_cryptostore"] [dependencies] -async-trait = "0.1.41" - -matrix-sdk-common-macros = { version = "0.1.0", path = "../matrix_sdk_common_macros" } matrix-sdk-common = { version = "0.1.0", path = "../matrix_sdk_common" } olm-rs = { version = "1.0.0", features = ["serde"] } -getrandom = "0.2.0" -serde = { version = "1.0.117", features = ["derive", "rc"] } -serde_json = "1.0.59" -zeroize = { version = "1.1.1", features = ["zeroize_derive"] } +getrandom = "0.2.1" +serde = { version = "1.0.118", features = ["derive", "rc"] } +serde_json = "1.0.61" +zeroize = { version = "1.2.0", features = ["zeroize_derive"] } # Misc dependencies -thiserror = "1.0.21" -tracing = "0.1.21" +thiserror = "1.0.23" +tracing = "0.1.22" atomic = "0.5.0" -dashmap = "3.11.10" -sha2 = "0.9.1" -aes-gcm = "0.7.0" +dashmap = "4.0.1" +sha2 = "0.9.2" +aes-gcm = "0.8.0" aes-ctr = "0.6.0" pbkdf2 = { version = "0.6.0", default-features = false } hmac = "0.10.1" @@ -45,17 +42,17 @@ base64 = "0.13.0" byteorder = "1.3.4" [target.'cfg(not(target_arch = "wasm32"))'.dependencies.sqlx] -version = "0.4.1" +version = "0.4.2" optional = true default-features = false features = ["runtime-tokio-native-tls", "sqlite", "macros"] [dev-dependencies] -tokio = { version = "0.2.22", default-features = false, features = ["rt-threaded", "macros"] } -futures = "0.3.6" +tokio = { version = "0.2.24", default-features = false, features = ["rt-threaded", "macros"] } +futures = "0.3.8" proptest = "0.10.1" -serde_json = "1.0.59" +serde_json = "1.0.61" tempfile = "3.1.0" -http = "0.2.1" +http = "0.2.2" matrix-sdk-test = { version = "0.1.0", path = "../matrix_sdk_test" } indoc = "1.0.3" diff --git a/matrix_sdk_crypto/src/machine.rs b/matrix_sdk_crypto/src/machine.rs index 2a731a5b..8b0c42fe 100644 --- a/matrix_sdk_crypto/src/machine.rs +++ b/matrix_sdk_crypto/src/machine.rs @@ -39,10 +39,9 @@ use matrix_sdk_common::{ DeviceId, DeviceIdBox, DeviceKeyAlgorithm, EventEncryptionAlgorithm, EventId, RoomId, UserId, }, - js_int::UInt, locks::Mutex, uuid::Uuid, - Raw, + Raw, UInt, }; use crate::{ @@ -1202,7 +1201,7 @@ pub(crate) mod test { /// These keys need to be periodically uploaded to the server. type OneTimeKeys = BTreeMap; - use matrix_sdk_common::js_int::uint; + use matrix_sdk_common::uint; fn alice_id() -> UserId { user_id!("@alice:example.org") diff --git a/matrix_sdk_crypto/src/olm/account.rs b/matrix_sdk_crypto/src/olm/account.rs index c619ffeb..6799e55d 100644 --- a/matrix_sdk_crypto/src/olm/account.rs +++ b/matrix_sdk_crypto/src/olm/account.rs @@ -41,9 +41,8 @@ use matrix_sdk_common::{ UserId, }, instant::Instant, - js_int::UInt, locks::Mutex, - CanonicalJsonValue, Raw, + CanonicalJsonValue, Raw, UInt, }; use olm_rs::{ account::{IdentityKeys, OlmAccount, OneTimeKeys}, diff --git a/matrix_sdk_crypto/src/olm/group_sessions/outbound.rs b/matrix_sdk_crypto/src/olm/group_sessions/outbound.rs index 700563df..dd11f2f9 100644 --- a/matrix_sdk_crypto/src/olm/group_sessions/outbound.rs +++ b/matrix_sdk_crypto/src/olm/group_sessions/outbound.rs @@ -418,7 +418,7 @@ mod test { use matrix_sdk_common::{ events::room::encryption::EncryptionEventContent, identifiers::EventEncryptionAlgorithm, - js_int::uint, + uint, }; use super::{EncryptionSettings, ROTATION_MESSAGES, ROTATION_PERIOD}; diff --git a/matrix_sdk_crypto/src/store/memorystore.rs b/matrix_sdk_crypto/src/store/memorystore.rs index d9b3403f..442985a1 100644 --- a/matrix_sdk_crypto/src/store/memorystore.rs +++ b/matrix_sdk_crypto/src/store/memorystore.rs @@ -19,10 +19,10 @@ use std::{ use dashmap::{DashMap, DashSet}; use matrix_sdk_common::{ + async_trait, identifiers::{DeviceId, DeviceIdBox, RoomId, UserId}, locks::Mutex, }; -use matrix_sdk_common_macros::async_trait; use super::{ caches::{DeviceStore, GroupSessionStore, SessionStore}, @@ -92,7 +92,8 @@ impl MemoryStore { } } -#[async_trait] +#[cfg_attr(target_arch = "wasm32", async_trait(?Send))] +#[cfg_attr(not(target_arch = "wasm32"), async_trait)] impl CryptoStore for MemoryStore { async fn load_account(&self) -> Result> { Ok(None) diff --git a/matrix_sdk_crypto/src/store/mod.rs b/matrix_sdk_crypto/src/store/mod.rs index 9f7f7c4b..54f27b11 100644 --- a/matrix_sdk_crypto/src/store/mod.rs +++ b/matrix_sdk_crypto/src/store/mod.rs @@ -44,7 +44,6 @@ mod pickle_key; #[cfg(feature = "sqlite_cryptostore")] pub(crate) mod sqlite; -use matrix_sdk_common::identifiers::DeviceIdBox; pub use memorystore::MemoryStore; pub use pickle_key::{EncryptedPickleKey, PickleKey}; #[cfg(not(target_arch = "wasm32"))] @@ -70,14 +69,14 @@ use thiserror::Error; use sqlx::Error as SqlxError; use matrix_sdk_common::{ + async_trait, identifiers::{ - DeviceId, DeviceKeyAlgorithm, Error as IdentifierValidationError, RoomId, UserId, + DeviceId, DeviceIdBox, DeviceKeyAlgorithm, Error as IdentifierValidationError, RoomId, + UserId, }, locks::Mutex, + AsyncTraitDeps, }; -use matrix_sdk_common_macros::async_trait; -#[cfg(not(target_arch = "wasm32"))] -use matrix_sdk_common_macros::send_sync; use crate::{ error::SessionUnpicklingError, @@ -332,10 +331,9 @@ pub enum CryptoStoreError { /// Trait abstracting a store that the `OlmMachine` uses to store cryptographic /// keys. -#[async_trait] -#[allow(clippy::type_complexity)] -#[cfg_attr(not(target_arch = "wasm32"), send_sync)] -pub trait CryptoStore: Debug { +#[cfg_attr(target_arch = "wasm32", async_trait(?Send))] +#[cfg_attr(not(target_arch = "wasm32"), async_trait)] +pub trait CryptoStore: AsyncTraitDeps { /// Load an account that was previously stored. async fn load_account(&self) -> Result>; diff --git a/matrix_sdk_crypto/src/store/sqlite.rs b/matrix_sdk_crypto/src/store/sqlite.rs index 27d3cb06..6391028d 100644 --- a/matrix_sdk_crypto/src/store/sqlite.rs +++ b/matrix_sdk_crypto/src/store/sqlite.rs @@ -20,10 +20,10 @@ use std::{ sync::{Arc, Mutex as SyncMutex}, }; -use async_trait::async_trait; use dashmap::DashSet; use matrix_sdk_common::{ api::r0::keys::{CrossSigningKey, KeyUsage}, + async_trait, identifiers::{ DeviceId, DeviceIdBox, DeviceKeyAlgorithm, DeviceKeyId, EventEncryptionAlgorithm, RoomId, UserId, diff --git a/matrix_sdk_test/Cargo.toml b/matrix_sdk_test/Cargo.toml index 28f88398..59ff693c 100644 --- a/matrix_sdk_test/Cargo.toml +++ b/matrix_sdk_test/Cargo.toml @@ -11,9 +11,9 @@ repository = "https://github.com/matrix-org/matrix-rust-sdk" version = "0.1.0" [dependencies] -serde_json = "1.0.59" -http = "0.2.1" +serde_json = "1.0.61" +http = "0.2.2" matrix-sdk-common = { version = "0.1.0", path = "../matrix_sdk_common" } matrix-sdk-test-macros = { version = "0.1.0", path = "../matrix_sdk_test_macros" } lazy_static = "1.4.0" -serde = "1.0.117" +serde = "1.0.118"