diff --git a/crates/ruma-common/src/directory.rs b/crates/ruma-common/src/directory.rs index 9d23f88f..89149d4f 100644 --- a/crates/ruma-common/src/directory.rs +++ b/crates/ruma-common/src/directory.rs @@ -2,7 +2,10 @@ use std::fmt; -use crate::serde::{Incoming, StringEnum}; +use crate::{ + serde::{Incoming, StringEnum}, + OwnedRoomAliasId, OwnedRoomId, +}; use js_int::UInt; use serde::{ de::{Error, MapAccess, Visitor}, @@ -11,7 +14,7 @@ use serde::{ }; use serde_json::Value as JsonValue; -use crate::{MxcUri, PrivOwnedStr, RoomAliasId, RoomId, RoomName}; +use crate::{MxcUri, PrivOwnedStr, RoomName}; /// A chunk of a room list response, describing one room. /// @@ -26,7 +29,7 @@ pub struct PublicRoomsChunk { feature = "compat", serde(default, deserialize_with = "crate::serde::empty_string_as_none") )] - pub canonical_alias: Option>, + pub canonical_alias: Option, /// The name of the room, if any. #[serde(skip_serializing_if = "Option::is_none")] @@ -36,7 +39,7 @@ pub struct PublicRoomsChunk { pub num_joined_members: UInt, /// The ID of the room. - pub room_id: Box, + pub room_id: OwnedRoomId, /// The topic of the room, if any. #[serde(skip_serializing_if = "Option::is_none")] @@ -77,7 +80,7 @@ pub struct PublicRoomsChunkInit { pub num_joined_members: UInt, /// The ID of the room. - pub room_id: Box, + pub room_id: OwnedRoomId, /// Whether the room may be viewed by guest users without joining. pub world_readable: bool, diff --git a/crates/ruma-common/src/encryption.rs b/crates/ruma-common/src/encryption.rs index e71abd80..437ba70b 100644 --- a/crates/ruma-common/src/encryption.rs +++ b/crates/ruma-common/src/encryption.rs @@ -8,7 +8,7 @@ use serde::{Deserialize, Serialize}; use crate::{ serde::{Base64, StringEnum}, - DeviceId, DeviceKeyId, EventEncryptionAlgorithm, PrivOwnedStr, UserId, + EventEncryptionAlgorithm, OwnedDeviceId, OwnedDeviceKeyId, OwnedUserId, PrivOwnedStr, }; /// Identity keys for a device. @@ -18,21 +18,21 @@ pub struct DeviceKeys { /// The ID of the user the device belongs to. /// /// Must match the user ID used when logging in. - pub user_id: Box, + pub user_id: OwnedUserId, /// The ID of the device these keys belong to. /// /// Must match the device ID used when logging in. - pub device_id: Box, + pub device_id: OwnedDeviceId, /// The encryption algorithms supported by this device. pub algorithms: Vec, /// Public identity keys. - pub keys: BTreeMap, String>, + pub keys: BTreeMap, /// Signatures for the device key object. - pub signatures: BTreeMap, BTreeMap, String>>, + pub signatures: BTreeMap>, /// Additional data added to the device key information by intermediate servers, and /// not covered by the signatures. @@ -44,11 +44,11 @@ impl DeviceKeys { /// Creates a new `DeviceKeys` from the given user id, device id, algorithms, keys and /// signatures. pub fn new( - user_id: Box, - device_id: Box, + user_id: OwnedUserId, + device_id: OwnedDeviceId, algorithms: Vec, - keys: BTreeMap, String>, - signatures: BTreeMap, BTreeMap, String>>, + keys: BTreeMap, + signatures: BTreeMap>, ) -> Self { Self { user_id, device_id, algorithms, keys, signatures, unsigned: Default::default() } } @@ -76,7 +76,7 @@ impl UnsignedDeviceInfo { } /// Signatures for a `SignedKey` object. -pub type SignedKeySignatures = BTreeMap, BTreeMap, String>>; +pub type SignedKeySignatures = BTreeMap>; /// A key for the SignedCurve25519 algorithm #[derive(Debug, Clone, Serialize, Deserialize)] @@ -118,14 +118,14 @@ pub enum OneTimeKey { } /// Signatures for a `CrossSigningKey` object. -pub type CrossSigningKeySignatures = BTreeMap, BTreeMap, String>>; +pub type CrossSigningKeySignatures = BTreeMap>; /// A cross signing key. #[derive(Clone, Debug, Deserialize, Serialize)] #[cfg_attr(not(feature = "unstable-exhaustive-types"), non_exhaustive)] pub struct CrossSigningKey { /// The ID of the user the key belongs to. - pub user_id: Box, + pub user_id: OwnedUserId, /// What the key is used for. pub usage: Vec, @@ -133,7 +133,7 @@ pub struct CrossSigningKey { /// The public key. /// /// The object must have exactly one property. - pub keys: BTreeMap, String>, + pub keys: BTreeMap, /// Signatures of the key. /// @@ -145,9 +145,9 @@ pub struct CrossSigningKey { impl CrossSigningKey { /// Creates a new `CrossSigningKey` with the given user ID, usage, keys and signatures. pub fn new( - user_id: Box, + user_id: OwnedUserId, usage: Vec, - keys: BTreeMap, String>, + keys: BTreeMap, signatures: CrossSigningKeySignatures, ) -> Self { Self { user_id, usage, keys, signatures } diff --git a/crates/ruma-common/src/thirdparty.rs b/crates/ruma-common/src/thirdparty.rs index d8a7ee6e..c0e9c770 100644 --- a/crates/ruma-common/src/thirdparty.rs +++ b/crates/ruma-common/src/thirdparty.rs @@ -6,7 +6,9 @@ use std::collections::BTreeMap; use serde::{Deserialize, Serialize}; -use crate::{serde::StringEnum, MilliSecondsSinceUnixEpoch, PrivOwnedStr, RoomAliasId, UserId}; +use crate::{ + serde::StringEnum, MilliSecondsSinceUnixEpoch, OwnedRoomAliasId, OwnedUserId, PrivOwnedStr, +}; /// Metadata about a third party protocol. /// @@ -175,7 +177,7 @@ impl From for FieldType { #[cfg_attr(not(feature = "unstable-exhaustive-types"), non_exhaustive)] pub struct Location { /// An alias for a matrix room. - pub alias: Box, + pub alias: OwnedRoomAliasId, /// The protocol ID that the third party location is a part of. pub protocol: String, @@ -187,7 +189,7 @@ pub struct Location { impl Location { /// Creates a new `Location` with the given alias, protocol and fields. pub fn new( - alias: Box, + alias: OwnedRoomAliasId, protocol: String, fields: BTreeMap, ) -> Self { @@ -200,7 +202,7 @@ impl Location { #[cfg_attr(not(feature = "unstable-exhaustive-types"), non_exhaustive)] pub struct User { /// A matrix user ID representing a third party user. - pub userid: Box, + pub userid: OwnedUserId, /// The protocol ID that the third party user is a part of. pub protocol: String, @@ -211,7 +213,7 @@ pub struct User { impl User { /// Creates a new `User` with the given userid, protocol and fields. - pub fn new(userid: Box, protocol: String, fields: BTreeMap) -> Self { + pub fn new(userid: OwnedUserId, protocol: String, fields: BTreeMap) -> Self { Self { userid, protocol, fields } } } diff --git a/crates/ruma-common/src/to_device.rs b/crates/ruma-common/src/to_device.rs index d24a3e46..384d5284 100644 --- a/crates/ruma-common/src/to_device.rs +++ b/crates/ruma-common/src/to_device.rs @@ -12,14 +12,14 @@ use serde::{ Deserialize, Deserializer, Serialize, Serializer, }; -use crate::DeviceId; +use crate::OwnedDeviceId; /// Represents one or all of a user's devices. #[derive(Clone, Debug, PartialEq, Eq, PartialOrd, Ord)] #[allow(clippy::exhaustive_enums)] pub enum DeviceIdOrAllDevices { /// Represents a device Id for one of a user's devices. - DeviceId(Box), + DeviceId(OwnedDeviceId), /// Represents all devices for a user. AllDevices, @@ -34,8 +34,8 @@ impl Display for DeviceIdOrAllDevices { } } -impl From> for DeviceIdOrAllDevices { - fn from(d: Box) -> Self { +impl From for DeviceIdOrAllDevices { + fn from(d: OwnedDeviceId) -> Self { DeviceIdOrAllDevices::DeviceId(d) } }