diff --git a/ruma-client-api/src/r0/context/get_context.rs b/ruma-client-api/src/r0/context/get_context.rs index ed23862f..0b476c90 100644 --- a/ruma-client-api/src/r0/context/get_context.rs +++ b/ruma-client-api/src/r0/context/get_context.rs @@ -1,6 +1,6 @@ //! [GET /_matrix/client/r0/rooms/{roomId}/context/{eventId}](https://matrix.org/docs/spec/client_server/r0.6.0#get-matrix-client-r0-rooms-roomid-context-eventid) -use js_int::UInt; +use js_int::{uint, UInt}; use ruma_api::ruma_api; use ruma_events::{AnyRoomEvent, AnyStateEvent, EventJson}; use ruma_identifiers::{EventId, RoomId}; @@ -75,7 +75,7 @@ ruma_api! { } fn default_limit() -> UInt { - UInt::from(10u32) + uint!(10) } #[allow(clippy::trivially_copy_pass_by_ref)] diff --git a/ruma-client-api/src/r0/message/get_message_events.rs b/ruma-client-api/src/r0/message/get_message_events.rs index c2a536ac..9779a8df 100644 --- a/ruma-client-api/src/r0/message/get_message_events.rs +++ b/ruma-client-api/src/r0/message/get_message_events.rs @@ -1,6 +1,6 @@ //! [GET /_matrix/client/r0/rooms/{roomId}/messages](https://matrix.org/docs/spec/client_server/r0.6.0#get-matrix-client-r0-rooms-roomid-messages) -use js_int::UInt; +use js_int::{uint, UInt}; use ruma_api::ruma_api; use ruma_events::{AnyRoomEvent, AnyStateEvent, EventJson}; use ruma_identifiers::RoomId; @@ -83,7 +83,7 @@ ruma_api! { } fn default_limit() -> UInt { - UInt::from(10u32) + uint!(10) } #[allow(clippy::trivially_copy_pass_by_ref)] @@ -109,7 +109,7 @@ mod tests { use std::convert::{TryFrom, TryInto}; - use js_int::UInt; + use js_int::uint; use ruma_identifiers::RoomId; use crate::r0::filter::{LazyLoadOptions, RoomEventFilter}; @@ -129,7 +129,7 @@ mod tests { from: "token".into(), to: Some("token2".into()), dir: Direction::Backward, - limit: UInt::from(0u32), + limit: uint!(0), filter: Some(filter), }; @@ -148,7 +148,7 @@ mod tests { from: "token".into(), to: Some("token2".into()), dir: Direction::Backward, - limit: UInt::from(0u32), + limit: uint!(0), filter: None, }; @@ -164,7 +164,7 @@ mod tests { from: "token".into(), to: Some("token2".into()), dir: Direction::Backward, - limit: UInt::from(0u32), + limit: uint!(0), filter: Some(RoomEventFilter::default()), }; diff --git a/ruma-client-api/src/r0/search/search_events.rs b/ruma-client-api/src/r0/search/search_events.rs index 6e5e3db4..988dd157 100644 --- a/ruma-client-api/src/r0/search/search_events.rs +++ b/ruma-client-api/src/r0/search/search_events.rs @@ -2,7 +2,7 @@ use std::collections::BTreeMap; -use js_int::UInt; +use js_int::{uint, UInt}; use ruma_api::ruma_api; use ruma_events::{AnyEvent, AnyStateEvent, EventJson}; use ruma_identifiers::{EventId, RoomId, UserId}; @@ -102,7 +102,7 @@ pub struct EventContext { } fn default_event_context_limit() -> UInt { - UInt::from(5u32) + uint!(5) } #[allow(clippy::trivially_copy_pass_by_ref)] diff --git a/ruma-events/src/presence.rs b/ruma-events/src/presence.rs index fa36e754..a283084f 100644 --- a/ruma-events/src/presence.rs +++ b/ruma-events/src/presence.rs @@ -55,7 +55,7 @@ pub struct PresenceEventContent { mod tests { use std::convert::TryFrom; - use js_int::UInt; + use js_int::uint; use matches::assert_matches; use ruma_identifiers::UserId; use serde_json::{from_value as from_json_value, json, to_value as to_json_value}; @@ -69,7 +69,7 @@ mod tests { avatar_url: Some("mxc://localhost:wefuiwegh8742w".to_string()), currently_active: Some(false), displayname: None, - last_active_ago: Some(UInt::try_from(2_478_593).unwrap()), + last_active_ago: Some(uint!(2_478_593)), presence: PresenceState::Online, status_msg: Some("Making cupcakes".to_string()), }, @@ -120,7 +120,7 @@ mod tests { } if avatar_url == "mxc://localhost:wefuiwegh8742w" && status_msg == "Making cupcakes" && sender == "@example:localhost" - && last_active_ago == UInt::from(2_478_593u32) + && last_active_ago == uint!(2_478_593) ); } } diff --git a/ruma-events/tests/stripped.rs b/ruma-events/tests/stripped.rs index 353bb1b9..e98eb71d 100644 --- a/ruma-events/tests/stripped.rs +++ b/ruma-events/tests/stripped.rs @@ -1,6 +1,6 @@ use std::convert::TryFrom; -use js_int::UInt; +use js_int::uint; use ruma_events::{ room::{join_rules::JoinRule, topic::TopicEventContent}, AnyStateEventContent, AnyStrippedStateEventStub, @@ -100,14 +100,11 @@ fn deserialize_stripped_state_events() { AnyStateEventContent::RoomAvatar(content) => { let image_info = content.info.unwrap(); - assert_eq!(image_info.height.unwrap(), UInt::try_from(128).unwrap()); - assert_eq!(image_info.width.unwrap(), UInt::try_from(128).unwrap()); + assert_eq!(image_info.height.unwrap(), uint!(128)); + assert_eq!(image_info.width.unwrap(), uint!(128)); assert_eq!(image_info.mimetype.unwrap(), "image/jpeg"); - assert_eq!(image_info.size.unwrap(), UInt::try_from(1024).unwrap()); - assert_eq!( - image_info.thumbnail_info.unwrap().size.unwrap(), - UInt::try_from(32).unwrap() - ); + assert_eq!(image_info.size.unwrap(), uint!(1024)); + assert_eq!(image_info.thumbnail_info.unwrap().size.unwrap(), uint!(32)); assert_eq!(content.url, "https://example.com/image.jpg"); assert_eq!(event.state_key, ""); assert_eq!(event.sender.to_string(), "@example:localhost");