From ed1f12ce377f9785ead08486d0d84da3f69be872 Mon Sep 17 00:00:00 2001 From: Devin Ragotzy Date: Thu, 30 Jul 2020 19:22:48 -0400 Subject: [PATCH 1/4] Run cargo fmt with merge-imports true --- matrix_sdk/examples/get_profiles.rs | 3 +- matrix_sdk/src/client.rs | 97 +++++++++++---------- matrix_sdk/src/error.rs | 8 +- matrix_sdk/src/lib.rs | 9 +- matrix_sdk/src/request_builder.rs | 11 ++- matrix_sdk_base/src/client.rs | 66 ++++++++------ matrix_sdk_base/src/event_emitter/mod.rs | 47 +++++----- matrix_sdk_base/src/lib.rs | 5 +- matrix_sdk_base/src/models/message.rs | 3 +- matrix_sdk_base/src/models/room.rs | 48 +++++----- matrix_sdk_base/src/models/room_member.rs | 6 +- matrix_sdk_base/src/state/json_store.rs | 32 +++---- matrix_sdk_base/src/state/mod.rs | 13 +-- matrix_sdk_crypto/src/device.rs | 29 +++--- matrix_sdk_crypto/src/lib.rs | 6 +- matrix_sdk_crypto/src/machine.rs | 88 +++++++++++-------- matrix_sdk_crypto/src/memory_stores.rs | 18 ++-- matrix_sdk_crypto/src/olm/account.rs | 24 ++--- matrix_sdk_crypto/src/olm/group_sessions.rs | 20 +++-- matrix_sdk_crypto/src/olm/mod.rs | 9 +- matrix_sdk_crypto/src/olm/session.rs | 14 ++- matrix_sdk_crypto/src/store/memorystore.rs | 19 ++-- matrix_sdk_crypto/src/store/mod.rs | 12 +-- matrix_sdk_crypto/src/store/sqlite.rs | 37 ++++---- matrix_sdk_test/src/lib.rs | 16 ++-- 25 files changed, 353 insertions(+), 287 deletions(-) diff --git a/matrix_sdk/examples/get_profiles.rs b/matrix_sdk/examples/get_profiles.rs index b9ad61dc..6850c404 100644 --- a/matrix_sdk/examples/get_profiles.rs +++ b/matrix_sdk/examples/get_profiles.rs @@ -1,5 +1,4 @@ -use std::convert::TryFrom; -use std::{env, process::exit}; +use std::{convert::TryFrom, env, process::exit}; use url::Url; diff --git a/matrix_sdk/src/client.rs b/matrix_sdk/src/client.rs index 4fc63f81..87303b3f 100644 --- a/matrix_sdk/src/client.rs +++ b/matrix_sdk/src/client.rs @@ -15,19 +15,23 @@ #[cfg(feature = "encryption")] use std::collections::BTreeMap; -use std::collections::HashMap; -use std::convert::{TryFrom, TryInto}; -use std::fmt::{self, Debug}; -use std::path::Path; -use std::result::Result as StdResult; -use std::sync::Arc; +use std::{ + collections::HashMap, + convert::{TryFrom, TryInto}, + fmt::{self, Debug}, + path::Path, + result::Result as StdResult, + sync::Arc, +}; -use matrix_sdk_common::identifiers::ServerName; -use matrix_sdk_common::instant::{Duration, Instant}; -use matrix_sdk_common::js_int::UInt; -use matrix_sdk_common::locks::RwLock; -use matrix_sdk_common::presence::PresenceState; -use matrix_sdk_common::uuid::Uuid; +use matrix_sdk_common::{ + identifiers::ServerName, + instant::{Duration, Instant}, + js_int::UInt, + locks::RwLock, + presence::PresenceState, + uuid::Uuid, +}; use futures_timer::Delay as sleep; use std::future::Future; @@ -35,23 +39,22 @@ use std::future::Future; use tracing::{debug, warn}; use tracing::{error, info, instrument, trace}; -use http::Method as HttpMethod; -use http::Response as HttpResponse; +use http::{Method as HttpMethod, Response as HttpResponse}; use reqwest::header::{HeaderValue, InvalidHeaderValue, AUTHORIZATION}; use url::Url; -use crate::events::room::message::MessageEventContent; -use crate::events::EventType; -use crate::identifiers::{EventId, RoomId, RoomIdOrAliasId, UserId}; -use crate::Endpoint; +use crate::{ + events::{room::message::MessageEventContent, EventType}, + identifiers::{EventId, RoomId, RoomIdOrAliasId, UserId}, + Endpoint, +}; #[cfg(feature = "encryption")] use crate::identifiers::DeviceId; -use crate::api; #[cfg(not(target_arch = "wasm32"))] use crate::VERSION; -use crate::{Error, EventEmitter, Result}; +use crate::{api, Error, EventEmitter, Result}; use matrix_sdk_base::{BaseClient, BaseClientConfig, Room, Session, StateStore}; const DEFAULT_SYNC_TIMEOUT: Duration = Duration::from_secs(30); @@ -269,27 +272,27 @@ impl SyncSettings { } } -use api::r0::account::register; -use api::r0::directory::get_public_rooms; -use api::r0::directory::get_public_rooms_filtered; #[cfg(feature = "encryption")] use api::r0::keys::{claim_keys, get_keys, upload_keys, KeyAlgorithm}; -use api::r0::membership::{ - ban_user, forget_room, - invite_user::{self, InvitationRecipient}, - join_room_by_id, join_room_by_id_or_alias, kick_user, leave_room, Invite3pid, -}; -use api::r0::message::create_message_event; -use api::r0::message::get_message_events; -use api::r0::read_marker::set_read_marker; -use api::r0::receipt::create_receipt; -use api::r0::room::create_room; -use api::r0::session::login; -use api::r0::sync::sync_events; #[cfg(feature = "encryption")] use api::r0::to_device::send_event_to_device; -use api::r0::typing::create_typing_event; -use api::r0::uiaa::UiaaResponse; +use api::r0::{ + account::register, + directory::{get_public_rooms, get_public_rooms_filtered}, + membership::{ + ban_user, forget_room, + invite_user::{self, InvitationRecipient}, + join_room_by_id, join_room_by_id_or_alias, kick_user, leave_room, Invite3pid, + }, + message::{create_message_event, get_message_events}, + read_marker::set_read_marker, + receipt::create_receipt, + room::create_room, + session::login, + sync::sync_events, + typing::create_typing_event, + uiaa::UiaaResponse, +}; impl Client { /// Creates a new client for making HTTP requests to the given homeserver. @@ -1538,23 +1541,27 @@ mod test { get_public_rooms_filtered::{self, Filter}, invite_user, kick_user, leave_room, register::RegistrationKind, - set_read_marker, Invite3pid, MessageEventContent, + set_read_marker, Client, ClientConfig, Invite3pid, MessageEventContent, Session, + SyncSettings, Url, }; - use super::{Client, ClientConfig, Session, SyncSettings, Url}; use crate::events::room::message::TextMessageEventContent; - use crate::identifiers::{EventId, RoomId, RoomIdOrAliasId, UserId}; - use crate::{RegistrationBuilder, RoomListFilterBuilder}; + use crate::{ + identifiers::{EventId, RoomId, RoomIdOrAliasId, UserId}, + RegistrationBuilder, RoomListFilterBuilder, + }; use matrix_sdk_base::JsonStore; use matrix_sdk_test::{test_json, EventBuilder, EventsJson}; use mockito::{mock, Matcher}; use tempfile::tempdir; - use std::convert::{TryFrom, TryInto}; - use std::path::Path; - use std::str::FromStr; - use std::time::Duration; + use std::{ + convert::{TryFrom, TryInto}, + path::Path, + str::FromStr, + time::Duration, + }; #[tokio::test] async fn test_join_leave_room() { diff --git a/matrix_sdk/src/error.rs b/matrix_sdk/src/error.rs index c293797a..e26fcf80 100644 --- a/matrix_sdk/src/error.rs +++ b/matrix_sdk/src/error.rs @@ -20,10 +20,10 @@ use thiserror::Error; use matrix_sdk_base::Error as MatrixError; -use crate::api::r0::uiaa::UiaaResponse as UiaaError; -use crate::api::Error as RumaClientError; -use crate::FromHttpResponseError as RumaResponseError; -use crate::IntoHttpError as RumaIntoHttpError; +use crate::{ + api::{r0::uiaa::UiaaResponse as UiaaError, Error as RumaClientError}, + FromHttpResponseError as RumaResponseError, IntoHttpError as RumaIntoHttpError, +}; /// Result type of the rust-sdk. pub type Result = std::result::Result; diff --git a/matrix_sdk/src/lib.rs b/matrix_sdk/src/lib.rs index 9b72cd43..f3e0e4ad 100644 --- a/matrix_sdk/src/lib.rs +++ b/matrix_sdk/src/lib.rs @@ -36,13 +36,14 @@ unused_qualifications )] -pub use matrix_sdk_base::Error as BaseError; #[cfg(not(target_arch = "wasm32"))] pub use matrix_sdk_base::JsonStore; -pub use matrix_sdk_base::{CustomOrRawEvent, EventEmitter, Room, Session, SyncRoom}; +pub use matrix_sdk_base::{ + CustomOrRawEvent, Error as BaseError, EventEmitter, Room, RoomState, Session, StateStore, + SyncRoom, +}; #[cfg(feature = "messages")] -pub use matrix_sdk_base::{MessageQueue, PossiblyRedactedExt}; -pub use matrix_sdk_base::{RoomState, StateStore}; +pub use matrix_sdk_base::{MessageQueue, MessageWrapper, PossiblyRedactedExt}; pub use matrix_sdk_common::*; pub use reqwest::header::InvalidHeaderValue; diff --git a/matrix_sdk/src/request_builder.rs b/matrix_sdk/src/request_builder.rs index 88ba1d5f..6591a7bb 100644 --- a/matrix_sdk/src/request_builder.rs +++ b/matrix_sdk/src/request_builder.rs @@ -454,10 +454,13 @@ mod test { use std::collections::BTreeMap; use super::*; - use crate::api::r0::filter::{LazyLoadOptions, RoomEventFilter}; - use crate::events::room::power_levels::NotificationPowerLevels; - use crate::js_int::Int; - use crate::{identifiers::RoomId, Client, Session}; + use crate::{ + api::r0::filter::{LazyLoadOptions, RoomEventFilter}, + events::room::power_levels::NotificationPowerLevels, + identifiers::RoomId, + js_int::Int, + Client, Session, + }; use matrix_sdk_test::test_json; use mockito::{mock, Matcher}; diff --git a/matrix_sdk_base/src/client.rs b/matrix_sdk_base/src/client.rs index 1f2bc2a2..99f60be9 100644 --- a/matrix_sdk_base/src/client.rs +++ b/matrix_sdk_base/src/client.rs @@ -13,35 +13,40 @@ // See the License for the specific language governing permissions and // limitations under the License. -use std::collections::HashMap; #[cfg(feature = "encryption")] use std::collections::{BTreeMap, HashSet}; -use std::fmt; -use std::path::{Path, PathBuf}; -use std::sync::Arc; +use std::{ + collections::HashMap, + fmt, + path::{Path, PathBuf}, + sync::Arc, +}; use zeroize::Zeroizing; use std::result::Result as StdResult; -use crate::api::r0 as api; -use crate::error::Result; -use crate::events::presence::PresenceEvent; +use crate::{api::r0 as api, error::Result, events::presence::PresenceEvent}; // `NonRoomEvent` is what it is aliased as -use crate::event_emitter::CustomOrRawEvent; -use crate::events::ignored_user_list::IgnoredUserListEvent; -use crate::events::push_rules::PushRulesEvent; -use crate::events::room::member::MemberEventContent; -use crate::identifiers::{RoomId, UserId}; -use crate::models::Room; -use crate::push::Ruleset; -use crate::session::Session; -use crate::state::{AllRooms, ClientState, StateStore}; -use crate::EventEmitter; -use matrix_sdk_common::events::{ - AnyBasicEvent, AnyStrippedStateEvent, AnySyncEphemeralRoomEvent, AnySyncMessageEvent, - AnySyncRoomEvent, AnySyncStateEvent, +use crate::{ + event_emitter::CustomOrRawEvent, + events::{ + ignored_user_list::IgnoredUserListEvent, push_rules::PushRulesEvent, + room::member::MemberEventContent, + }, + identifiers::{RoomId, UserId}, + models::Room, + push::Ruleset, + session::Session, + state::{AllRooms, ClientState, StateStore}, + EventEmitter, +}; +use matrix_sdk_common::{ + events::{ + AnyBasicEvent, AnyStrippedStateEvent, AnySyncEphemeralRoomEvent, AnySyncMessageEvent, + AnySyncRoomEvent, AnySyncStateEvent, + }, + Raw, }; -use matrix_sdk_common::Raw; #[cfg(feature = "encryption")] use matrix_sdk_common::locks::Mutex; @@ -1831,10 +1836,12 @@ impl BaseClient { #[cfg(test)] mod test { - use crate::identifiers::{RoomId, UserId}; #[cfg(feature = "messages")] use crate::{events::AnySyncRoomEvent, identifiers::EventId, BaseClientConfig, JsonStore, Raw}; - use crate::{BaseClient, Session}; + use crate::{ + identifiers::{RoomId, UserId}, + BaseClient, Session, + }; use matrix_sdk_common_macros::async_trait; use matrix_sdk_test::{async_test, test_json, EventBuilder, EventsJson}; use serde_json::json; @@ -1997,11 +2004,13 @@ mod test { use super::*; use crate::{EventEmitter, SyncRoom}; - use matrix_sdk_common::events::{ - room::member::{MemberEventContent, MembershipChange}, - SyncStateEvent, + use matrix_sdk_common::{ + events::{ + room::member::{MemberEventContent, MembershipChange}, + SyncStateEvent, + }, + locks::RwLock, }; - use matrix_sdk_common::locks::RwLock; use std::sync::{ atomic::{AtomicBool, Ordering}, Arc, @@ -2253,8 +2262,7 @@ mod test { use super::*; use crate::{EventEmitter, SyncRoom}; - use matrix_sdk_common::api::r0::sync::sync_events; - use matrix_sdk_common::locks::RwLock; + use matrix_sdk_common::{api::r0::sync::sync_events, locks::RwLock}; use std::sync::{ atomic::{AtomicBool, Ordering}, Arc, diff --git a/matrix_sdk_base/src/event_emitter/mod.rs b/matrix_sdk_base/src/event_emitter/mod.rs index 150cc74f..faa416bf 100644 --- a/matrix_sdk_base/src/event_emitter/mod.rs +++ b/matrix_sdk_base/src/event_emitter/mod.rs @@ -17,29 +17,31 @@ use std::sync::Arc; use matrix_sdk_common::locks::RwLock; use serde_json::value::RawValue as RawJsonValue; -use crate::events::{ - custom::CustomEventContent, - fully_read::FullyReadEventContent, - ignored_user_list::IgnoredUserListEventContent, - presence::PresenceEvent, - push_rules::PushRulesEventContent, - receipt::ReceiptEventContent, - room::{ - aliases::AliasesEventContent, - avatar::AvatarEventContent, - canonical_alias::CanonicalAliasEventContent, - join_rules::JoinRulesEventContent, - member::MemberEventContent, - message::{feedback::FeedbackEventContent, MessageEventContent as MsgEventContent}, - name::NameEventContent, - power_levels::PowerLevelsEventContent, - redaction::SyncRedactionEvent, - tombstone::TombstoneEventContent, +use crate::{ + events::{ + custom::CustomEventContent, + fully_read::FullyReadEventContent, + ignored_user_list::IgnoredUserListEventContent, + presence::PresenceEvent, + push_rules::PushRulesEventContent, + receipt::ReceiptEventContent, + room::{ + aliases::AliasesEventContent, + avatar::AvatarEventContent, + canonical_alias::CanonicalAliasEventContent, + join_rules::JoinRulesEventContent, + member::MemberEventContent, + message::{feedback::FeedbackEventContent, MessageEventContent as MsgEventContent}, + name::NameEventContent, + power_levels::PowerLevelsEventContent, + redaction::SyncRedactionEvent, + tombstone::TombstoneEventContent, + }, + typing::TypingEventContent, + BasicEvent, StrippedStateEvent, SyncEphemeralRoomEvent, SyncMessageEvent, SyncStateEvent, }, - typing::TypingEventContent, - BasicEvent, StrippedStateEvent, SyncEphemeralRoomEvent, SyncMessageEvent, SyncStateEvent, + Room, RoomState, }; -use crate::{Room, RoomState}; use matrix_sdk_common_macros::async_trait; /// Type alias for `RoomState` enum when passed to `EventEmitter` methods. @@ -471,8 +473,7 @@ mod test { } } - use crate::identifiers::UserId; - use crate::{BaseClient, Session}; + use crate::{identifiers::UserId, BaseClient, Session}; use std::convert::TryFrom; diff --git a/matrix_sdk_base/src/lib.rs b/matrix_sdk_base/src/lib.rs index f7e07bd2..9d32fa56 100644 --- a/matrix_sdk_base/src/lib.rs +++ b/matrix_sdk_base/src/lib.rs @@ -35,7 +35,10 @@ unused_qualifications )] -pub use crate::{error::Error, error::Result, session::Session}; +pub use crate::{ + error::{Error, Result}, + session::Session, +}; pub use matrix_sdk_common::*; mod client; diff --git a/matrix_sdk_base/src/models/message.rs b/matrix_sdk_base/src/models/message.rs index 5b496766..29b9a582 100644 --- a/matrix_sdk_base/src/models/message.rs +++ b/matrix_sdk_base/src/models/message.rs @@ -160,8 +160,7 @@ pub(crate) mod ser_deser { #[cfg(test)] mod test { - use std::collections::HashMap; - use std::convert::TryFrom; + use std::{collections::HashMap, convert::TryFrom}; use matrix_sdk_common::{ events::{AnyPossiblyRedactedSyncMessageEvent, AnySyncMessageEvent}, diff --git a/matrix_sdk_base/src/models/room.rs b/matrix_sdk_base/src/models/room.rs index 8d9fb2d9..6802f1e9 100644 --- a/matrix_sdk_base/src/models/room.rs +++ b/matrix_sdk_base/src/models/room.rs @@ -13,10 +13,12 @@ // See the License for the specific language governing permissions and // limitations under the License. -use std::collections::{BTreeMap, HashMap, HashSet}; -use std::convert::TryFrom; #[cfg(feature = "messages")] use std::ops::DerefMut; +use std::{ + collections::{BTreeMap, HashMap, HashSet}, + convert::TryFrom, +}; use serde::{Deserialize, Serialize}; use tracing::{debug, error, trace}; @@ -24,20 +26,22 @@ use tracing::{debug, error, trace}; #[cfg(feature = "messages")] use super::message::MessageQueue; use super::RoomMember; -use crate::api::r0::sync::sync_events::{RoomSummary, UnreadNotificationsCount}; -use crate::events::{ - presence::{PresenceEvent, PresenceEventContent}, - room::{ - aliases::AliasesEventContent, - canonical_alias::CanonicalAliasEventContent, - encryption::EncryptionEventContent, - member::{MemberEventContent, MembershipChange, MembershipState}, - name::NameEventContent, - power_levels::{NotificationPowerLevels, PowerLevelsEventContent}, - tombstone::TombstoneEventContent, +use crate::{ + api::r0::sync::sync_events::{RoomSummary, UnreadNotificationsCount}, + events::{ + presence::{PresenceEvent, PresenceEventContent}, + room::{ + aliases::AliasesEventContent, + canonical_alias::CanonicalAliasEventContent, + encryption::EncryptionEventContent, + member::{MemberEventContent, MembershipChange, MembershipState}, + name::NameEventContent, + power_levels::{NotificationPowerLevels, PowerLevelsEventContent}, + tombstone::TombstoneEventContent, + }, + Algorithm, AnyStrippedStateEvent, AnySyncRoomEvent, AnySyncStateEvent, EventType, + StrippedStateEvent, SyncStateEvent, }, - Algorithm, AnyStrippedStateEvent, AnySyncRoomEvent, AnySyncStateEvent, EventType, - StrippedStateEvent, SyncStateEvent, }; #[cfg(feature = "messages")] @@ -670,8 +674,7 @@ impl Room { #[cfg(feature = "messages")] #[cfg_attr(docsrs, doc(cfg(feature = "messages")))] pub fn handle_redaction(&mut self, redacted_event: &SyncRedactionEvent) -> bool { - use crate::identifiers::RoomVersionId; - use crate::models::message::PossiblyRedactedExt; + use crate::{identifiers::RoomVersionId, models::message::PossiblyRedactedExt}; if let Some(mut msg) = self .messages @@ -1080,9 +1083,11 @@ impl Describe for MembershipChange { #[cfg(test)] mod test { use super::*; - use crate::events::{room::encryption::EncryptionEventContent, Unsigned}; - use crate::identifiers::{EventId, UserId}; - use crate::{BaseClient, Raw, Session}; + use crate::{ + events::{room::encryption::EncryptionEventContent, Unsigned}, + identifiers::{EventId, UserId}, + BaseClient, Raw, Session, + }; use matrix_sdk_test::{async_test, sync_response, EventBuilder, EventsJson, SyncResponseFile}; use std::time::SystemTime; @@ -1090,8 +1095,7 @@ mod test { #[cfg(target_arch = "wasm32")] use wasm_bindgen_test::*; - use std::convert::TryFrom; - use std::ops::Deref; + use std::{convert::TryFrom, ops::Deref}; async fn get_client() -> BaseClient { let session = Session { diff --git a/matrix_sdk_base/src/models/room_member.rs b/matrix_sdk_base/src/models/room_member.rs index 9baf8482..79bb0c8d 100644 --- a/matrix_sdk_base/src/models/room_member.rs +++ b/matrix_sdk_base/src/models/room_member.rs @@ -154,8 +154,10 @@ impl RoomMember { mod test { use matrix_sdk_test::{async_test, EventBuilder, EventsJson}; - use crate::identifiers::{RoomId, UserId}; - use crate::{BaseClient, Session}; + use crate::{ + identifiers::{RoomId, UserId}, + BaseClient, Session, + }; use crate::js_int::int; diff --git a/matrix_sdk_base/src/state/json_store.rs b/matrix_sdk_base/src/state/json_store.rs index c7ef514f..204eb67a 100644 --- a/matrix_sdk_base/src/state/json_store.rs +++ b/matrix_sdk_base/src/state/json_store.rs @@ -1,16 +1,15 @@ -use std::collections::HashMap; -use std::fmt; -use std::fs; -use std::path::{Path, PathBuf}; -use std::sync::{ - atomic::{AtomicBool, Ordering}, - Arc, +use std::{ + collections::HashMap, + fmt, fs, + path::{Path, PathBuf}, + sync::{ + atomic::{AtomicBool, Ordering}, + Arc, + }, }; -use matrix_sdk_common::identifiers::RoomId; -use matrix_sdk_common::locks::RwLock; -use tokio::fs as async_fs; -use tokio::io::AsyncWriteExt; +use matrix_sdk_common::{identifiers::RoomId, locks::RwLock}; +use tokio::{fs as async_fs, io::AsyncWriteExt}; use super::{AllRooms, ClientState, StateStore}; use crate::{Error, Result, Room, RoomState, Session}; @@ -218,14 +217,15 @@ impl StateStore for JsonStore { mod test { use super::*; - use std::convert::TryFrom; - use std::path::PathBuf; + use std::{convert::TryFrom, path::PathBuf}; use tempfile::tempdir; - use crate::identifiers::{RoomId, UserId}; - use crate::push::Ruleset; - use crate::{BaseClient, BaseClientConfig, Session}; + use crate::{ + identifiers::{RoomId, UserId}, + push::Ruleset, + BaseClient, BaseClientConfig, Session, + }; use matrix_sdk_test::{sync_response, SyncResponseFile}; diff --git a/matrix_sdk_base/src/state/mod.rs b/matrix_sdk_base/src/state/mod.rs index 3b5d0203..6e7ac5a2 100644 --- a/matrix_sdk_base/src/state/mod.rs +++ b/matrix_sdk_base/src/state/mod.rs @@ -22,10 +22,12 @@ mod json_store; #[cfg(not(target_arch = "wasm32"))] pub use json_store::JsonStore; -use crate::client::{BaseClient, Token}; -use crate::identifiers::{RoomId, UserId}; -use crate::push::Ruleset; -use crate::{Result, Room, RoomState, Session}; +use crate::{ + client::{BaseClient, Token}, + identifiers::{RoomId, UserId}, + push::Ruleset, + Result, Room, RoomState, Session, +}; #[cfg(not(target_arch = "wasm32"))] use matrix_sdk_common_macros::send_sync; @@ -117,8 +119,7 @@ pub trait StateStore { mod test { use super::*; - use std::collections::HashMap; - use std::convert::TryFrom; + use std::{collections::HashMap, convert::TryFrom}; use crate::identifiers::RoomId; diff --git a/matrix_sdk_crypto/src/device.rs b/matrix_sdk_crypto/src/device.rs index fc01f73c..fe59f1d4 100644 --- a/matrix_sdk_crypto/src/device.rs +++ b/matrix_sdk_crypto/src/device.rs @@ -12,22 +12,27 @@ // See the License for the specific language governing permissions and // limitations under the License. -use std::collections::BTreeMap; -use std::convert::TryFrom; -use std::sync::atomic::{AtomicBool, Ordering}; -use std::sync::Arc; +use std::{ + collections::BTreeMap, + convert::TryFrom, + sync::{ + atomic::{AtomicBool, Ordering}, + Arc, + }, +}; use atomic::Atomic; use serde_json::{json, Value}; #[cfg(test)] use super::OlmMachine; -use matrix_sdk_common::api::r0::keys::{AlgorithmAndDeviceId, DeviceKeys, KeyAlgorithm, SignedKey}; -use matrix_sdk_common::events::Algorithm; -use matrix_sdk_common::identifiers::{DeviceId, UserId}; +use matrix_sdk_common::{ + api::r0::keys::{AlgorithmAndDeviceId, DeviceKeys, KeyAlgorithm, SignedKey}, + events::Algorithm, + identifiers::{DeviceId, UserId}, +}; -use crate::error::SignatureError; -use crate::verify_json; +use crate::{error::SignatureError, verify_json}; /// A device represents a E2EE capable client of an user. #[derive(Debug, Clone)] @@ -230,8 +235,10 @@ pub(crate) mod test { use std::convert::TryFrom; use crate::device::{Device, TrustState}; - use matrix_sdk_common::api::r0::keys::{DeviceKeys, KeyAlgorithm}; - use matrix_sdk_common::identifiers::UserId; + use matrix_sdk_common::{ + api::r0::keys::{DeviceKeys, KeyAlgorithm}, + identifiers::UserId, + }; fn device_keys() -> DeviceKeys { let device_keys = json!({ diff --git a/matrix_sdk_crypto/src/lib.rs b/matrix_sdk_crypto/src/lib.rs index 332e61db..6abb7a9f 100644 --- a/matrix_sdk_crypto/src/lib.rs +++ b/matrix_sdk_crypto/src/lib.rs @@ -43,8 +43,10 @@ pub use store::sqlite::SqliteStore; pub use store::{CryptoStore, CryptoStoreError}; use error::SignatureError; -use matrix_sdk_common::api::r0::keys::{AlgorithmAndDeviceId, KeyAlgorithm}; -use matrix_sdk_common::identifiers::UserId; +use matrix_sdk_common::{ + api::r0::keys::{AlgorithmAndDeviceId, KeyAlgorithm}, + identifiers::UserId, +}; use olm_rs::utility::OlmUtility; use serde_json::Value; diff --git a/matrix_sdk_crypto/src/machine.rs b/matrix_sdk_crypto/src/machine.rs index b569e429..67ba2f21 100644 --- a/matrix_sdk_crypto/src/machine.rs +++ b/matrix_sdk_crypto/src/machine.rs @@ -12,35 +12,44 @@ // See the License for the specific language governing permissions and // limitations under the License. -use std::collections::{BTreeMap, HashMap, HashSet}; -use std::convert::TryFrom; -use std::convert::TryInto; -use std::mem; #[cfg(feature = "sqlite-cryptostore")] use std::path::Path; -use std::result::Result as StdResult; - -use super::error::{EventError, MegolmError, MegolmResult, OlmError, OlmResult}; -use super::olm::{ - Account, GroupSessionKey, IdentityKeys, InboundGroupSession, OlmMessage, OutboundGroupSession, +use std::{ + collections::{BTreeMap, HashMap, HashSet}, + convert::{TryFrom, TryInto}, + mem, + result::Result as StdResult, }; -use super::store::memorystore::MemoryStore; + #[cfg(feature = "sqlite-cryptostore")] use super::store::sqlite::SqliteStore; -use super::{device::Device, store::Result as StoreResult, CryptoStore}; - -use matrix_sdk_common::events::{ - forwarded_room_key::ForwardedRoomKeyEventContent, room::encrypted::EncryptedEventContent, - room::message::MessageEventContent, room_key::RoomKeyEventContent, - room_key_request::RoomKeyRequestEventContent, Algorithm, AnySyncRoomEvent, AnyToDeviceEvent, - EventType, SyncMessageEvent, ToDeviceEvent, +use super::{ + device::Device, + error::{EventError, MegolmError, MegolmResult, OlmError, OlmResult}, + olm::{ + Account, GroupSessionKey, IdentityKeys, InboundGroupSession, OlmMessage, + OutboundGroupSession, + }, + store::{memorystore::MemoryStore, Result as StoreResult}, + CryptoStore, +}; + +use matrix_sdk_common::{ + api, + events::{ + forwarded_room_key::ForwardedRoomKeyEventContent, + room::{encrypted::EncryptedEventContent, message::MessageEventContent}, + room_key::RoomKeyEventContent, + room_key_request::RoomKeyRequestEventContent, + Algorithm, AnySyncRoomEvent, AnyToDeviceEvent, EventType, SyncMessageEvent, ToDeviceEvent, + }, + identifiers::{DeviceId, RoomId, UserId}, + uuid::Uuid, + Raw, }; -use matrix_sdk_common::identifiers::{DeviceId, RoomId, UserId}; -use matrix_sdk_common::uuid::Uuid; -use matrix_sdk_common::{api, Raw}; -use api::r0::keys; use api::r0::{ + keys, keys::{AlgorithmAndDeviceId, DeviceKeys, KeyAlgorithm, OneTimeKey}, sync::sync_events::Response as SyncResponse, to_device::{send_event_to_device::Request as ToDeviceRequest, DeviceIdOrAllDevices}, @@ -1166,30 +1175,33 @@ mod test { static USER_ID: &str = "@bob:example.org"; use matrix_sdk_common::js_int::uint; - use std::collections::BTreeMap; - use std::convert::TryFrom; - use std::convert::TryInto; - use std::time::SystemTime; + use std::{ + collections::BTreeMap, + convert::{TryFrom, TryInto}, + time::SystemTime, + }; use http::Response; use serde_json::json; - use crate::machine::{OlmMachine, OneTimeKeys}; - use crate::{verify_json, Device}; + use crate::{ + machine::{OlmMachine, OneTimeKeys}, + verify_json, Device, + }; - use matrix_sdk_common::api::r0::{ - keys, to_device::send_event_to_device::Request as ToDeviceRequest, - }; - use matrix_sdk_common::events::{ - room::{ - encrypted::EncryptedEventContent, - message::{MessageEventContent, TextMessageEventContent}, + use matrix_sdk_common::{ + api::r0::{keys, to_device::send_event_to_device::Request as ToDeviceRequest}, + events::{ + room::{ + encrypted::EncryptedEventContent, + message::{MessageEventContent, TextMessageEventContent}, + }, + AnySyncMessageEvent, AnySyncRoomEvent, AnyToDeviceEvent, EventType, SyncMessageEvent, + ToDeviceEvent, Unsigned, }, - AnySyncMessageEvent, AnySyncRoomEvent, AnyToDeviceEvent, EventType, SyncMessageEvent, - ToDeviceEvent, Unsigned, + identifiers::{DeviceId, EventId, RoomId, UserId}, + Raw, }; - use matrix_sdk_common::identifiers::{DeviceId, EventId, RoomId, UserId}; - use matrix_sdk_common::Raw; use matrix_sdk_test::test_json; fn alice_id() -> UserId { diff --git a/matrix_sdk_crypto/src/memory_stores.rs b/matrix_sdk_crypto/src/memory_stores.rs index 72d91395..0b465c4a 100644 --- a/matrix_sdk_crypto/src/memory_stores.rs +++ b/matrix_sdk_crypto/src/memory_stores.rs @@ -12,14 +12,15 @@ // See the License for the specific language governing permissions and // limitations under the License. -use std::collections::HashMap; -use std::sync::Arc; +use std::{collections::HashMap, sync::Arc}; use dashmap::{DashMap, ReadOnlyView}; use matrix_sdk_common::locks::Mutex; -use super::device::Device; -use super::olm::{InboundGroupSession, Session}; +use super::{ + device::Device, + olm::{InboundGroupSession, Session}, +}; use matrix_sdk_common::identifiers::{DeviceId, RoomId, UserId}; /// In-memory store for Olm Sessions. @@ -211,10 +212,11 @@ impl DeviceStore { mod test { use std::convert::TryFrom; - use crate::device::test::get_device; - use crate::memory_stores::{DeviceStore, GroupSessionStore, SessionStore}; - use crate::olm::test::get_account_and_session; - use crate::olm::InboundGroupSession; + use crate::{ + device::test::get_device, + memory_stores::{DeviceStore, GroupSessionStore, SessionStore}, + olm::{test::get_account_and_session, InboundGroupSession}, + }; use matrix_sdk_common::identifiers::RoomId; #[tokio::test] diff --git a/matrix_sdk_crypto/src/olm/account.rs b/matrix_sdk_crypto/src/olm/account.rs index a1308666..9fa2c17f 100644 --- a/matrix_sdk_crypto/src/olm/account.rs +++ b/matrix_sdk_crypto/src/olm/account.rs @@ -13,23 +13,27 @@ // limitations under the License. use matrix_sdk_common::instant::Instant; -use std::convert::TryFrom; -use std::convert::TryInto; -use std::fmt; -use std::sync::atomic::{AtomicBool, AtomicI64, Ordering}; -use std::sync::Arc; +use std::{ + convert::{TryFrom, TryInto}, + fmt, + sync::{ + atomic::{AtomicBool, AtomicI64, Ordering}, + Arc, + }, +}; use matrix_sdk_common::locks::Mutex; use serde_json::{json, Value}; use std::collections::BTreeMap; pub use olm_rs::account::IdentityKeys; -use olm_rs::account::{OlmAccount, OneTimeKeys}; -use olm_rs::errors::{OlmAccountError, OlmSessionError}; -use olm_rs::PicklingMode; +use olm_rs::{ + account::{OlmAccount, OneTimeKeys}, + errors::{OlmAccountError, OlmSessionError}, + PicklingMode, +}; -use crate::device::Device; -use crate::error::SessionCreationError; +use crate::{device::Device, error::SessionCreationError}; pub use olm_rs::{ session::{OlmMessage, PreKeyMessage}, utility::OlmUtility, diff --git a/matrix_sdk_crypto/src/olm/group_sessions.rs b/matrix_sdk_crypto/src/olm/group_sessions.rs index 10c61904..e3725d04 100644 --- a/matrix_sdk_crypto/src/olm/group_sessions.rs +++ b/matrix_sdk_crypto/src/olm/group_sessions.rs @@ -13,10 +13,14 @@ // limitations under the License. use matrix_sdk_common::instant::Instant; -use std::convert::TryInto; -use std::fmt; -use std::sync::atomic::{AtomicBool, AtomicUsize, Ordering}; -use std::sync::Arc; +use std::{ + convert::TryInto, + fmt, + sync::{ + atomic::{AtomicBool, AtomicUsize, Ordering}, + Arc, + }, +}; use matrix_sdk_common::locks::Mutex; use serde::Serialize; @@ -24,10 +28,10 @@ use serde_json::{json, Value}; use zeroize::Zeroize; pub use olm_rs::account::IdentityKeys; -use olm_rs::errors::OlmGroupSessionError; -use olm_rs::inbound_group_session::OlmInboundGroupSession; -use olm_rs::outbound_group_session::OlmOutboundGroupSession; -use olm_rs::PicklingMode; +use olm_rs::{ + errors::OlmGroupSessionError, inbound_group_session::OlmInboundGroupSession, + outbound_group_session::OlmOutboundGroupSession, PicklingMode, +}; use crate::error::{EventError, MegolmResult}; pub use olm_rs::{ diff --git a/matrix_sdk_crypto/src/olm/mod.rs b/matrix_sdk_crypto/src/olm/mod.rs index e6e31c3f..18f21936 100644 --- a/matrix_sdk_crypto/src/olm/mod.rs +++ b/matrix_sdk_crypto/src/olm/mod.rs @@ -23,11 +23,12 @@ pub use session::{OlmMessage, Session}; #[cfg(test)] pub(crate) mod test { use crate::olm::{Account, InboundGroupSession, Session}; - use matrix_sdk_common::api::r0::keys::SignedKey; - use matrix_sdk_common::identifiers::{DeviceId, RoomId, UserId}; + use matrix_sdk_common::{ + api::r0::keys::SignedKey, + identifiers::{DeviceId, RoomId, UserId}, + }; use olm_rs::session::OlmMessage; - use std::collections::BTreeMap; - use std::convert::TryFrom; + use std::{collections::BTreeMap, convert::TryFrom}; fn alice_id() -> UserId { UserId::try_from("@alice:example.org").unwrap() diff --git a/matrix_sdk_crypto/src/olm/session.rs b/matrix_sdk_crypto/src/olm/session.rs index d6b11de8..eb52cebc 100644 --- a/matrix_sdk_crypto/src/olm/session.rs +++ b/matrix_sdk_crypto/src/olm/session.rs @@ -12,13 +12,9 @@ // See the License for the specific language governing permissions and // limitations under the License. -use std::collections::BTreeMap; -use std::fmt; -use std::sync::Arc; +use std::{collections::BTreeMap, fmt, sync::Arc}; -use olm_rs::errors::OlmSessionError; -use olm_rs::session::OlmSession; -use olm_rs::PicklingMode; +use olm_rs::{errors::OlmSessionError, session::OlmSession, PicklingMode}; use serde_json::{json, Value}; @@ -28,8 +24,10 @@ pub use olm_rs::{ }; use super::IdentityKeys; -use crate::error::{EventError, OlmResult}; -use crate::Device; +use crate::{ + error::{EventError, OlmResult}, + Device, +}; use matrix_sdk_common::{ api::r0::keys::KeyAlgorithm, diff --git a/matrix_sdk_crypto/src/store/memorystore.rs b/matrix_sdk_crypto/src/store/memorystore.rs index a911320f..071c697a 100644 --- a/matrix_sdk_crypto/src/store/memorystore.rs +++ b/matrix_sdk_crypto/src/store/memorystore.rs @@ -12,15 +12,16 @@ // See the License for the specific language governing permissions and // limitations under the License. -use std::collections::HashSet; -use std::sync::Arc; +use std::{collections::HashSet, sync::Arc}; use async_trait::async_trait; use matrix_sdk_common::locks::Mutex; use super::{Account, CryptoStore, InboundGroupSession, Result, Session}; -use crate::device::Device; -use crate::memory_stores::{DeviceStore, GroupSessionStore, SessionStore, UserDevices}; +use crate::{ + device::Device, + memory_stores::{DeviceStore, GroupSessionStore, SessionStore, UserDevices}, +}; use matrix_sdk_common::identifiers::{DeviceId, RoomId, UserId}; #[derive(Debug)] @@ -126,11 +127,11 @@ impl CryptoStore for MemoryStore { mod test { use std::convert::TryFrom; - use crate::device::test::get_device; - use crate::olm::test::get_account_and_session; - use crate::olm::InboundGroupSession; - use crate::store::memorystore::MemoryStore; - use crate::store::CryptoStore; + use crate::{ + device::test::get_device, + olm::{test::get_account_and_session, InboundGroupSession}, + store::{memorystore::MemoryStore, CryptoStore}, + }; use matrix_sdk_common::identifiers::RoomId; #[tokio::test] diff --git a/matrix_sdk_crypto/src/store/mod.rs b/matrix_sdk_crypto/src/store/mod.rs index 2e40503e..ab0f2a24 100644 --- a/matrix_sdk_crypto/src/store/mod.rs +++ b/matrix_sdk_crypto/src/store/mod.rs @@ -13,9 +13,7 @@ // limitations under the License. use core::fmt::Debug; -use std::collections::HashSet; -use std::io::Error as IoError; -use std::sync::Arc; +use std::{collections::HashSet, io::Error as IoError, sync::Arc}; use url::ParseError; use async_trait::async_trait; @@ -23,9 +21,11 @@ use matrix_sdk_common::locks::Mutex; use serde_json::Error as SerdeError; use thiserror::Error; -use super::device::Device; -use super::memory_stores::UserDevices; -use super::olm::{Account, InboundGroupSession, Session}; +use super::{ + device::Device, + memory_stores::UserDevices, + olm::{Account, InboundGroupSession, Session}, +}; use matrix_sdk_common::identifiers::{DeviceId, RoomId, UserId}; use matrix_sdk_common_macros::send_sync; use olm_rs::errors::{OlmAccountError, OlmGroupSessionError, OlmSessionError}; diff --git a/matrix_sdk_crypto/src/store/sqlite.rs b/matrix_sdk_crypto/src/store/sqlite.rs index 786863a8..6f407be4 100644 --- a/matrix_sdk_crypto/src/store/sqlite.rs +++ b/matrix_sdk_crypto/src/store/sqlite.rs @@ -13,11 +13,13 @@ // limitations under the License. use matrix_sdk_common::instant::{Duration, Instant}; -use std::collections::{BTreeMap, HashSet}; -use std::convert::TryFrom; -use std::path::{Path, PathBuf}; -use std::result::Result as StdResult; -use std::sync::Arc; +use std::{ + collections::{BTreeMap, HashSet}, + convert::TryFrom, + path::{Path, PathBuf}, + result::Result as StdResult, + sync::Arc, +}; use url::Url; use async_trait::async_trait; @@ -27,12 +29,16 @@ use sqlx::{query, query_as, sqlite::SqliteQueryAs, Connect, Executor, SqliteConn use zeroize::Zeroizing; use super::{CryptoStore, CryptoStoreError, Result}; -use crate::device::{Device, TrustState}; -use crate::memory_stores::{DeviceStore, GroupSessionStore, SessionStore, UserDevices}; -use crate::{Account, IdentityKeys, InboundGroupSession, Session}; -use matrix_sdk_common::api::r0::keys::{AlgorithmAndDeviceId, KeyAlgorithm}; -use matrix_sdk_common::events::Algorithm; -use matrix_sdk_common::identifiers::{DeviceId, RoomId, UserId}; +use crate::{ + device::{Device, TrustState}, + memory_stores::{DeviceStore, GroupSessionStore, SessionStore, UserDevices}, + Account, IdentityKeys, InboundGroupSession, Session, +}; +use matrix_sdk_common::{ + api::r0::keys::{AlgorithmAndDeviceId, KeyAlgorithm}, + events::Algorithm, + identifiers::{DeviceId, RoomId, UserId}, +}; /// SQLite based implementation of a `CryptoStore`. pub struct SqliteStore { @@ -887,10 +893,11 @@ impl std::fmt::Debug for SqliteStore { #[cfg(test)] mod test { - use crate::device::test::get_device; - use crate::olm::GroupSessionKey; - use matrix_sdk_common::api::r0::keys::SignedKey; - use matrix_sdk_common::identifiers::{DeviceId, UserId}; + use crate::{device::test::get_device, olm::GroupSessionKey}; + use matrix_sdk_common::{ + api::r0::keys::SignedKey, + identifiers::{DeviceId, UserId}, + }; use olm_rs::outbound_group_session::OlmOutboundGroupSession; use std::collections::BTreeMap; use tempfile::tempdir; diff --git a/matrix_sdk_test/src/lib.rs b/matrix_sdk_test/src/lib.rs index 2a33ce3a..c3a149b1 100644 --- a/matrix_sdk_test/src/lib.rs +++ b/matrix_sdk_test/src/lib.rs @@ -1,15 +1,15 @@ -use std::collections::HashMap; -use std::convert::TryFrom; -use std::panic; +use std::{collections::HashMap, convert::TryFrom, panic}; use http::Response; -use matrix_sdk_common::api::r0::sync::sync_events::Response as SyncResponse; -use matrix_sdk_common::events::{ - presence::PresenceEvent, AnyBasicEvent, AnySyncEphemeralRoomEvent, AnySyncRoomEvent, - AnySyncStateEvent, +use matrix_sdk_common::{ + api::r0::sync::sync_events::Response as SyncResponse, + events::{ + presence::PresenceEvent, AnyBasicEvent, AnySyncEphemeralRoomEvent, AnySyncRoomEvent, + AnySyncStateEvent, + }, + identifiers::RoomId, }; -use matrix_sdk_common::identifiers::RoomId; use serde_json::Value as JsonValue; pub use matrix_sdk_test_macros::async_test; From 230b2a229f7ed2391b2848f6c5fad4c1b5ec2eb6 Mon Sep 17 00:00:00 2001 From: Devin Ragotzy Date: Thu, 30 Jul 2020 20:05:49 -0400 Subject: [PATCH 2/4] matrix_sdk: Remove clippy allows --- matrix_sdk/src/client.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/matrix_sdk/src/client.rs b/matrix_sdk/src/client.rs index 87303b3f..40ccf616 100644 --- a/matrix_sdk/src/client.rs +++ b/matrix_sdk/src/client.rs @@ -316,10 +316,10 @@ impl Client { homeserver_url: U, config: ClientConfig, ) -> Result { - #[allow(clippy::match_wild_err_arm)] - let homeserver: Url = match homeserver_url.try_into() { - Ok(u) => u, - Err(_e) => panic!("Error parsing homeserver url"), + let homeserver = if let Ok(u) = homeserver_url.try_into() { + u + } else { + panic!("Error parsing homeserver url") }; let http_client = reqwest::Client::builder(); From 0ac2b84c026f53441e9b945f2b025ee9b80eab44 Mon Sep 17 00:00:00 2001 From: Devin Ragotzy Date: Sun, 2 Aug 2020 08:05:43 -0400 Subject: [PATCH 3/4] Unify import style across workspace --- matrix_sdk/src/client.rs | 35 ++++------ matrix_sdk/src/error.rs | 10 ++- matrix_sdk/src/lib.rs | 10 +-- matrix_sdk_base/src/client.rs | 77 ++++++++++----------- matrix_sdk_base/src/models/message.rs | 7 +- matrix_sdk_base/src/models/room.rs | 23 +++--- matrix_sdk_base/src/session.rs | 2 +- matrix_sdk_base/src/state/mod.rs | 6 +- matrix_sdk_common/src/lib.rs | 1 - matrix_sdk_crypto/src/device.rs | 7 +- matrix_sdk_crypto/src/machine.rs | 38 +++++----- matrix_sdk_crypto/src/memory_stores.rs | 6 +- matrix_sdk_crypto/src/olm/account.rs | 24 +++---- matrix_sdk_crypto/src/olm/group_sessions.rs | 35 +++++----- matrix_sdk_crypto/src/olm/session.rs | 28 ++++---- matrix_sdk_crypto/src/store/memorystore.rs | 7 +- matrix_sdk_crypto/src/store/mod.rs | 14 ++-- matrix_sdk_crypto/src/store/sqlite.rs | 16 ++--- 18 files changed, 164 insertions(+), 182 deletions(-) diff --git a/matrix_sdk/src/client.rs b/matrix_sdk/src/client.rs index 40ccf616..e619fb82 100644 --- a/matrix_sdk/src/client.rs +++ b/matrix_sdk/src/client.rs @@ -19,44 +19,37 @@ use std::{ collections::HashMap, convert::{TryFrom, TryInto}, fmt::{self, Debug}, + future::Future, path::Path, result::Result as StdResult, sync::Arc, }; +#[cfg(not(target_arch = "wasm32"))] +use crate::VERSION; +use crate::{Error, EventEmitter, Result}; +use futures_timer::Delay as sleep; +use http::{Method as HttpMethod, Response as HttpResponse}; +use matrix_sdk_base::{BaseClient, BaseClientConfig, Room, Session, StateStore}; +#[cfg(feature = "encryption")] +use matrix_sdk_common::identifiers::DeviceId; use matrix_sdk_common::{ - identifiers::ServerName, + api, + events::{room::message::MessageEventContent, EventType}, + identifiers::{EventId, RoomId, RoomIdOrAliasId, ServerName, UserId}, instant::{Duration, Instant}, js_int::UInt, locks::RwLock, presence::PresenceState, uuid::Uuid, + Endpoint, }; - -use futures_timer::Delay as sleep; -use std::future::Future; +use reqwest::header::{HeaderValue, InvalidHeaderValue, AUTHORIZATION}; #[cfg(feature = "encryption")] use tracing::{debug, warn}; use tracing::{error, info, instrument, trace}; - -use http::{Method as HttpMethod, Response as HttpResponse}; -use reqwest::header::{HeaderValue, InvalidHeaderValue, AUTHORIZATION}; use url::Url; -use crate::{ - events::{room::message::MessageEventContent, EventType}, - identifiers::{EventId, RoomId, RoomIdOrAliasId, UserId}, - Endpoint, -}; - -#[cfg(feature = "encryption")] -use crate::identifiers::DeviceId; - -#[cfg(not(target_arch = "wasm32"))] -use crate::VERSION; -use crate::{api, Error, EventEmitter, Result}; -use matrix_sdk_base::{BaseClient, BaseClientConfig, Room, Session, StateStore}; - const DEFAULT_SYNC_TIMEOUT: Duration = Duration::from_secs(30); /// An async/await enabled Matrix client. diff --git a/matrix_sdk/src/error.rs b/matrix_sdk/src/error.rs index e26fcf80..fbfdc716 100644 --- a/matrix_sdk/src/error.rs +++ b/matrix_sdk/src/error.rs @@ -14,16 +14,14 @@ //! Error conditions. -use reqwest::Error as ReqwestError; -use serde_json::Error as JsonError; -use thiserror::Error; - use matrix_sdk_base::Error as MatrixError; - -use crate::{ +use matrix_sdk_common::{ api::{r0::uiaa::UiaaResponse as UiaaError, Error as RumaClientError}, FromHttpResponseError as RumaResponseError, IntoHttpError as RumaIntoHttpError, }; +use reqwest::Error as ReqwestError; +use serde_json::Error as JsonError; +use thiserror::Error; /// Result type of the rust-sdk. pub type Result = std::result::Result; diff --git a/matrix_sdk/src/lib.rs b/matrix_sdk/src/lib.rs index f3e0e4ad..7215703e 100644 --- a/matrix_sdk/src/lib.rs +++ b/matrix_sdk/src/lib.rs @@ -42,17 +42,17 @@ pub use matrix_sdk_base::{ CustomOrRawEvent, Error as BaseError, EventEmitter, Room, RoomState, Session, StateStore, SyncRoom, }; -#[cfg(feature = "messages")] -pub use matrix_sdk_base::{MessageQueue, MessageWrapper, PossiblyRedactedExt}; -pub use matrix_sdk_common::*; -pub use reqwest::header::InvalidHeaderValue; - #[cfg(feature = "encryption")] pub use matrix_sdk_base::{Device, TrustState}; +#[cfg(feature = "messages")] +pub use matrix_sdk_base::{MessageQueue, PossiblyRedactedExt}; +pub use matrix_sdk_common::*; +pub use reqwest::header::InvalidHeaderValue; mod client; mod error; mod request_builder; + pub use client::{Client, ClientConfig, SyncSettings}; pub use error::{Error, Result}; pub use request_builder::{ diff --git a/matrix_sdk_base/src/client.rs b/matrix_sdk_base/src/client.rs index 99f60be9..9f70bdec 100644 --- a/matrix_sdk_base/src/client.rs +++ b/matrix_sdk_base/src/client.rs @@ -18,58 +18,53 @@ use std::collections::{BTreeMap, HashSet}; use std::{ collections::HashMap, fmt, + ops::Deref, path::{Path, PathBuf}, + result::Result as StdResult, sync::Arc, }; -use zeroize::Zeroizing; - -use std::result::Result as StdResult; - -use crate::{api::r0 as api, error::Result, events::presence::PresenceEvent}; -// `NonRoomEvent` is what it is aliased as -use crate::{ - event_emitter::CustomOrRawEvent, - events::{ - ignored_user_list::IgnoredUserListEvent, push_rules::PushRulesEvent, - room::member::MemberEventContent, - }, - identifiers::{RoomId, UserId}, - models::Room, - push::Ruleset, - session::Session, - state::{AllRooms, ClientState, StateStore}, - EventEmitter, -}; -use matrix_sdk_common::{ - events::{ - AnyBasicEvent, AnyStrippedStateEvent, AnySyncEphemeralRoomEvent, AnySyncMessageEvent, - AnySyncRoomEvent, AnySyncStateEvent, - }, - Raw, -}; #[cfg(feature = "encryption")] use matrix_sdk_common::locks::Mutex; -use matrix_sdk_common::locks::RwLock; -use std::ops::Deref; - #[cfg(feature = "encryption")] -use crate::api::r0::keys::{ - claim_keys::Response as KeysClaimResponse, get_keys::Response as KeysQueryResponse, - upload_keys::Response as KeysUploadResponse, DeviceKeys, KeyAlgorithm, +use matrix_sdk_common::{ + api::r0 as api, + api::r0::keys::{ + claim_keys::Response as KeysClaimResponse, get_keys::Response as KeysQueryResponse, + upload_keys::Response as KeysUploadResponse, DeviceKeys, KeyAlgorithm, + }, + api::r0::to_device::send_event_to_device, + events::room::{ + encrypted::EncryptedEventContent, message::MessageEventContent as MsgEventContent, + }, + identifiers::DeviceId, }; -#[cfg(feature = "encryption")] -use crate::api::r0::to_device::send_event_to_device; -#[cfg(feature = "encryption")] -use crate::events::room::{ - encrypted::EncryptedEventContent, message::MessageEventContent as MsgEventContent, +use matrix_sdk_common::{ + events::{ + ignored_user_list::IgnoredUserListEvent, push_rules::PushRulesEvent, + room::member::MemberEventContent, AnyBasicEvent, AnyStrippedStateEvent, + AnySyncEphemeralRoomEvent, AnySyncMessageEvent, AnySyncRoomEvent, AnySyncStateEvent, + }, + identifiers::{RoomId, UserId}, + locks::RwLock, + push::Ruleset, + Raw, }; #[cfg(feature = "encryption")] -use crate::identifiers::DeviceId; -#[cfg(not(target_arch = "wasm32"))] -use crate::JsonStore; -#[cfg(feature = "encryption")] use matrix_sdk_crypto::{CryptoStore, OlmError, OlmMachine, OneTimeKeys}; +use zeroize::Zeroizing; + +#[cfg(not(target_arch = "wasm32"))] +use crate::JsonStore; +use crate::{ + error::Result, + event_emitter::CustomOrRawEvent, + events::presence::PresenceEvent, + models::Room, + session::Session, + state::{AllRooms, ClientState, StateStore}, + EventEmitter, +}; pub type Token = String; diff --git a/matrix_sdk_base/src/models/message.rs b/matrix_sdk_base/src/models/message.rs index 29b9a582..bf3f0be2 100644 --- a/matrix_sdk_base/src/models/message.rs +++ b/matrix_sdk_base/src/models/message.rs @@ -5,11 +5,12 @@ use std::{time::SystemTime, vec::IntoIter}; -use matrix_sdk_common::identifiers::{EventId, UserId}; +use matrix_sdk_common::{ + events::AnyPossiblyRedactedSyncMessageEvent, + identifiers::{EventId, UserId}, +}; use serde::{de, ser, Serialize}; -use crate::events::AnyPossiblyRedactedSyncMessageEvent; - /// Exposes some of the field access methods found in the event held by /// `AnyPossiblyRedacted*` enums. /// diff --git a/matrix_sdk_base/src/models/room.rs b/matrix_sdk_base/src/models/room.rs index 6802f1e9..3db38be5 100644 --- a/matrix_sdk_base/src/models/room.rs +++ b/matrix_sdk_base/src/models/room.rs @@ -20,13 +20,11 @@ use std::{ convert::TryFrom, }; -use serde::{Deserialize, Serialize}; -use tracing::{debug, error, trace}; - #[cfg(feature = "messages")] -use super::message::MessageQueue; -use super::RoomMember; -use crate::{ +use matrix_sdk_common::events::{ + room::redaction::SyncRedactionEvent, AnyPossiblyRedactedSyncMessageEvent, AnySyncMessageEvent, +}; +use matrix_sdk_common::{ api::r0::sync::sync_events::{RoomSummary, UnreadNotificationsCount}, events::{ presence::{PresenceEvent, PresenceEventContent}, @@ -42,16 +40,15 @@ use crate::{ Algorithm, AnyStrippedStateEvent, AnySyncRoomEvent, AnySyncStateEvent, EventType, StrippedStateEvent, SyncStateEvent, }, + identifiers::{RoomAliasId, RoomId, UserId}, + js_int::{int, uint, Int, UInt}, }; +use serde::{Deserialize, Serialize}; +use tracing::{debug, error, trace}; #[cfg(feature = "messages")] -use crate::events::{ - room::redaction::SyncRedactionEvent, AnyPossiblyRedactedSyncMessageEvent, AnySyncMessageEvent, -}; - -use crate::identifiers::{RoomAliasId, RoomId, UserId}; - -use crate::js_int::{int, uint, Int, UInt}; +use super::message::MessageQueue; +use super::RoomMember; #[derive(Clone, Debug, Default, PartialEq, Serialize, Deserialize)] /// `RoomName` allows the calculation of a text room name. diff --git a/matrix_sdk_base/src/session.rs b/matrix_sdk_base/src/session.rs index 55b3c4bf..b240b5d0 100644 --- a/matrix_sdk_base/src/session.rs +++ b/matrix_sdk_base/src/session.rs @@ -15,7 +15,7 @@ //! User sessions. -use crate::identifiers::{DeviceId, UserId}; +use matrix_sdk_common::identifiers::{DeviceId, UserId}; /// A user session, containing an access token and information about the /// associated user account. diff --git a/matrix_sdk_base/src/state/mod.rs b/matrix_sdk_base/src/state/mod.rs index 6e7ac5a2..6d76e0b8 100644 --- a/matrix_sdk_base/src/state/mod.rs +++ b/matrix_sdk_base/src/state/mod.rs @@ -15,6 +15,10 @@ use std::collections::HashMap; +use matrix_sdk_common::{ + identifiers::{RoomId, UserId}, + push::Ruleset, +}; use serde::{Deserialize, Serialize}; #[cfg(not(target_arch = "wasm32"))] @@ -24,8 +28,6 @@ pub use json_store::JsonStore; use crate::{ client::{BaseClient, Token}, - identifiers::{RoomId, UserId}, - push::Ruleset, Result, Room, RoomState, Session, }; diff --git a/matrix_sdk_common/src/lib.rs b/matrix_sdk_common/src/lib.rs index 155c6ec4..bb478f9b 100644 --- a/matrix_sdk_common/src/lib.rs +++ b/matrix_sdk_common/src/lib.rs @@ -1,6 +1,5 @@ pub use instant; pub use js_int; - pub use ruma::{ api::{ client as api, diff --git a/matrix_sdk_crypto/src/device.rs b/matrix_sdk_crypto/src/device.rs index fe59f1d4..7aff977f 100644 --- a/matrix_sdk_crypto/src/device.rs +++ b/matrix_sdk_crypto/src/device.rs @@ -22,16 +22,15 @@ use std::{ }; use atomic::Atomic; -use serde_json::{json, Value}; - -#[cfg(test)] -use super::OlmMachine; use matrix_sdk_common::{ api::r0::keys::{AlgorithmAndDeviceId, DeviceKeys, KeyAlgorithm, SignedKey}, events::Algorithm, identifiers::{DeviceId, UserId}, }; +use serde_json::{json, Value}; +#[cfg(test)] +use super::OlmMachine; use crate::{error::SignatureError, verify_json}; /// A device represents a E2EE capable client of an user. diff --git a/matrix_sdk_crypto/src/machine.rs b/matrix_sdk_crypto/src/machine.rs index 67ba2f21..480070a6 100644 --- a/matrix_sdk_crypto/src/machine.rs +++ b/matrix_sdk_crypto/src/machine.rs @@ -21,19 +21,12 @@ use std::{ result::Result as StdResult, }; -#[cfg(feature = "sqlite-cryptostore")] -use super::store::sqlite::SqliteStore; -use super::{ - device::Device, - error::{EventError, MegolmError, MegolmResult, OlmError, OlmResult}, - olm::{ - Account, GroupSessionKey, IdentityKeys, InboundGroupSession, OlmMessage, - OutboundGroupSession, - }, - store::{memorystore::MemoryStore, Result as StoreResult}, - CryptoStore, +use api::r0::{ + keys, + keys::{AlgorithmAndDeviceId, DeviceKeys, KeyAlgorithm, OneTimeKey}, + sync::sync_events::Response as SyncResponse, + to_device::{send_event_to_device::Request as ToDeviceRequest, DeviceIdOrAllDevices}, }; - use matrix_sdk_common::{ api, events::{ @@ -47,17 +40,22 @@ use matrix_sdk_common::{ uuid::Uuid, Raw, }; - -use api::r0::{ - keys, - keys::{AlgorithmAndDeviceId, DeviceKeys, KeyAlgorithm, OneTimeKey}, - sync::sync_events::Response as SyncResponse, - to_device::{send_event_to_device::Request as ToDeviceRequest, DeviceIdOrAllDevices}, -}; - use serde_json::Value; use tracing::{debug, error, info, instrument, trace, warn}; +#[cfg(feature = "sqlite-cryptostore")] +use super::store::sqlite::SqliteStore; +use super::{ + device::Device, + error::{EventError, MegolmError, MegolmResult, OlmError, OlmResult}, + olm::{ + Account, GroupSessionKey, IdentityKeys, InboundGroupSession, OlmMessage, + OutboundGroupSession, + }, + store::{memorystore::MemoryStore, Result as StoreResult}, + CryptoStore, +}; + /// A map from the algorithm and device id to a one-time key. /// /// These keys need to be periodically uploaded to the server. diff --git a/matrix_sdk_crypto/src/memory_stores.rs b/matrix_sdk_crypto/src/memory_stores.rs index 0b465c4a..b91fbacc 100644 --- a/matrix_sdk_crypto/src/memory_stores.rs +++ b/matrix_sdk_crypto/src/memory_stores.rs @@ -15,13 +15,15 @@ use std::{collections::HashMap, sync::Arc}; use dashmap::{DashMap, ReadOnlyView}; -use matrix_sdk_common::locks::Mutex; +use matrix_sdk_common::{ + identifiers::{DeviceId, RoomId, UserId}, + locks::Mutex, +}; use super::{ device::Device, olm::{InboundGroupSession, Session}, }; -use matrix_sdk_common::identifiers::{DeviceId, RoomId, UserId}; /// In-memory store for Olm Sessions. #[derive(Debug, Default)] diff --git a/matrix_sdk_crypto/src/olm/account.rs b/matrix_sdk_crypto/src/olm/account.rs index 9fa2c17f..793fd1a1 100644 --- a/matrix_sdk_crypto/src/olm/account.rs +++ b/matrix_sdk_crypto/src/olm/account.rs @@ -12,8 +12,8 @@ // See the License for the specific language governing permissions and // limitations under the License. -use matrix_sdk_common::instant::Instant; use std::{ + collections::BTreeMap, convert::{TryFrom, TryInto}, fmt, sync::{ @@ -22,30 +22,28 @@ use std::{ }, }; -use matrix_sdk_common::locks::Mutex; -use serde_json::{json, Value}; -use std::collections::BTreeMap; - -pub use olm_rs::account::IdentityKeys; +use matrix_sdk_common::{ + api::r0::keys::{AlgorithmAndDeviceId, DeviceKeys, KeyAlgorithm, OneTimeKey, SignedKey}, + events::Algorithm, + identifiers::{DeviceId, RoomId, UserId}, + instant::Instant, + locks::Mutex, +}; use olm_rs::{ account::{OlmAccount, OneTimeKeys}, errors::{OlmAccountError, OlmSessionError}, PicklingMode, }; +use serde_json::{json, Value}; -use crate::{device::Device, error::SessionCreationError}; pub use olm_rs::{ + account::IdentityKeys, session::{OlmMessage, PreKeyMessage}, utility::OlmUtility, }; -use matrix_sdk_common::{ - api::r0::keys::{AlgorithmAndDeviceId, DeviceKeys, KeyAlgorithm, OneTimeKey, SignedKey}, - events::Algorithm, - identifiers::{DeviceId, RoomId, UserId}, -}; - use super::{InboundGroupSession, OutboundGroupSession, Session}; +use crate::{device::Device, error::SessionCreationError}; /// Account holding identity keys for which sessions can be created. /// diff --git a/matrix_sdk_crypto/src/olm/group_sessions.rs b/matrix_sdk_crypto/src/olm/group_sessions.rs index e3725d04..bbb36227 100644 --- a/matrix_sdk_crypto/src/olm/group_sessions.rs +++ b/matrix_sdk_crypto/src/olm/group_sessions.rs @@ -12,7 +12,6 @@ // See the License for the specific language governing permissions and // limitations under the License. -use matrix_sdk_common::instant::Instant; use std::{ convert::TryInto, fmt, @@ -22,31 +21,31 @@ use std::{ }, }; -use matrix_sdk_common::locks::Mutex; -use serde::Serialize; -use serde_json::{json, Value}; -use zeroize::Zeroize; - -pub use olm_rs::account::IdentityKeys; -use olm_rs::{ - errors::OlmGroupSessionError, inbound_group_session::OlmInboundGroupSession, - outbound_group_session::OlmOutboundGroupSession, PicklingMode, -}; - -use crate::error::{EventError, MegolmResult}; -pub use olm_rs::{ - session::{OlmMessage, PreKeyMessage}, - utility::OlmUtility, -}; - use matrix_sdk_common::{ events::{ room::{encrypted::EncryptedEventContent, message::MessageEventContent}, Algorithm, AnySyncRoomEvent, EventType, SyncMessageEvent, }, identifiers::{DeviceId, RoomId}, + instant::Instant, + locks::Mutex, Raw, }; +use olm_rs::{ + errors::OlmGroupSessionError, inbound_group_session::OlmInboundGroupSession, + outbound_group_session::OlmOutboundGroupSession, PicklingMode, +}; +use serde::Serialize; +use serde_json::{json, Value}; +use zeroize::Zeroize; + +pub use olm_rs::{ + account::IdentityKeys, + session::{OlmMessage, PreKeyMessage}, + utility::OlmUtility, +}; + +use crate::error::{EventError, MegolmResult}; /// The private session key of a group session. /// Can be used to create a new inbound group session. diff --git a/matrix_sdk_crypto/src/olm/session.rs b/matrix_sdk_crypto/src/olm/session.rs index eb52cebc..a1ca78b9 100644 --- a/matrix_sdk_crypto/src/olm/session.rs +++ b/matrix_sdk_crypto/src/olm/session.rs @@ -14,21 +14,6 @@ use std::{collections::BTreeMap, fmt, sync::Arc}; -use olm_rs::{errors::OlmSessionError, session::OlmSession, PicklingMode}; - -use serde_json::{json, Value}; - -pub use olm_rs::{ - session::{OlmMessage, PreKeyMessage}, - utility::OlmUtility, -}; - -use super::IdentityKeys; -use crate::{ - error::{EventError, OlmResult}, - Device, -}; - use matrix_sdk_common::{ api::r0::keys::KeyAlgorithm, events::{ @@ -39,6 +24,19 @@ use matrix_sdk_common::{ instant::Instant, locks::Mutex, }; +use olm_rs::{errors::OlmSessionError, session::OlmSession, PicklingMode}; +use serde_json::{json, Value}; + +use super::IdentityKeys; +use crate::{ + error::{EventError, OlmResult}, + Device, +}; + +pub use olm_rs::{ + session::{OlmMessage, PreKeyMessage}, + utility::OlmUtility, +}; /// Cryptographic session that enables secure communication between two /// `Account`s diff --git a/matrix_sdk_crypto/src/store/memorystore.rs b/matrix_sdk_crypto/src/store/memorystore.rs index 071c697a..77c53538 100644 --- a/matrix_sdk_crypto/src/store/memorystore.rs +++ b/matrix_sdk_crypto/src/store/memorystore.rs @@ -15,15 +15,16 @@ use std::{collections::HashSet, sync::Arc}; use async_trait::async_trait; -use matrix_sdk_common::locks::Mutex; +use matrix_sdk_common::{ + identifiers::{DeviceId, RoomId, UserId}, + locks::Mutex, +}; use super::{Account, CryptoStore, InboundGroupSession, Result, Session}; use crate::{ device::Device, memory_stores::{DeviceStore, GroupSessionStore, SessionStore, UserDevices}, }; -use matrix_sdk_common::identifiers::{DeviceId, RoomId, UserId}; - #[derive(Debug)] pub struct MemoryStore { sessions: SessionStore, diff --git a/matrix_sdk_crypto/src/store/mod.rs b/matrix_sdk_crypto/src/store/mod.rs index ab0f2a24..c45f2d17 100644 --- a/matrix_sdk_crypto/src/store/mod.rs +++ b/matrix_sdk_crypto/src/store/mod.rs @@ -12,23 +12,25 @@ // See the License for the specific language governing permissions and // limitations under the License. -use core::fmt::Debug; use std::{collections::HashSet, io::Error as IoError, sync::Arc}; -use url::ParseError; use async_trait::async_trait; -use matrix_sdk_common::locks::Mutex; +use core::fmt::Debug; +use matrix_sdk_common::{ + identifiers::{DeviceId, RoomId, UserId}, + locks::Mutex, +}; +use matrix_sdk_common_macros::send_sync; +use olm_rs::errors::{OlmAccountError, OlmGroupSessionError, OlmSessionError}; use serde_json::Error as SerdeError; use thiserror::Error; +use url::ParseError; use super::{ device::Device, memory_stores::UserDevices, olm::{Account, InboundGroupSession, Session}, }; -use matrix_sdk_common::identifiers::{DeviceId, RoomId, UserId}; -use matrix_sdk_common_macros::send_sync; -use olm_rs::errors::{OlmAccountError, OlmGroupSessionError, OlmSessionError}; pub mod memorystore; diff --git a/matrix_sdk_crypto/src/store/sqlite.rs b/matrix_sdk_crypto/src/store/sqlite.rs index 6f407be4..544fb62f 100644 --- a/matrix_sdk_crypto/src/store/sqlite.rs +++ b/matrix_sdk_crypto/src/store/sqlite.rs @@ -12,7 +12,6 @@ // See the License for the specific language governing permissions and // limitations under the License. -use matrix_sdk_common::instant::{Duration, Instant}; use std::{ collections::{BTreeMap, HashSet}, convert::TryFrom, @@ -20,12 +19,18 @@ use std::{ result::Result as StdResult, sync::Arc, }; -use url::Url; use async_trait::async_trait; -use matrix_sdk_common::locks::Mutex; +use matrix_sdk_common::{ + api::r0::keys::{AlgorithmAndDeviceId, KeyAlgorithm}, + events::Algorithm, + identifiers::{DeviceId, RoomId, UserId}, + instant::{Duration, Instant}, + locks::Mutex, +}; use olm_rs::PicklingMode; use sqlx::{query, query_as, sqlite::SqliteQueryAs, Connect, Executor, SqliteConnection}; +use url::Url; use zeroize::Zeroizing; use super::{CryptoStore, CryptoStoreError, Result}; @@ -34,11 +39,6 @@ use crate::{ memory_stores::{DeviceStore, GroupSessionStore, SessionStore, UserDevices}, Account, IdentityKeys, InboundGroupSession, Session, }; -use matrix_sdk_common::{ - api::r0::keys::{AlgorithmAndDeviceId, KeyAlgorithm}, - events::Algorithm, - identifiers::{DeviceId, RoomId, UserId}, -}; /// SQLite based implementation of a `CryptoStore`. pub struct SqliteStore { From 33e1601004a583b1c0ef2061b6030feb67631e31 Mon Sep 17 00:00:00 2001 From: Devin Ragotzy Date: Mon, 3 Aug 2020 20:13:58 -0400 Subject: [PATCH 4/4] matrix_sdk: Fix import error --- matrix_sdk_base/src/client.rs | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/matrix_sdk_base/src/client.rs b/matrix_sdk_base/src/client.rs index 9f70bdec..257a5b90 100644 --- a/matrix_sdk_base/src/client.rs +++ b/matrix_sdk_base/src/client.rs @@ -26,20 +26,8 @@ use std::{ #[cfg(feature = "encryption")] use matrix_sdk_common::locks::Mutex; -#[cfg(feature = "encryption")] use matrix_sdk_common::{ api::r0 as api, - api::r0::keys::{ - claim_keys::Response as KeysClaimResponse, get_keys::Response as KeysQueryResponse, - upload_keys::Response as KeysUploadResponse, DeviceKeys, KeyAlgorithm, - }, - api::r0::to_device::send_event_to_device, - events::room::{ - encrypted::EncryptedEventContent, message::MessageEventContent as MsgEventContent, - }, - identifiers::DeviceId, -}; -use matrix_sdk_common::{ events::{ ignored_user_list::IgnoredUserListEvent, push_rules::PushRulesEvent, room::member::MemberEventContent, AnyBasicEvent, AnyStrippedStateEvent, @@ -51,6 +39,18 @@ use matrix_sdk_common::{ Raw, }; #[cfg(feature = "encryption")] +use matrix_sdk_common::{ + api::r0::keys::{ + claim_keys::Response as KeysClaimResponse, get_keys::Response as KeysQueryResponse, + upload_keys::Response as KeysUploadResponse, DeviceKeys, KeyAlgorithm, + }, + api::r0::to_device::send_event_to_device, + events::room::{ + encrypted::EncryptedEventContent, message::MessageEventContent as MsgEventContent, + }, + identifiers::DeviceId, +}; +#[cfg(feature = "encryption")] use matrix_sdk_crypto::{CryptoStore, OlmError, OlmMachine, OneTimeKeys}; use zeroize::Zeroizing;