common: Use the re-exported versions of js_int and assign

master
Damir Jelić 2021-01-04 15:29:49 +01:00
parent de51291166
commit 2e3b6fba7d
8 changed files with 17 additions and 29 deletions

View File

@ -98,11 +98,10 @@ use matrix_sdk_common::{
}, },
identifiers::{DeviceIdBox, EventId, RoomId, RoomIdOrAliasId, ServerName, UserId}, identifiers::{DeviceIdBox, EventId, RoomId, RoomIdOrAliasId, ServerName, UserId},
instant::{Duration, Instant}, instant::{Duration, Instant},
js_int::UInt,
locks::RwLock, locks::RwLock,
presence::PresenceState, presence::PresenceState,
uuid::Uuid, uuid::Uuid,
FromHttpResponseError, FromHttpResponseError, UInt,
}; };
#[cfg(feature = "encryption")] #[cfg(feature = "encryption")]
@ -1001,7 +1000,6 @@ impl Client {
/// # use matrix_sdk::api::r0::filter::RoomEventFilter; /// # use matrix_sdk::api::r0::filter::RoomEventFilter;
/// # use matrix_sdk::api::r0::message::get_message_events::Request as MessagesRequest; /// # use matrix_sdk::api::r0::message::get_message_events::Request as MessagesRequest;
/// # use url::Url; /// # use url::Url;
/// # use matrix_sdk::js_int::UInt;
/// ///
/// # let homeserver = Url::parse("http://example.com").unwrap(); /// # let homeserver = Url::parse("http://example.com").unwrap();
/// let room_id = room_id!("!roomid:example.com"); /// let room_id = room_id!("!roomid:example.com");

View File

@ -48,7 +48,7 @@ use matrix_sdk_common::{
SyncStateEvent, SyncStateEvent,
}, },
identifiers::{EventEncryptionAlgorithm, RoomAliasId, RoomId, UserId}, identifiers::{EventEncryptionAlgorithm, RoomAliasId, RoomId, UserId},
js_int::{int, uint, Int, UInt}, int, uint, Int, UInt,
}; };
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
use tracing::{debug, error, trace}; use tracing::{debug, error, trace};
@ -1140,7 +1140,7 @@ mod test {
identifiers::{event_id, room_id, user_id, UserId}, identifiers::{event_id, room_id, user_id, UserId},
BaseClient, Session, 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 matrix_sdk_test::{async_test, sync_response, EventBuilder, EventsJson, SyncResponseFile};
use std::{ops::Deref, time::SystemTime}; use std::{ops::Deref, time::SystemTime};
@ -1609,12 +1609,9 @@ mod test {
assert_eq!(room.joined_members.len(), 1); assert_eq!(room.joined_members.len(), 1);
assert!(room.power_levels.is_some()); assert!(room.power_levels.is_some());
assert_eq!( assert_eq!(room.power_levels.as_ref().unwrap().kick, int!(50));
room.power_levels.as_ref().unwrap().kick,
crate::js_int::int!(50)
);
let admin = room.joined_members.get(&user_id).unwrap(); 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] #[async_test]
@ -1816,8 +1813,8 @@ mod test {
*content *content
.users .users
.entry(user_id.clone()) .entry(user_id.clone())
.or_insert_with(|| js_int::Int::new(4503599627370495).unwrap()) = .or_insert_with(|| Int::new(4503599627370495).unwrap()) =
js_int::Int::new(4503599627370495).unwrap(); Int::new(4503599627370495).unwrap();
let power = SyncStateEvent { let power = SyncStateEvent {
event_id: event_id!("$h29iv0s8:example.com"), event_id: event_id!("$h29iv0s8:example.com"),
origin_server_ts: SystemTime::now(), origin_server_ts: SystemTime::now(),
@ -1831,8 +1828,8 @@ mod test {
Room::update_member_power( Room::update_member_power(
&mut room_member, &mut room_member,
&power, &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)))
} }
} }

View File

