From c3f48c5be3160d26baf515682f7c9b1b0d30e31b Mon Sep 17 00:00:00 2001 From: Jimmy Cuadra Date: Sun, 16 Jun 2019 16:16:37 -0700 Subject: [PATCH] Use js_int types for numbers. Closes #27. --- Cargo.toml | 4 ++++ src/call/answer.rs | 3 ++- src/call/candidates.rs | 5 +++-- src/call/hangup.rs | 3 ++- src/call/invite.rs | 5 +++-- src/key/verification/request.rs | 3 ++- src/lib.rs | 3 ++- src/macros.rs | 6 +++--- src/presence.rs | 9 +++++---- src/receipt.rs | 3 ++- src/room.rs | 13 +++++++------ src/room/aliases.rs | 1 + src/room/avatar.rs | 1 + src/room/canonical_alias.rs | 4 +++- src/room/create.rs | 1 + src/room/encrypted.rs | 3 ++- src/room/encryption.rs | 5 +++-- src/room/guest_access.rs | 1 + src/room/history_visibility.rs | 1 + src/room/join_rules.rs | 1 + src/room/member.rs | 1 + src/room/message.rs | 15 ++++++++------- src/room/message/feedback.rs | 1 + src/room/name.rs | 4 +++- src/room/pinned_events.rs | 6 +++++- src/room/power_levels.rs | 25 +++++++++++++------------ src/room/redaction.rs | 1 + src/room/server_acl.rs | 1 + src/room/third_party_invite.rs | 1 + src/room/tombstone.rs | 1 + src/room/topic.rs | 1 + src/sticker.rs | 1 + src/stripped.rs | 12 ++++++++---- 33 files changed, 94 insertions(+), 51 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index b82b1e4a..dcd9566c 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -16,6 +16,10 @@ ruma-identifiers = "0.13.0" ruma-signatures = "0.4.2" serde_json = "1.0.39" +[dependencies.js_int] +version = "0.1.0" +features = ["serde"] + [dependencies.serde] version = "1.0.92" features = ["derive"] diff --git a/src/call/answer.rs b/src/call/answer.rs index 3bef8ad6..3153b128 100644 --- a/src/call/answer.rs +++ b/src/call/answer.rs @@ -1,5 +1,6 @@ //! Types for the *m.call.answer* event. +use js_int::UInt; use serde::{Deserialize, Serialize}; use super::SessionDescription; @@ -19,5 +20,5 @@ pub struct AnswerEventContent { pub call_id: String, /// The version of the VoIP specification this messages adheres to. - pub version: u64, + pub version: UInt, } diff --git a/src/call/candidates.rs b/src/call/candidates.rs index b6c47abe..5dc084f7 100644 --- a/src/call/candidates.rs +++ b/src/call/candidates.rs @@ -1,5 +1,6 @@ //! Types for the *m.call.candidates* event. +use js_int::UInt; use serde::{Deserialize, Serialize}; room_event! { @@ -19,7 +20,7 @@ pub struct CandidatesEventContent { pub candidates: Vec, /// The version of the VoIP specification this messages adheres to. - pub version: u64, + pub version: UInt, } /// An ICE (Interactive Connectivity Establishment) candidate. @@ -34,5 +35,5 @@ pub struct Candidate { /// The index of the SDP "m" line this candidate is intended for. #[serde(rename = "sdpMLineIndex")] - pub sdp_m_line_index: u64, + pub sdp_m_line_index: UInt, } diff --git a/src/call/hangup.rs b/src/call/hangup.rs index ce3fd792..0cad2923 100644 --- a/src/call/hangup.rs +++ b/src/call/hangup.rs @@ -1,5 +1,6 @@ //! Types for the *m.call.hangup* event. +use js_int::UInt; use serde::{Deserialize, Serialize}; room_event! { @@ -15,7 +16,7 @@ pub struct HangupEventContent { pub call_id: String, /// The version of the VoIP specification this messages adheres to. - pub version: u64, + pub version: UInt, /// Optional error reason for the hangup. pub reason: Option, diff --git a/src/call/invite.rs b/src/call/invite.rs index de48ccd5..ffdf8c15 100644 --- a/src/call/invite.rs +++ b/src/call/invite.rs @@ -1,5 +1,6 @@ //! Types for the *m.call.invite* event. +use js_int::UInt; use serde::{Deserialize, Serialize}; use super::SessionDescription; @@ -18,11 +19,11 @@ pub struct InviteEventContent { /// The time in milliseconds that the invite is valid for. Once the invite age exceeds this /// value, clients should discard it. They should also no longer show the call as awaiting an /// answer in the UI. - pub lifetime: u64, + pub lifetime: UInt, /// The session description object. The session description type must be *offer*. pub offer: SessionDescription, /// The version of the VoIP specification this messages adheres to. - pub version: u64, + pub version: UInt, } diff --git a/src/key/verification/request.rs b/src/key/verification/request.rs index 7d1a3a4f..513ad1fb 100644 --- a/src/key/verification/request.rs +++ b/src/key/verification/request.rs @@ -1,5 +1,6 @@ //! Types for the *m.key.verification.request* event. +use js_int::UInt; use ruma_identifiers::DeviceId; use serde::{Deserialize, Serialize}; @@ -30,5 +31,5 @@ pub struct RequestEventContent { /// /// If the request is in the future by more than 5 minutes or more than 10 minutes in the past, /// the message should be ignored by the receiver. - pub timestamp: u64, + pub timestamp: UInt, } diff --git a/src/lib.rs b/src/lib.rs index edfcb89b..e8a56f96 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -101,6 +101,7 @@ use std::fmt::{Debug, Display, Error as FmtError, Formatter, Result as FmtResult}; +use js_int::UInt; use ruma_identifiers::{EventId, RoomId, UserId}; use serde::{ de::{Error as SerdeError, IntoDeserializer, Visitor}, @@ -301,7 +302,7 @@ pub trait RoomEvent: Event { /// Timestamp (milliseconds since the UNIX epoch) on originating homeserver when this event was /// sent. - fn origin_server_ts(&self) -> u64; + fn origin_server_ts(&self) -> UInt; /// The unique identifier for the room associated with this event. /// diff --git a/src/macros.rs b/src/macros.rs index 3fb5be23..ba7a7ac9 100644 --- a/src/macros.rs +++ b/src/macros.rs @@ -93,7 +93,7 @@ macro_rules! room_event { /// Timestamp (milliseconds since the UNIX epoch) on originating homeserver when this /// event was sent. - pub origin_server_ts: u64, + pub origin_server_ts: UInt, /// The unique identifier for the room associated with this event. #[serde(skip_serializing_if="Option::is_none")] @@ -125,7 +125,7 @@ macro_rules! impl_room_event { &self.event_id } - fn origin_server_ts(&self) -> u64 { + fn origin_server_ts(&self) -> UInt { self.origin_server_ts } @@ -168,7 +168,7 @@ macro_rules! state_event { pub event_type: $crate::EventType, /// Timestamp in milliseconds on originating homeserver when this event was sent. - pub origin_server_ts: u64, + pub origin_server_ts: UInt, /// The previous content for this state key, if any. #[serde(skip_serializing_if = "Option::is_none")] diff --git a/src/presence.rs b/src/presence.rs index 73c90631..abd7a02b 100644 --- a/src/presence.rs +++ b/src/presence.rs @@ -1,8 +1,8 @@ //! Types for the *m.presence* event. -use serde::{Deserialize, Serialize}; - +use js_int::UInt; use ruma_identifiers::UserId; +use serde::{Deserialize, Serialize}; event! { /// Informs the client of a user's presence state change. @@ -29,7 +29,7 @@ pub struct PresenceEventContent { /// The last time since this user performed some action, in milliseconds. #[serde(skip_serializing_if = "Option::is_none")] - pub last_active_ago: Option, + pub last_active_ago: Option, /// The presence state for this user. pub presence: PresenceState, @@ -73,6 +73,7 @@ impl_enum! { mod tests { use std::convert::TryFrom; + use js_int::UInt; use ruma_identifiers::UserId; use serde_json::{from_str, to_string}; @@ -88,7 +89,7 @@ mod tests { avatar_url: Some("mxc://localhost:wefuiwegh8742w".to_string()), currently_active: Some(false), displayname: None, - last_active_ago: Some(2_478_593), + last_active_ago: Some(UInt::try_from(2_478_593).unwrap()), presence: PresenceState::Online, status_msg: Some("Making cupcakes".to_string()), }, diff --git a/src/receipt.rs b/src/receipt.rs index 7e2c290e..6e005b5d 100644 --- a/src/receipt.rs +++ b/src/receipt.rs @@ -2,6 +2,7 @@ use std::collections::HashMap; +use js_int::UInt; use ruma_identifiers::{EventId, RoomId, UserId}; use serde::{Deserialize, Serialize}; @@ -37,5 +38,5 @@ pub type UserReceipts = HashMap; #[derive(Clone, Debug, Deserialize, PartialEq, Serialize)] pub struct Receipt { /// The timestamp (milliseconds since the Unix epoch) when the receipt was sent. - pub ts: Option, + pub ts: Option, } diff --git a/src/room.rs b/src/room.rs index 28073a50..5b4e35a4 100644 --- a/src/room.rs +++ b/src/room.rs @@ -4,6 +4,7 @@ use std::collections::HashMap; +use js_int::UInt; use serde::{Deserialize, Serialize}; pub mod aliases; @@ -32,12 +33,12 @@ pub struct ImageInfo { /// The height of the image in pixels. #[serde(rename = "h")] #[serde(skip_serializing_if = "Option::is_none")] - pub height: Option, + pub height: Option, /// The width of the image in pixels. #[serde(rename = "w")] #[serde(skip_serializing_if = "Option::is_none")] - pub width: Option, + pub width: Option, /// The MIME type of the image, e.g. "image/png." #[serde(skip_serializing_if = "Option::is_none")] @@ -45,7 +46,7 @@ pub struct ImageInfo { /// The file size of the image in bytes. #[serde(skip_serializing_if = "Option::is_none")] - pub size: Option, + pub size: Option, /// Metadata about the image referred to in `thumbnail_url`. #[serde(skip_serializing_if = "Option::is_none")] @@ -66,12 +67,12 @@ pub struct ThumbnailInfo { /// The height of the thumbnail in pixels. #[serde(rename = "h")] #[serde(skip_serializing_if = "Option::is_none")] - pub height: Option, + pub height: Option, /// The width of the thumbnail in pixels. #[serde(rename = "w")] #[serde(skip_serializing_if = "Option::is_none")] - pub width: Option, + pub width: Option, /// The MIME type of the thumbnail, e.g. "image/png." #[serde(skip_serializing_if = "Option::is_none")] @@ -79,7 +80,7 @@ pub struct ThumbnailInfo { /// The file size of the thumbnail in bytes. #[serde(skip_serializing_if = "Option::is_none")] - pub size: Option, + pub size: Option, } /// A file sent to a room with end-to-end encryption enabled. diff --git a/src/room/aliases.rs b/src/room/aliases.rs index 505597d9..d7abeb45 100644 --- a/src/room/aliases.rs +++ b/src/room/aliases.rs @@ -1,5 +1,6 @@ //! Types for the *m.room.aliases* event. +use js_int::UInt; use ruma_identifiers::RoomAliasId; use serde::{Deserialize, Serialize}; diff --git a/src/room/avatar.rs b/src/room/avatar.rs index 4d5c9f28..b00fa7f8 100644 --- a/src/room/avatar.rs +++ b/src/room/avatar.rs @@ -1,5 +1,6 @@ //! Types for the *m.room.avatar* event. +use js_int::UInt; use serde::{Deserialize, Serialize}; use super::ImageInfo; diff --git a/src/room/canonical_alias.rs b/src/room/canonical_alias.rs index c1225a82..a57fdd5c 100644 --- a/src/room/canonical_alias.rs +++ b/src/room/canonical_alias.rs @@ -1,9 +1,11 @@ //! Types for the *m.room.canonical_alias* event. -use crate::empty_string_as_none; +use js_int::UInt; use ruma_identifiers::RoomAliasId; use serde::{Deserialize, Serialize}; +use crate::empty_string_as_none; + state_event! { /// Informs the room as to which alias is the canonical one. pub struct CanonicalAliasEvent(CanonicalAliasEventContent) {} diff --git a/src/room/create.rs b/src/room/create.rs index 0e256952..0a5acd55 100644 --- a/src/room/create.rs +++ b/src/room/create.rs @@ -2,6 +2,7 @@ use std::convert::TryFrom; +use js_int::UInt; use ruma_identifiers::{EventId, RoomId, RoomVersionId, UserId}; use serde::{Deserialize, Serialize}; diff --git a/src/room/encrypted.rs b/src/room/encrypted.rs index 9b340e68..6fe007cb 100644 --- a/src/room/encrypted.rs +++ b/src/room/encrypted.rs @@ -1,5 +1,6 @@ //! Types for the *m.room.encrypted* event. +use js_int::UInt; use ruma_identifiers::DeviceId; use serde::{de::Error, Deserialize, Deserializer, Serialize, Serializer}; use serde_json::{from_value, Value}; @@ -52,7 +53,7 @@ pub struct CiphertextInfo { /// The Olm message type. #[serde(rename = "type")] - pub message_type: u64, + pub message_type: UInt, } /// The payload of an *m.room.encrypted* event using the *m.megolm.v1.aes-sha2* algorithm. diff --git a/src/room/encryption.rs b/src/room/encryption.rs index 2a39ebdf..2adcaa2c 100644 --- a/src/room/encryption.rs +++ b/src/room/encryption.rs @@ -1,5 +1,6 @@ //! Types for the *m.room.encryption* event. +use js_int::UInt; use serde::{Deserialize, Serialize}; use crate::Algorithm; @@ -20,10 +21,10 @@ pub struct EncryptionEventContent { /// How long the session should be used before changing it. /// /// 604800000 (a week) is the recommended default. - pub rotation_period_ms: Option, + pub rotation_period_ms: Option, /// How many messages should be sent before changing the session. /// /// 100 is the recommended default. - pub rotation_period_msgs: Option, + pub rotation_period_msgs: Option, } diff --git a/src/room/guest_access.rs b/src/room/guest_access.rs index 72466230..05cf9ac5 100644 --- a/src/room/guest_access.rs +++ b/src/room/guest_access.rs @@ -1,5 +1,6 @@ //! Types for the *m.room.guest_access* event. +use js_int::UInt; use serde::{Deserialize, Serialize}; state_event! { diff --git a/src/room/history_visibility.rs b/src/room/history_visibility.rs index 3f7f7658..93aca95c 100644 --- a/src/room/history_visibility.rs +++ b/src/room/history_visibility.rs @@ -1,5 +1,6 @@ //! Types for the *m.room.history_visibility* event. +use js_int::UInt; use serde::{Deserialize, Serialize}; state_event! { diff --git a/src/room/join_rules.rs b/src/room/join_rules.rs index 4c324b37..a736a72b 100644 --- a/src/room/join_rules.rs +++ b/src/room/join_rules.rs @@ -1,5 +1,6 @@ //! Types for the *m.room.join_rules* event. +use js_int::UInt; use serde::{Deserialize, Serialize}; state_event! { diff --git a/src/room/member.rs b/src/room/member.rs index 061848a6..141121a7 100644 --- a/src/room/member.rs +++ b/src/room/member.rs @@ -1,5 +1,6 @@ //! Types for the *m.room.member* event. +use js_int::UInt; use ruma_identifiers::UserId; use ruma_signatures::Signatures; use serde::{Deserialize, Serialize}; diff --git a/src/room/message.rs b/src/room/message.rs index 10024ca9..5542287e 100644 --- a/src/room/message.rs +++ b/src/room/message.rs @@ -1,5 +1,6 @@ //! Types for the *m.room.message* event. +use js_int::UInt; use ruma_identifiers::EventId; use serde::{de::Error, Deserialize, Deserializer, Serialize, Serializer}; use serde_json::{from_value, Value}; @@ -119,7 +120,7 @@ pub struct AudioMessageEventContent { pub struct AudioInfo { /// The duration of the audio in milliseconds. #[serde(skip_serializing_if = "Option::is_none")] - pub duration: Option, + pub duration: Option, /// The mimetype of the audio, e.g. "audio/aac." #[serde(skip_serializing_if = "Option::is_none")] @@ -127,7 +128,7 @@ pub struct AudioInfo { /// The size of the audio clip in bytes. #[serde(skip_serializing_if = "Option::is_none")] - pub size: Option, + pub size: Option, } /// The payload of an emote message. @@ -184,7 +185,7 @@ pub struct FileInfo { pub mimetype: Option, /// The size of the file in bytes. - pub size: Option, + pub size: Option, /// Metadata about the image referred to in `thumbnail_url`. #[serde(skip_serializing_if = "Option::is_none")] @@ -369,17 +370,17 @@ pub struct VideoMessageEventContent { pub struct VideoInfo { /// The duration of the video in milliseconds. #[serde(skip_serializing_if = "Option::is_none")] - pub duration: Option, + pub duration: Option, /// The height of the video in pixels. #[serde(rename = "h")] #[serde(skip_serializing_if = "Option::is_none")] - pub height: Option, + pub height: Option, /// The width of the video in pixels. #[serde(rename = "w")] #[serde(skip_serializing_if = "Option::is_none")] - pub width: Option, + pub width: Option, /// The mimetype of the video, e.g. "video/mp4." #[serde(skip_serializing_if = "Option::is_none")] @@ -387,7 +388,7 @@ pub struct VideoInfo { /// The size of the video in bytes. #[serde(skip_serializing_if = "Option::is_none")] - pub size: Option, + pub size: Option, /// Metadata about an image. #[serde(skip_serializing_if = "Option::is_none")] diff --git a/src/room/message/feedback.rs b/src/room/message/feedback.rs index 6d6e8a75..9849cd86 100644 --- a/src/room/message/feedback.rs +++ b/src/room/message/feedback.rs @@ -1,5 +1,6 @@ //! Types for the *m.room.message.feedback* event. +use js_int::UInt; use ruma_identifiers::EventId; use serde::{Deserialize, Serialize}; diff --git a/src/room/name.rs b/src/room/name.rs index 4563e908..c14be263 100644 --- a/src/room/name.rs +++ b/src/room/name.rs @@ -1,8 +1,10 @@ //! Types for the *m.room.name* event. -use crate::empty_string_as_none; +use js_int::UInt; use serde::{Deserialize, Serialize}; +use crate::empty_string_as_none; + state_event! { /// A human-friendly room name designed to be displayed to the end-user. pub struct NameEvent(NameEventContent) {} diff --git a/src/room/pinned_events.rs b/src/room/pinned_events.rs index 77104aae..c36b6352 100644 --- a/src/room/pinned_events.rs +++ b/src/room/pinned_events.rs @@ -1,5 +1,6 @@ //! Types for the *m.room.pinned_events* event. +use js_int::UInt; use ruma_identifiers::EventId; use serde::{Deserialize, Serialize}; @@ -17,6 +18,9 @@ pub struct PinnedEventsContent { #[cfg(test)] mod tests { + use std::convert::TryFrom; + + use js_int::UInt; use ruma_identifiers::{EventId, RoomId, UserId}; use serde_json::{from_str, to_string}; @@ -36,7 +40,7 @@ mod tests { content: content.clone(), event_id: EventId::new("example.com").unwrap(), event_type: EventType::RoomPinnedEvents, - origin_server_ts: 1_432_804_485_886, + origin_server_ts: UInt::try_from(1_432_804_485_886u64).unwrap(), prev_content: None, room_id: Some(RoomId::new("example.com").unwrap()), sender: UserId::new("example.com").unwrap(), diff --git a/src/room/power_levels.rs b/src/room/power_levels.rs index a61d4d7b..7405fd5a 100644 --- a/src/room/power_levels.rs +++ b/src/room/power_levels.rs @@ -2,6 +2,7 @@ use std::collections::HashMap; +use js_int::{Int, UInt}; use ruma_identifiers::UserId; use serde::{Deserialize, Serialize}; @@ -17,41 +18,41 @@ state_event! { pub struct PowerLevelsEventContent { /// The level required to ban a user. #[serde(default = "default_power_level")] - pub ban: u64, + pub ban: Int, /// The level required to send specific event types. /// /// This is a mapping from event type to power level required. - pub events: HashMap, + pub events: HashMap, /// The default level required to send message events. #[serde(default)] - pub events_default: u64, + pub events_default: Int, /// The level required to invite a user. #[serde(default = "default_power_level")] - pub invite: u64, + pub invite: Int, /// The level required to kick a user. #[serde(default = "default_power_level")] - pub kick: u64, + pub kick: Int, /// The level required to redact an event. #[serde(default = "default_power_level")] - pub redact: u64, + pub redact: Int, /// The default level required to send state events. #[serde(default = "default_power_level")] - pub state_default: u64, + pub state_default: Int, /// The power levels for specific users. /// /// This is a mapping from `user_id` to power level for that user. - pub users: HashMap, + pub users: HashMap, /// The default power level for every user in the room. #[serde(default)] - pub users_default: u64, + pub users_default: Int, /// The power level requirements for specific notification types. /// @@ -64,10 +65,10 @@ pub struct PowerLevelsEventContent { pub struct NotificationPowerLevels { /// The level required to trigger an `@room` notification. #[serde(default = "default_power_level")] - pub room: u64, + pub room: Int, } /// Used to default power levels to 50 during deserialization. -fn default_power_level() -> u64 { - 50 +fn default_power_level() -> Int { + Int::from(50) } diff --git a/src/room/redaction.rs b/src/room/redaction.rs index acd78bd4..31306bf2 100644 --- a/src/room/redaction.rs +++ b/src/room/redaction.rs @@ -1,5 +1,6 @@ //! Types for the *m.room.redaction* event. +use js_int::UInt; use ruma_identifiers::EventId; use serde::{Deserialize, Serialize}; diff --git a/src/room/server_acl.rs b/src/room/server_acl.rs index f46fca96..3c985863 100644 --- a/src/room/server_acl.rs +++ b/src/room/server_acl.rs @@ -1,5 +1,6 @@ //! Types for the *m.room.server_acl* event. +use js_int::UInt; use serde::{Deserialize, Serialize}; use crate::default_true; diff --git a/src/room/third_party_invite.rs b/src/room/third_party_invite.rs index 5f0bd30b..675ab44b 100644 --- a/src/room/third_party_invite.rs +++ b/src/room/third_party_invite.rs @@ -1,5 +1,6 @@ //! Types for the *m.room.third_party_invite* event. +use js_int::UInt; use serde::{Deserialize, Serialize}; state_event! { diff --git a/src/room/tombstone.rs b/src/room/tombstone.rs index 0ed92d1c..a1a1c7c4 100644 --- a/src/room/tombstone.rs +++ b/src/room/tombstone.rs @@ -1,5 +1,6 @@ //! Types for the *m.room.tombstone* event. +use js_int::UInt; use ruma_identifiers::RoomId; use serde::{Deserialize, Serialize}; diff --git a/src/room/topic.rs b/src/room/topic.rs index 124f15e6..39475408 100644 --- a/src/room/topic.rs +++ b/src/room/topic.rs @@ -1,5 +1,6 @@ //! Types for the *m.room.topic* event. +use js_int::UInt; use serde::{Deserialize, Serialize}; state_event! { diff --git a/src/sticker.rs b/src/sticker.rs index 69128e06..b52763e3 100644 --- a/src/sticker.rs +++ b/src/sticker.rs @@ -1,5 +1,6 @@ //! Types for the *m.sticker* event. +use js_int::UInt; use serde::{Deserialize, Serialize}; use crate::room::ImageInfo; diff --git a/src/stripped.rs b/src/stripped.rs index 419b0f78..c4292bcc 100644 --- a/src/stripped.rs +++ b/src/stripped.rs @@ -260,6 +260,7 @@ pub type StrippedRoomTopic = StrippedStateContent; mod tests { use std::convert::TryFrom; + use js_int::UInt; use ruma_identifiers::UserId; use serde_json::{from_str, to_string}; @@ -361,11 +362,14 @@ mod tests { StrippedState::RoomAvatar(event) => { let image_info = event.content.info.unwrap(); - assert_eq!(image_info.height.unwrap(), 128); - assert_eq!(image_info.width.unwrap(), 128); + 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.mimetype.unwrap(), "image/jpeg"); - assert_eq!(image_info.size.unwrap(), 1024); - assert_eq!(image_info.thumbnail_info.unwrap().size.unwrap(), 32); + 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!(event.content.url, "https://domain.com/image.jpg"); assert_eq!(event.event_type, EventType::RoomAvatar); assert_eq!(event.state_key, "");