From 2e3b6fba7dbd9580554cc78966b740b9689ae9d0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Damir=20Jeli=C4=87?= Date: Mon, 4 Jan 2021 15:29:49 +0100 Subject: [PATCH] common: Use the re-exported versions of js_int and assign --- matrix_sdk/src/client.rs | 4 +--- matrix_sdk_base/src/models/room.rs | 19 ++++++++----------- matrix_sdk_base/src/models/room_member.rs | 5 ++--- matrix_sdk_common/Cargo.toml | 1 - matrix_sdk_common/src/lib.rs | 7 ++----- matrix_sdk_crypto/src/machine.rs | 5 ++--- matrix_sdk_crypto/src/olm/account.rs | 3 +-- .../src/olm/group_sessions/outbound.rs | 2 +- 8 files changed, 17 insertions(+), 29 deletions(-) diff --git a/matrix_sdk/src/client.rs b/matrix_sdk/src/client.rs index e199e2df..d7af467a 100644 --- a/matrix_sdk/src/client.rs +++ b/matrix_sdk/src/client.rs @@ -98,11 +98,10 @@ use matrix_sdk_common::{ }, identifiers::{DeviceIdBox, EventId, RoomId, RoomIdOrAliasId, ServerName, UserId}, instant::{Duration, Instant}, - js_int::UInt, locks::RwLock, presence::PresenceState, uuid::Uuid, - FromHttpResponseError, + FromHttpResponseError, UInt, }; #[cfg(feature = "encryption")] @@ -1001,7 +1000,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_base/src/models/room.rs b/matrix_sdk_base/src/models/room.rs index 0b65abcb..358ddd16 100644 --- a/matrix_sdk_base/src/models/room.rs +++ b/matrix_sdk_base/src/models/room.rs @@ -48,7 +48,7 @@ use matrix_sdk_common::{ SyncStateEvent, }, identifiers::{EventEncryptionAlgorithm, RoomAliasId, RoomId, UserId}, - js_int::{int, uint, Int, UInt}, + int, uint, Int, UInt, }; use serde::{Deserialize, Serialize}; use tracing::{debug, error, trace}; @@ -1140,7 +1140,7 @@ mod test { identifiers::{event_id, room_id, user_id, UserId}, BaseClient, Session, }; - use matrix_sdk_common::js_int; + use matrix_sdk_common::{int, Int}; use matrix_sdk_test::{async_test, sync_response, EventBuilder, EventsJson, SyncResponseFile}; use std::{ops::Deref, time::SystemTime}; @@ -1609,12 +1609,9 @@ mod test { assert_eq!(room.joined_members.len(), 1); assert!(room.power_levels.is_some()); - assert_eq!( - room.power_levels.as_ref().unwrap().kick, - crate::js_int::int!(50) - ); + assert_eq!(room.power_levels.as_ref().unwrap().kick, int!(50)); let admin = room.joined_members.get(&user_id).unwrap(); - assert_eq!(admin.power_level.unwrap(), crate::js_int::int!(100)); + assert_eq!(admin.power_level.unwrap(), int!(100)); } #[async_test] @@ -1816,8 +1813,8 @@ mod test { *content .users .entry(user_id.clone()) - .or_insert_with(|| js_int::Int::new(4503599627370495).unwrap()) = - js_int::Int::new(4503599627370495).unwrap(); + .or_insert_with(|| Int::new(4503599627370495).unwrap()) = + Int::new(4503599627370495).unwrap(); let power = SyncStateEvent { event_id: event_id!("$h29iv0s8:example.com"), origin_server_ts: SystemTime::now(), @@ -1831,8 +1828,8 @@ mod test { Room::update_member_power( &mut room_member, &power, - js_int::Int::new(4503599627370495).unwrap(), + Int::new(4503599627370495).unwrap(), ); - assert_eq!(room_member.power_level_norm, Some(js_int::int!(100))) + assert_eq!(room_member.power_level_norm, Some(int!(100))) } } diff --git a/matrix_sdk_base/src/models/room_member.rs b/matrix_sdk_base/src/models/room_member.rs index 393d54ac..2885fbee 100644 --- a/matrix_sdk_base/src/models/room_member.rs +++ b/matrix_sdk_base/src/models/room_member.rs @@ -18,8 +18,8 @@ use std::convert::TryFrom; use matrix_sdk_common::{ events::{presence::PresenceEvent, room::member::MemberEventContent, SyncStateEvent}, identifiers::{RoomId, UserId}, - js_int::{Int, UInt}, presence::PresenceState, + Int, UInt, }; use serde::{Deserialize, Serialize}; @@ -164,8 +164,7 @@ mod test { use crate::{ identifiers::{room_id, user_id, RoomId}, - js_int::int, - BaseClient, Session, + int, BaseClient, Session, }; #[cfg(target_arch = "wasm32")] diff --git a/matrix_sdk_common/Cargo.toml b/matrix_sdk_common/Cargo.toml index 03d314c0..4ee1644f 100644 --- a/matrix_sdk_common/Cargo.toml +++ b/matrix_sdk_common/Cargo.toml @@ -14,7 +14,6 @@ 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"] } [dependencies.ruma] diff --git a/matrix_sdk_common/src/lib.rs b/matrix_sdk_common/src/lib.rs index c7a83c90..daa9d9e0 100644 --- a/matrix_sdk_common/src/lib.rs +++ b/matrix_sdk_common/src/lib.rs @@ -1,4 +1,3 @@ -pub use assign::assign; pub use instant; pub use ruma::{ api::{ @@ -6,11 +5,9 @@ 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; diff --git a/matrix_sdk_crypto/src/machine.rs b/matrix_sdk_crypto/src/machine.rs index 2cdab741..69aa3456 100644 --- a/matrix_sdk_crypto/src/machine.rs +++ b/matrix_sdk_crypto/src/machine.rs @@ -38,10 +38,9 @@ use matrix_sdk_common::{ identifiers::{ DeviceId, DeviceIdBox, DeviceKeyAlgorithm, EventEncryptionAlgorithm, RoomId, UserId, }, - js_int::UInt, locks::Mutex, uuid::Uuid, - Raw, + Raw, UInt, }; #[cfg(feature = "sqlite_cryptostore")] @@ -1186,7 +1185,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 adecc4e1..7d3cc190 100644 --- a/matrix_sdk_crypto/src/olm/group_sessions/outbound.rs +++ b/matrix_sdk_crypto/src/olm/group_sessions/outbound.rs @@ -399,7 +399,7 @@ mod test { use matrix_sdk_common::{ events::room::encryption::EncryptionEventContent, identifiers::EventEncryptionAlgorithm, - js_int::uint, + uint, }; use super::{EncryptionSettings, ROTATION_MESSAGES, ROTATION_PERIOD};