@ -18,8 +18,8 @@ use std::convert::TryFrom;
use matrix_sdk_common::{ use matrix_sdk_common::{
events::{presence::PresenceEvent, room::member::MemberEventContent, SyncStateEvent}, events::{presence::PresenceEvent, room::member::MemberEventContent, SyncStateEvent},
identifiers::{RoomId, UserId}, identifiers::{RoomId, UserId},
js_int::{Int, UInt},
presence::PresenceState, presence::PresenceState,
Int, UInt,
}; };
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
@ -164,8 +164,7 @@ mod test {
use crate::{ use crate::{
identifiers::{room_id, user_id, RoomId}, identifiers::{room_id, user_id, RoomId},
js_int::int, int, BaseClient, Session,
BaseClient, Session,
}; };
#[cfg(target_arch = "wasm32")] #[cfg(target_arch = "wasm32")]

View File

@ -14,7 +14,6 @@ version = "0.1.0"
unstable-synapse-quirks = ["ruma/unstable-synapse-quirks"] unstable-synapse-quirks = ["ruma/unstable-synapse-quirks"]
[dependencies] [dependencies]
assign = "1.1.0"
instant = { version = "0.1.7", features = ["wasm-bindgen", "now"] } instant = { version = "0.1.7", features = ["wasm-bindgen", "now"] }
[dependencies.ruma] [dependencies.ruma]

View File

@ -1,4 +1,3 @@
pub use assign::assign;
pub use instant; pub use instant;
pub use ruma::{ pub use ruma::{
api::{ api::{
@ -6,11 +5,9 @@ pub use ruma::{
error::{FromHttpRequestError, FromHttpResponseError, IntoHttpError, ServerError}, error::{FromHttpRequestError, FromHttpResponseError, IntoHttpError, ServerError},
AuthScheme, EndpointError, OutgoingRequest, AuthScheme, EndpointError, OutgoingRequest,
}, },
directory, encryption, events, assign, directory, encryption, events, identifiers, int, presence, push,
events::exports::js_int,
identifiers, presence, push,
serde::{CanonicalJsonValue, Raw}, serde::{CanonicalJsonValue, Raw},
thirdparty, Outgoing, thirdparty, uint, Int, Outgoing, UInt,
}; };
pub use uuid; pub use uuid;

View File

@ -38,10 +38,9 @@ use matrix_sdk_common::{
identifiers::{ identifiers::{
DeviceId, DeviceIdBox, DeviceKeyAlgorithm, EventEncryptionAlgorithm, RoomId, UserId, DeviceId, DeviceIdBox, DeviceKeyAlgorithm, EventEncryptionAlgorithm, RoomId, UserId,
}, },
js_int::UInt,
locks::Mutex, locks::Mutex,
uuid::Uuid, uuid::Uuid,
Raw, Raw, UInt,
}; };
#[cfg(feature = "sqlite_cryptostore")] #[cfg(feature = "sqlite_cryptostore")]
@ -1186,7 +1185,7 @@ pub(crate) mod test {
/// These keys need to be periodically uploaded to the server. /// These keys need to be periodically uploaded to the server.
type OneTimeKeys = BTreeMap<DeviceKeyId, OneTimeKey>; type OneTimeKeys = BTreeMap<DeviceKeyId, OneTimeKey>;
use matrix_sdk_common::js_int::uint; use matrix_sdk_common::uint;
fn alice_id() -> UserId { fn alice_id() -> UserId {
user_id!("@alice:example.org") user_id!("@alice:example.org")

View File

@ -41,9 +41,8 @@ use matrix_sdk_common::{
UserId, UserId,
}, },
instant::Instant, instant::Instant,
js_int::UInt,
locks::Mutex, locks::Mutex,
CanonicalJsonValue, Raw, CanonicalJsonValue, Raw, UInt,
}; };
use olm_rs::{ use olm_rs::{
account::{IdentityKeys, OlmAccount, OneTimeKeys}, account::{IdentityKeys, OlmAccount, OneTimeKeys},

View File

@ -399,7 +399,7 @@ mod test {
use matrix_sdk_common::{ use matrix_sdk_common::{
events::room::encryption::EncryptionEventContent, identifiers::EventEncryptionAlgorithm, events::room::encryption::EncryptionEventContent, identifiers::EventEncryptionAlgorithm,
js_int::uint, uint,
}; };
use super::{EncryptionSettings, ROTATION_MESSAGES, ROTATION_PERIOD}; use super::{EncryptionSettings, ROTATION_MESSAGES, ROTATION_PERIOD};