From 4014e6959ffbb2c4445338d213d73d9abe3f2c1c Mon Sep 17 00:00:00 2001 From: Jonas Platte Date: Mon, 25 Apr 2022 15:16:55 +0200 Subject: [PATCH] Replace Box with OwnedMxcUri --- crates/ruma-client-api/src/media/create_content.rs | 6 +++--- crates/ruma-client-api/src/membership/joined_members.rs | 4 ++-- crates/ruma-client-api/src/profile/get_avatar_url.rs | 6 +++--- crates/ruma-client-api/src/profile/get_profile.rs | 6 +++--- crates/ruma-client-api/src/search/search_events.rs | 4 ++-- crates/ruma-client-api/src/session/get_login_types.rs | 4 ++-- crates/ruma-client-api/src/space.rs | 4 ++-- crates/ruma-client-api/src/user_directory/search_users.rs | 4 ++-- crates/ruma-common/src/directory.rs | 4 ++-- crates/ruma-common/src/events/room/avatar.rs | 6 +++--- crates/ruma-common/src/events/room/member.rs | 5 +++-- crates/ruma-common/src/identifiers/mxc_uri.rs | 4 ++-- .../src/query/get_profile_information.rs | 4 ++-- crates/ruma-federation-api/src/space.rs | 6 +++--- 14 files changed, 34 insertions(+), 33 deletions(-) diff --git a/crates/ruma-client-api/src/media/create_content.rs b/crates/ruma-client-api/src/media/create_content.rs index 09926f7f..4f984d23 100644 --- a/crates/ruma-client-api/src/media/create_content.rs +++ b/crates/ruma-client-api/src/media/create_content.rs @@ -5,7 +5,7 @@ pub mod v3 { //! //! [spec]: https://spec.matrix.org/v1.2/client-server-api/#post_matrixmediav3upload - use ruma_common::{api::ruma_api, MxcUri}; + use ruma_common::{api::ruma_api, OwnedMxcUri}; ruma_api! { metadata: { @@ -50,7 +50,7 @@ pub mod v3 { response: { /// The MXC URI for the uploaded content. - pub content_uri: Box, + pub content_uri: OwnedMxcUri, /// The [BlurHash](https://blurha.sh) for the uploaded content. /// @@ -83,7 +83,7 @@ pub mod v3 { impl Response { /// Creates a new `Response` with the given MXC URI. - pub fn new(content_uri: Box) -> Self { + pub fn new(content_uri: OwnedMxcUri) -> Self { Self { content_uri, #[cfg(feature = "unstable-msc2448")] diff --git a/crates/ruma-client-api/src/membership/joined_members.rs b/crates/ruma-client-api/src/membership/joined_members.rs index 760ee62c..55b2ca7c 100644 --- a/crates/ruma-client-api/src/membership/joined_members.rs +++ b/crates/ruma-client-api/src/membership/joined_members.rs @@ -7,7 +7,7 @@ pub mod v3 { use std::collections::BTreeMap; - use ruma_common::{api::ruma_api, MxcUri, OwnedUserId, RoomId}; + use ruma_common::{api::ruma_api, OwnedMxcUri, OwnedUserId, RoomId}; use serde::{Deserialize, Serialize}; ruma_api! { @@ -68,7 +68,7 @@ pub mod v3 { feature = "compat", serde(default, deserialize_with = "ruma_common::serde::empty_string_as_none") )] - pub avatar_url: Option>, + pub avatar_url: Option, } impl RoomMember { diff --git a/crates/ruma-client-api/src/profile/get_avatar_url.rs b/crates/ruma-client-api/src/profile/get_avatar_url.rs index f9023826..4fde861d 100644 --- a/crates/ruma-client-api/src/profile/get_avatar_url.rs +++ b/crates/ruma-client-api/src/profile/get_avatar_url.rs @@ -5,7 +5,7 @@ pub mod v3 { //! //! [spec]: https://spec.matrix.org/v1.2/client-server-api/#get_matrixclientv3profileuseridavatar_url - use ruma_common::{api::ruma_api, MxcUri, UserId}; + use ruma_common::{api::ruma_api, OwnedMxcUri, UserId}; ruma_api! { metadata: { @@ -36,7 +36,7 @@ pub mod v3 { feature = "compat", serde(default, deserialize_with = "ruma_common::serde::empty_string_as_none") )] - pub avatar_url: Option>, + pub avatar_url: Option, /// The [BlurHash](https://blurha.sh) for the avatar pointed to by `avatar_url`. /// @@ -63,7 +63,7 @@ pub mod v3 { impl Response { /// Creates a new `Response` with the given avatar URL. - pub fn new(avatar_url: Option>) -> Self { + pub fn new(avatar_url: Option) -> Self { Self { avatar_url, #[cfg(feature = "unstable-msc2448")] diff --git a/crates/ruma-client-api/src/profile/get_profile.rs b/crates/ruma-client-api/src/profile/get_profile.rs index 8748b3bd..e58c9143 100644 --- a/crates/ruma-client-api/src/profile/get_profile.rs +++ b/crates/ruma-client-api/src/profile/get_profile.rs @@ -5,7 +5,7 @@ pub mod v3 { //! //! [spec]: https://spec.matrix.org/v1.2/client-server-api/#get_matrixclientv3profileuserid - use ruma_common::{api::ruma_api, MxcUri, UserId}; + use ruma_common::{api::ruma_api, OwnedMxcUri, UserId}; ruma_api! { metadata: { @@ -36,7 +36,7 @@ pub mod v3 { feature = "compat", serde(default, deserialize_with = "ruma_common::serde::empty_string_as_none") )] - pub avatar_url: Option>, + pub avatar_url: Option, /// The user's display name, if set. #[serde(skip_serializing_if = "Option::is_none")] @@ -67,7 +67,7 @@ pub mod v3 { impl Response { /// Creates a new `Response` with the given avatar URL and display name. - pub fn new(avatar_url: Option>, displayname: Option) -> Self { + pub fn new(avatar_url: Option, displayname: Option) -> Self { Self { avatar_url, displayname, diff --git a/crates/ruma-client-api/src/search/search_events.rs b/crates/ruma-client-api/src/search/search_events.rs index ccb231b6..6cc9e655 100644 --- a/crates/ruma-client-api/src/search/search_events.rs +++ b/crates/ruma-client-api/src/search/search_events.rs @@ -12,7 +12,7 @@ pub mod v3 { api::ruma_api, events::{AnyRoomEvent, AnyStateEvent}, serde::{Incoming, Raw, StringEnum}, - MxcUri, OwnedEventId, OwnedRoomId, OwnedUserId, + OwnedEventId, OwnedMxcUri, OwnedRoomId, OwnedUserId, }; use serde::{Deserialize, Serialize}; @@ -489,7 +489,7 @@ pub mod v3 { feature = "compat", serde(default, deserialize_with = "ruma_common::serde::empty_string_as_none") )] - pub avatar_url: Option>, + pub avatar_url: Option, /// The user's display name, if set. #[serde(skip_serializing_if = "Option::is_none")] diff --git a/crates/ruma-client-api/src/session/get_login_types.rs b/crates/ruma-client-api/src/session/get_login_types.rs index 0c42e980..e0a612e4 100644 --- a/crates/ruma-client-api/src/session/get_login_types.rs +++ b/crates/ruma-client-api/src/session/get_login_types.rs @@ -10,7 +10,7 @@ pub mod v3 { use ruma_common::{ api::ruma_api, serde::{JsonObject, StringEnum}, - MxcUri, + OwnedMxcUri, }; use serde::{de::DeserializeOwned, Deserialize, Serialize}; use serde_json::Value as JsonValue; @@ -177,7 +177,7 @@ pub mod v3 { pub name: String, /// The icon for the provider. - pub icon: Option>, + pub icon: Option, /// The brand identifier for the provider. pub brand: Option, diff --git a/crates/ruma-client-api/src/space.rs b/crates/ruma-client-api/src/space.rs index f2039501..c5df84ff 100644 --- a/crates/ruma-client-api/src/space.rs +++ b/crates/ruma-client-api/src/space.rs @@ -9,7 +9,7 @@ use ruma_common::{ events::space::child::HierarchySpaceChildEvent, room::RoomType, serde::{Raw, StringEnum}, - MxcUri, OwnedRoomAliasId, OwnedRoomId, RoomName, + OwnedMxcUri, OwnedRoomAliasId, OwnedRoomId, RoomName, }; use serde::{Deserialize, Serialize}; @@ -63,7 +63,7 @@ pub struct SpaceHierarchyRoomsChunk { feature = "compat", serde(default, deserialize_with = "ruma_common::serde::empty_string_as_none") )] - pub avatar_url: Option>, + pub avatar_url: Option, /// The join rule of the room. #[serde(default, skip_serializing_if = "ruma_common::serde::is_default")] diff --git a/crates/ruma-client-api/src/user_directory/search_users.rs b/crates/ruma-client-api/src/user_directory/search_users.rs index 9e55783d..afcaf61f 100644 --- a/crates/ruma-client-api/src/user_directory/search_users.rs +++ b/crates/ruma-client-api/src/user_directory/search_users.rs @@ -6,7 +6,7 @@ pub mod v3 { //! [spec]: https://spec.matrix.org/v1.2/client-server-api/#post_matrixclientv3user_directorysearch use js_int::{uint, UInt}; - use ruma_common::{api::ruma_api, MxcUri, OwnedUserId}; + use ruma_common::{api::ruma_api, OwnedMxcUri, OwnedUserId}; use serde::{Deserialize, Serialize}; ruma_api! { @@ -93,7 +93,7 @@ pub mod v3 { feature = "compat", serde(default, deserialize_with = "ruma_common::serde::empty_string_as_none") )] - pub avatar_url: Option>, + pub avatar_url: Option, } impl User { diff --git a/crates/ruma-common/src/directory.rs b/crates/ruma-common/src/directory.rs index 89149d4f..baa2b067 100644 --- a/crates/ruma-common/src/directory.rs +++ b/crates/ruma-common/src/directory.rs @@ -14,7 +14,7 @@ use serde::{ }; use serde_json::Value as JsonValue; -use crate::{MxcUri, PrivOwnedStr, RoomName}; +use crate::{OwnedMxcUri, PrivOwnedStr, RoomName}; /// A chunk of a room list response, describing one room. /// @@ -62,7 +62,7 @@ pub struct PublicRoomsChunk { feature = "compat", serde(default, deserialize_with = "crate::serde::empty_string_as_none") )] - pub avatar_url: Option>, + pub avatar_url: Option, /// The join rule of the room. #[serde(default, skip_serializing_if = "crate::serde::is_default")] diff --git a/crates/ruma-common/src/events/room/avatar.rs b/crates/ruma-common/src/events/room/avatar.rs index a0aa46d9..bb5e2f3d 100644 --- a/crates/ruma-common/src/events/room/avatar.rs +++ b/crates/ruma-common/src/events/room/avatar.rs @@ -7,7 +7,7 @@ use ruma_macros::EventContent; use serde::{Deserialize, Serialize}; use super::ThumbnailInfo; -use crate::{events::EmptyStateKey, MxcUri}; +use crate::{events::EmptyStateKey, OwnedMxcUri}; /// The content of an `m.room.avatar` event. /// @@ -23,7 +23,7 @@ pub struct RoomAvatarEventContent { pub info: Option>, /// URL of the avatar image. - pub url: Option>, + pub url: Option, } impl RoomAvatarEventContent { @@ -59,7 +59,7 @@ pub struct ImageInfo { /// The URL to the thumbnail of the image. #[serde(skip_serializing_if = "Option::is_none")] - pub thumbnail_url: Option>, + pub thumbnail_url: Option, /// The [BlurHash](https://blurha.sh) for this image. /// diff --git a/crates/ruma-common/src/events/room/member.rs b/crates/ruma-common/src/events/room/member.rs index 38b83c63..c241e39d 100644 --- a/crates/ruma-common/src/events/room/member.rs +++ b/crates/ruma-common/src/events/room/member.rs @@ -14,7 +14,8 @@ use crate::{ StateEventType, }, serde::StringEnum, - MxcUri, OwnedServerName, OwnedServerSigningKeyId, OwnedUserId, PrivOwnedStr, RoomVersionId, + OwnedMxcUri, OwnedServerName, OwnedServerSigningKeyId, OwnedUserId, PrivOwnedStr, + RoomVersionId, }; mod change; @@ -55,7 +56,7 @@ pub struct RoomMemberEventContent { feature = "compat", serde(default, deserialize_with = "crate::serde::empty_string_as_none") )] - pub avatar_url: Option>, + pub avatar_url: Option, /// The display name for this user, if any. /// diff --git a/crates/ruma-common/src/identifiers/mxc_uri.rs b/crates/ruma-common/src/identifiers/mxc_uri.rs index 1a09cd4e..c6726d29 100644 --- a/crates/ruma-common/src/identifiers/mxc_uri.rs +++ b/crates/ruma-common/src/identifiers/mxc_uri.rs @@ -65,7 +65,7 @@ mod tests { use ruma_identifiers_validation::error::MxcUriError; - use super::MxcUri; + use super::{MxcUri, OwnedMxcUri}; #[test] fn parse_mxc_uri() { @@ -102,7 +102,7 @@ mod tests { #[test] fn deserialize_mxc_uri() { - let mxc = serde_json::from_str::>(r#""mxc://server/1234id""#) + let mxc = serde_json::from_str::(r#""mxc://server/1234id""#) .expect("Failed to convert JSON to MxcUri"); assert_eq!(mxc.as_str(), "mxc://server/1234id"); diff --git a/crates/ruma-federation-api/src/query/get_profile_information.rs b/crates/ruma-federation-api/src/query/get_profile_information.rs index 9759788a..4d356312 100644 --- a/crates/ruma-federation-api/src/query/get_profile_information.rs +++ b/crates/ruma-federation-api/src/query/get_profile_information.rs @@ -7,7 +7,7 @@ pub mod v1 { //! //! [spec]: https://spec.matrix.org/v1.2/server-server-api/#get_matrixfederationv1queryprofile - use ruma_common::{api::ruma_api, serde::StringEnum, MxcUri, UserId}; + use ruma_common::{api::ruma_api, serde::StringEnum, OwnedMxcUri, UserId}; use crate::PrivOwnedStr; @@ -48,7 +48,7 @@ pub mod v1 { feature = "compat", serde(default, deserialize_with = "ruma_common::serde::empty_string_as_none") )] - pub avatar_url: Option>, + pub avatar_url: Option, /// The [BlurHash](https://blurha.sh) for the avatar pointed to by `avatar_url`. /// diff --git a/crates/ruma-federation-api/src/space.rs b/crates/ruma-federation-api/src/space.rs index 645d6f30..cb399ce4 100644 --- a/crates/ruma-federation-api/src/space.rs +++ b/crates/ruma-federation-api/src/space.rs @@ -3,7 +3,7 @@ use js_int::UInt; use ruma_common::{ directory::PublicRoomJoinRule, events::space::child::HierarchySpaceChildEvent, room::RoomType, - serde::Raw, MxcUri, OwnedRoomAliasId, OwnedRoomId, RoomName, + serde::Raw, OwnedMxcUri, OwnedRoomAliasId, OwnedRoomId, RoomName, }; use serde::{Deserialize, Serialize}; @@ -55,7 +55,7 @@ pub struct SpaceHierarchyParentSummary { feature = "compat", serde(default, deserialize_with = "ruma_common::serde::empty_string_as_none") )] - pub avatar_url: Option>, + pub avatar_url: Option, /// The join rule of the room. #[serde(default, skip_serializing_if = "ruma_common::serde::is_default")] @@ -184,7 +184,7 @@ pub struct SpaceHierarchyChildSummary { feature = "compat", serde(default, deserialize_with = "ruma_common::serde::empty_string_as_none") )] - pub avatar_url: Option>, + pub avatar_url: Option, /// The join rule of the room. #[serde(default, skip_serializing_if = "ruma_common::serde::is_default")]