Use new owned ID types in more places

This commit is contained in:
Jonas Platte 2022-04-09 23:29:17 +02:00
parent efc869ce9d
commit 6100a0fa12
28 changed files with 133 additions and 130 deletions

View File

@ -8,7 +8,9 @@ pub mod v1 {
//! [spec]: https://spec.matrix.org/v1.2/server-server-api/#get_matrixfederationv1backfillroomid //! [spec]: https://spec.matrix.org/v1.2/server-server-api/#get_matrixfederationv1backfillroomid
use js_int::UInt; use js_int::UInt;
use ruma_common::{api::ruma_api, EventId, MilliSecondsSinceUnixEpoch, RoomId, ServerName}; use ruma_common::{
api::ruma_api, MilliSecondsSinceUnixEpoch, OwnedEventId, OwnedServerName, RoomId,
};
use serde_json::value::RawValue as RawJsonValue; use serde_json::value::RawValue as RawJsonValue;
ruma_api! { ruma_api! {
@ -29,7 +31,7 @@ pub mod v1 {
/// The event IDs to backfill from. /// The event IDs to backfill from.
#[ruma_api(query)] #[ruma_api(query)]
pub v: &'a [Box<EventId>], pub v: &'a [OwnedEventId],
/// The maximum number of PDUs to retrieve, including the given events. /// The maximum number of PDUs to retrieve, including the given events.
#[ruma_api(query)] #[ruma_api(query)]
@ -38,7 +40,7 @@ pub mod v1 {
response: { response: {
/// The `server_name` of the homeserver sending this transaction. /// The `server_name` of the homeserver sending this transaction.
pub origin: Box<ServerName>, pub origin: OwnedServerName,
/// POSIX timestamp in milliseconds on originating homeserver when this transaction started. /// POSIX timestamp in milliseconds on originating homeserver when this transaction started.
pub origin_server_ts: MilliSecondsSinceUnixEpoch, pub origin_server_ts: MilliSecondsSinceUnixEpoch,
@ -53,7 +55,7 @@ pub mod v1 {
/// * the given room id. /// * the given room id.
/// * the event IDs to backfill from. /// * the event IDs to backfill from.
/// * the maximum number of PDUs to retrieve, including the given events. /// * the maximum number of PDUs to retrieve, including the given events.
pub fn new(room_id: &'a RoomId, v: &'a [Box<EventId>], limit: UInt) -> Self { pub fn new(room_id: &'a RoomId, v: &'a [OwnedEventId], limit: UInt) -> Self {
Self { room_id, v, limit } Self { room_id, v, limit }
} }
} }
@ -64,7 +66,7 @@ pub mod v1 {
/// * the timestamp in milliseconds of when this transaction started. /// * the timestamp in milliseconds of when this transaction started.
/// * the list of persistent updates to rooms. /// * the list of persistent updates to rooms.
pub fn new( pub fn new(
origin: Box<ServerName>, origin: OwnedServerName,
origin_server_ts: MilliSecondsSinceUnixEpoch, origin_server_ts: MilliSecondsSinceUnixEpoch,
pdus: Vec<Box<RawJsonValue>>, pdus: Vec<Box<RawJsonValue>>,
) -> Self { ) -> Self {

View File

@ -12,7 +12,7 @@ pub mod v1 {
api::ruma_api, api::ruma_api,
encryption::{CrossSigningKey, DeviceKeys}, encryption::{CrossSigningKey, DeviceKeys},
serde::Raw, serde::Raw,
DeviceId, UserId, OwnedDeviceId, OwnedUserId, UserId,
}; };
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
@ -37,7 +37,7 @@ pub mod v1 {
response: { response: {
/// The user ID devices were requested for. /// The user ID devices were requested for.
pub user_id: Box<UserId>, pub user_id: OwnedUserId,
/// A unique ID for a given user_id which describes the version of the returned device list. /// A unique ID for a given user_id which describes the version of the returned device list.
/// ///
@ -69,7 +69,7 @@ pub mod v1 {
/// Creates a new `Response` with the given user id and stream id. /// Creates a new `Response` with the given user id and stream id.
/// ///
/// The device list will be empty. /// The device list will be empty.
pub fn new(user_id: Box<UserId>, stream_id: UInt) -> Self { pub fn new(user_id: OwnedUserId, stream_id: UInt) -> Self {
Self { Self {
user_id, user_id,
stream_id, stream_id,
@ -85,7 +85,7 @@ pub mod v1 {
#[cfg_attr(not(feature = "unstable-exhaustive-types"), non_exhaustive)] #[cfg_attr(not(feature = "unstable-exhaustive-types"), non_exhaustive)]
pub struct UserDevice { pub struct UserDevice {
/// The device ID. /// The device ID.
pub device_id: Box<DeviceId>, pub device_id: OwnedDeviceId,
/// Identity keys for the device. /// Identity keys for the device.
pub keys: Raw<DeviceKeys>, pub keys: Raw<DeviceKeys>,
@ -97,7 +97,7 @@ pub mod v1 {
impl UserDevice { impl UserDevice {
/// Creates a new `UserDevice` with the given device id and keys. /// Creates a new `UserDevice` with the given device id and keys.
pub fn new(device_id: Box<DeviceId>, keys: Raw<DeviceKeys>) -> Self { pub fn new(device_id: OwnedDeviceId, keys: Raw<DeviceKeys>) -> Self {
Self { device_id, keys, device_display_name: None } Self { device_id, keys, device_display_name: None }
} }
} }

View File

@ -2,7 +2,7 @@
use std::collections::BTreeMap; use std::collections::BTreeMap;
use ruma_common::{serde::Base64, MilliSecondsSinceUnixEpoch, ServerName, ServerSigningKeyId}; use ruma_common::{serde::Base64, MilliSecondsSinceUnixEpoch, OwnedServerName, ServerSigningKeyId};
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
pub mod discover_homeserver; pub mod discover_homeserver;
@ -52,7 +52,7 @@ impl OldVerifyKey {
#[cfg_attr(not(feature = "unstable-exhaustive-types"), non_exhaustive)] #[cfg_attr(not(feature = "unstable-exhaustive-types"), non_exhaustive)]
pub struct ServerSigningKeys { pub struct ServerSigningKeys {
/// DNS name of the homeserver. /// DNS name of the homeserver.
pub server_name: Box<ServerName>, pub server_name: OwnedServerName,
/// Public keys of the homeserver for verifying digital signatures. /// Public keys of the homeserver for verifying digital signatures.
pub verify_keys: BTreeMap<Box<ServerSigningKeyId>, VerifyKey>, pub verify_keys: BTreeMap<Box<ServerSigningKeyId>, VerifyKey>,
@ -63,7 +63,7 @@ pub struct ServerSigningKeys {
/// Digital signatures of this object signed using the verify_keys. /// Digital signatures of this object signed using the verify_keys.
/// ///
/// Map of server name to keys by key ID. /// Map of server name to keys by key ID.
pub signatures: BTreeMap<Box<ServerName>, BTreeMap<Box<ServerSigningKeyId>, String>>, pub signatures: BTreeMap<OwnedServerName, BTreeMap<Box<ServerSigningKeyId>, String>>,
/// Timestamp when the keys should be refreshed. /// Timestamp when the keys should be refreshed.
/// ///
@ -75,7 +75,7 @@ impl ServerSigningKeys {
/// Creates a new `ServerSigningKeys` with the given server name and validity timestamp. /// Creates a new `ServerSigningKeys` with the given server name and validity timestamp.
/// ///
/// All other fields will be empty. /// All other fields will be empty.
pub fn new(server_name: Box<ServerName>, valid_until_ts: MilliSecondsSinceUnixEpoch) -> Self { pub fn new(server_name: OwnedServerName, valid_until_ts: MilliSecondsSinceUnixEpoch) -> Self {
Self { Self {
server_name, server_name,
verify_keys: BTreeMap::new(), verify_keys: BTreeMap::new(),

View File

@ -2,7 +2,7 @@
//! //!
//! [spec]: https://spec.matrix.org/v1.2/server-server-api/#getwell-knownmatrixserver //! [spec]: https://spec.matrix.org/v1.2/server-server-api/#getwell-knownmatrixserver
use ruma_common::{api::ruma_api, ServerName}; use ruma_common::{api::ruma_api, OwnedServerName};
ruma_api! { ruma_api! {
metadata: { metadata: {
@ -21,7 +21,7 @@ ruma_api! {
response: { response: {
/// The server name to delegate server-server communications to, with optional port. /// The server name to delegate server-server communications to, with optional port.
#[serde(rename = "m.server")] #[serde(rename = "m.server")]
pub server: Box<ServerName>, pub server: OwnedServerName,
} }
} }
@ -34,7 +34,7 @@ impl Request {
impl Response { impl Response {
/// Creates a new `Response` with the given homeserver. /// Creates a new `Response` with the given homeserver.
pub fn new(server: Box<ServerName>) -> Self { pub fn new(server: OwnedServerName) -> Self {
Self { server } Self { server }
} }
} }

View File

@ -11,7 +11,7 @@ pub mod v2 {
use std::collections::BTreeMap; use std::collections::BTreeMap;
use ruma_common::{ use ruma_common::{
api::ruma_api, serde::Raw, MilliSecondsSinceUnixEpoch, ServerName, ServerSigningKeyId, api::ruma_api, serde::Raw, MilliSecondsSinceUnixEpoch, OwnedServerName, ServerSigningKeyId,
}; };
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
@ -37,7 +37,7 @@ pub mod v2 {
/// notary server must return an empty server_keys array in the response. /// notary server must return an empty server_keys array in the response.
/// ///
/// The notary server may return multiple keys regardless of the Key IDs given. /// The notary server may return multiple keys regardless of the Key IDs given.
pub server_keys: BTreeMap<Box<ServerName>, BTreeMap<Box<ServerSigningKeyId>, QueryCriteria>>, pub server_keys: BTreeMap<OwnedServerName, BTreeMap<Box<ServerSigningKeyId>, QueryCriteria>>,
} }
@ -51,7 +51,7 @@ pub mod v2 {
/// Creates a new `Request` with the given query criteria. /// Creates a new `Request` with the given query criteria.
pub fn new( pub fn new(
server_keys: BTreeMap< server_keys: BTreeMap<
Box<ServerName>, OwnedServerName,
BTreeMap<Box<ServerSigningKeyId>, QueryCriteria>, BTreeMap<Box<ServerSigningKeyId>, QueryCriteria>,
>, >,
) -> Self { ) -> Self {

View File

@ -7,7 +7,7 @@ pub mod v1 {
//! //!
//! [spec]: https://spec.matrix.org/v1.2/server-server-api/#get_matrixfederationv1eventeventid //! [spec]: https://spec.matrix.org/v1.2/server-server-api/#get_matrixfederationv1eventeventid
use ruma_common::{api::ruma_api, EventId, MilliSecondsSinceUnixEpoch, ServerName}; use ruma_common::{api::ruma_api, EventId, MilliSecondsSinceUnixEpoch, OwnedServerName};
use serde_json::value::RawValue as RawJsonValue; use serde_json::value::RawValue as RawJsonValue;
ruma_api! { ruma_api! {
@ -29,7 +29,7 @@ pub mod v1 {
response: { response: {
/// The `server_name` of the homeserver sending this transaction. /// The `server_name` of the homeserver sending this transaction.
pub origin: Box<ServerName>, pub origin: OwnedServerName,
/// Time on originating homeserver when this transaction started. /// Time on originating homeserver when this transaction started.
pub origin_server_ts: MilliSecondsSinceUnixEpoch, pub origin_server_ts: MilliSecondsSinceUnixEpoch,
@ -50,7 +50,7 @@ pub mod v1 {
impl Response { impl Response {
/// Creates a new `Response` with the given server name, timestamp, and event. /// Creates a new `Response` with the given server name, timestamp, and event.
pub fn new( pub fn new(
origin: Box<ServerName>, origin: OwnedServerName,
origin_server_ts: MilliSecondsSinceUnixEpoch, origin_server_ts: MilliSecondsSinceUnixEpoch,
pdu: Box<RawJsonValue>, pdu: Box<RawJsonValue>,
) -> Self { ) -> Self {

View File

@ -8,7 +8,7 @@ pub mod v1 {
//! [spec]: https://spec.matrix.org/v1.2/server-server-api/#post_matrixfederationv1get_missing_eventsroomid //! [spec]: https://spec.matrix.org/v1.2/server-server-api/#post_matrixfederationv1get_missing_eventsroomid
use js_int::{uint, UInt}; use js_int::{uint, UInt};
use ruma_common::{api::ruma_api, EventId, RoomId}; use ruma_common::{api::ruma_api, OwnedEventId, RoomId};
use serde_json::value::RawValue as RawJsonValue; use serde_json::value::RawValue as RawJsonValue;
ruma_api! { ruma_api! {
@ -42,10 +42,10 @@ pub mod v1 {
/// The latest event IDs that the sender already has. /// The latest event IDs that the sender already has.
/// ///
/// These are skipped when retrieving the previous events of `latest_events`. /// These are skipped when retrieving the previous events of `latest_events`.
pub earliest_events: &'a [Box<EventId>], pub earliest_events: &'a [OwnedEventId],
/// The event IDs to retrieve the previous events for. /// The event IDs to retrieve the previous events for.
pub latest_events: &'a [Box<EventId>], pub latest_events: &'a [OwnedEventId],
} }
#[derive(Default)] #[derive(Default)]
@ -59,8 +59,8 @@ pub mod v1 {
/// Creates a new `Request` for events in the given room with the given constraints. /// Creates a new `Request` for events in the given room with the given constraints.
pub fn new( pub fn new(
room_id: &'a RoomId, room_id: &'a RoomId,
earliest_events: &'a [Box<EventId>], earliest_events: &'a [OwnedEventId],
latest_events: &'a [Box<EventId>], latest_events: &'a [OwnedEventId],
) -> Self { ) -> Self {
Self { Self {
room_id, room_id,

View File

@ -7,7 +7,7 @@ pub mod v1 {
//! //!
//! [spec]: https://spec.matrix.org/v1.2/server-server-api/#get_matrixfederationv1state_idsroomid //! [spec]: https://spec.matrix.org/v1.2/server-server-api/#get_matrixfederationv1state_idsroomid
use ruma_common::{api::ruma_api, EventId, RoomId}; use ruma_common::{api::ruma_api, EventId, OwnedEventId, RoomId};
ruma_api! { ruma_api! {
metadata: { metadata: {
@ -33,10 +33,10 @@ pub mod v1 {
response: { response: {
/// The full set of authorization events that make up the state of the /// The full set of authorization events that make up the state of the
/// room, and their authorization events, recursively. /// room, and their authorization events, recursively.
pub auth_chain_ids: Vec<Box<EventId>>, pub auth_chain_ids: Vec<OwnedEventId>,
/// The fully resolved state of the room at the given event. /// The fully resolved state of the room at the given event.
pub pdu_ids: Vec<Box<EventId>>, pub pdu_ids: Vec<OwnedEventId>,
} }
} }
@ -49,7 +49,7 @@ pub mod v1 {
impl Response { impl Response {
/// Creates a new `Response` with the given auth chain IDs and room state IDs. /// Creates a new `Response` with the given auth chain IDs and room state IDs.
pub fn new(auth_chain_ids: Vec<Box<EventId>>, pdu_ids: Vec<Box<EventId>>) -> Self { pub fn new(auth_chain_ids: Vec<OwnedEventId>, pdu_ids: Vec<OwnedEventId>) -> Self {
Self { auth_chain_ids, pdu_ids } Self { auth_chain_ids, pdu_ids }
} }
} }

View File

@ -13,7 +13,7 @@ pub mod v1 {
api::ruma_api, api::ruma_api,
encryption::OneTimeKey, encryption::OneTimeKey,
serde::{Base64, Raw}, serde::{Base64, Raw},
DeviceId, DeviceKeyAlgorithm, DeviceKeyId, UserId, DeviceKeyAlgorithm, DeviceKeyId, OwnedDeviceId, OwnedUserId,
}; };
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
@ -54,11 +54,11 @@ pub mod v1 {
} }
/// A claim for one time keys /// A claim for one time keys
pub type OneTimeKeyClaims = BTreeMap<Box<UserId>, BTreeMap<Box<DeviceId>, DeviceKeyAlgorithm>>; pub type OneTimeKeyClaims = BTreeMap<OwnedUserId, BTreeMap<OwnedDeviceId, DeviceKeyAlgorithm>>;
/// One time keys for use in pre-key messages /// One time keys for use in pre-key messages
pub type OneTimeKeys = pub type OneTimeKeys =
BTreeMap<Box<UserId>, BTreeMap<Box<DeviceId>, BTreeMap<Box<DeviceKeyId>, Raw<OneTimeKey>>>>; BTreeMap<OwnedUserId, BTreeMap<OwnedDeviceId, BTreeMap<Box<DeviceKeyId>, Raw<OneTimeKey>>>>;
/// A key and its signature /// A key and its signature
#[derive(Debug, Clone, Serialize, Deserialize)] #[derive(Debug, Clone, Serialize, Deserialize)]
@ -68,14 +68,14 @@ pub mod v1 {
pub key: Base64, pub key: Base64,
/// Signature of the key object. /// Signature of the key object.
pub signatures: BTreeMap<Box<UserId>, BTreeMap<Box<DeviceKeyId>, String>>, pub signatures: BTreeMap<OwnedUserId, BTreeMap<Box<DeviceKeyId>, String>>,
} }
impl KeyObject { impl KeyObject {
/// Creates a new `KeyObject` with the given key and signatures. /// Creates a new `KeyObject` with the given key and signatures.
pub fn new( pub fn new(
key: Base64, key: Base64,
signatures: BTreeMap<Box<UserId>, BTreeMap<Box<DeviceKeyId>, String>>, signatures: BTreeMap<OwnedUserId, BTreeMap<Box<DeviceKeyId>, String>>,
) -> Self { ) -> Self {
Self { key, signatures } Self { key, signatures }
} }

View File

@ -13,7 +13,7 @@ pub mod v1 {
api::ruma_api, api::ruma_api,
encryption::{CrossSigningKey, DeviceKeys}, encryption::{CrossSigningKey, DeviceKeys},
serde::Raw, serde::Raw,
DeviceId, UserId, OwnedDeviceId, OwnedUserId,
}; };
ruma_api! { ruma_api! {
@ -31,27 +31,27 @@ pub mod v1 {
/// The keys to be downloaded. /// The keys to be downloaded.
/// ///
/// Gives all keys for a given user if the list of device ids is empty. /// Gives all keys for a given user if the list of device ids is empty.
pub device_keys: BTreeMap<Box<UserId>, Vec<Box<DeviceId>>>, pub device_keys: BTreeMap<OwnedUserId, Vec<OwnedDeviceId>>,
} }
#[derive(Default)] #[derive(Default)]
response: { response: {
/// Keys from the queried devices. /// Keys from the queried devices.
pub device_keys: BTreeMap<Box<UserId>, BTreeMap<Box<DeviceId>, Raw<DeviceKeys>>>, pub device_keys: BTreeMap<OwnedUserId, BTreeMap<OwnedDeviceId, Raw<DeviceKeys>>>,
/// Information on the master cross-signing keys of the queried users. /// Information on the master cross-signing keys of the queried users.
#[serde(default, skip_serializing_if = "BTreeMap::is_empty")] #[serde(default, skip_serializing_if = "BTreeMap::is_empty")]
pub master_keys: BTreeMap<Box<UserId>, Raw<CrossSigningKey>>, pub master_keys: BTreeMap<OwnedUserId, Raw<CrossSigningKey>>,
/// Information on the self-signing keys of the queried users. /// Information on the self-signing keys of the queried users.
#[serde(default, skip_serializing_if = "BTreeMap::is_empty")] #[serde(default, skip_serializing_if = "BTreeMap::is_empty")]
pub self_signing_keys: BTreeMap<Box<UserId>, Raw<CrossSigningKey>>, pub self_signing_keys: BTreeMap<OwnedUserId, Raw<CrossSigningKey>>,
} }
} }
impl Request { impl Request {
/// Creates a new `Request` asking for the given device keys. /// Creates a new `Request` asking for the given device keys.
pub fn new(device_keys: BTreeMap<Box<UserId>, Vec<Box<DeviceId>>>) -> Self { pub fn new(device_keys: BTreeMap<OwnedUserId, Vec<OwnedDeviceId>>) -> Self {
Self { device_keys } Self { device_keys }
} }
} }
@ -59,7 +59,7 @@ pub mod v1 {
impl Response { impl Response {
/// Creates a new `Response` with the given device keys. /// Creates a new `Response` with the given device keys.
pub fn new( pub fn new(
device_keys: BTreeMap<Box<UserId>, BTreeMap<Box<DeviceId>, Raw<DeviceKeys>>>, device_keys: BTreeMap<OwnedUserId, BTreeMap<OwnedDeviceId, Raw<DeviceKeys>>>,
) -> Self { ) -> Self {
Self { device_keys, ..Default::default() } Self { device_keys, ..Default::default() }
} }

View File

@ -7,7 +7,7 @@ pub mod v1 {
//! //!
//! [spec]: https://spec.matrix.org/v1.2/server-server-api/#get_matrixfederationv1openiduserinfo //! [spec]: https://spec.matrix.org/v1.2/server-server-api/#get_matrixfederationv1openiduserinfo
use ruma_common::{api::ruma_api, UserId}; use ruma_common::{api::ruma_api, OwnedUserId};
ruma_api! { ruma_api! {
metadata: { metadata: {
@ -28,7 +28,7 @@ pub mod v1 {
response: { response: {
/// The Matrix User ID who generated the token. /// The Matrix User ID who generated the token.
pub sub: Box<UserId>, pub sub: OwnedUserId,
} }
} }
@ -41,7 +41,7 @@ pub mod v1 {
impl Response { impl Response {
/// Creates a new `Response` with the given user id. /// Creates a new `Response` with the given user id.
pub fn new(sub: Box<UserId>) -> Self { pub fn new(sub: OwnedUserId) -> Self {
Self { sub } Self { sub }
} }
} }

View File

@ -7,7 +7,7 @@ pub mod v1 {
//! //!
//! [spec]: https://spec.matrix.org/v1.2/server-server-api/#get_matrixfederationv1querydirectory //! [spec]: https://spec.matrix.org/v1.2/server-server-api/#get_matrixfederationv1querydirectory
use ruma_common::{api::ruma_api, RoomAliasId, RoomId, ServerName}; use ruma_common::{api::ruma_api, OwnedRoomId, OwnedServerName, RoomAliasId};
ruma_api! { ruma_api! {
metadata: { metadata: {
@ -28,10 +28,10 @@ pub mod v1 {
response: { response: {
/// Room ID mapped to queried alias. /// Room ID mapped to queried alias.
pub room_id: Box<RoomId>, pub room_id: OwnedRoomId,
/// An array of server names that are likely to hold the given room. /// An array of server names that are likely to hold the given room.
pub servers: Vec<Box<ServerName>>, pub servers: Vec<OwnedServerName>,
} }
} }
@ -44,7 +44,7 @@ pub mod v1 {
impl Response { impl Response {
/// Creates a new `Response` with the given room IDs and servers. /// Creates a new `Response` with the given room IDs and servers.
pub fn new(room_id: Box<RoomId>, servers: Vec<Box<ServerName>>) -> Self { pub fn new(room_id: OwnedRoomId, servers: Vec<OwnedServerName>) -> Self {
Self { room_id, servers } Self { room_id, servers }
} }
} }

View File

@ -3,7 +3,7 @@
use js_int::UInt; use js_int::UInt;
use ruma_common::{ use ruma_common::{
directory::PublicRoomJoinRule, events::space::child::HierarchySpaceChildEvent, room::RoomType, directory::PublicRoomJoinRule, events::space::child::HierarchySpaceChildEvent, room::RoomType,
serde::Raw, MxcUri, RoomAliasId, RoomId, RoomName, serde::Raw, MxcUri, OwnedRoomAliasId, OwnedRoomId, RoomName,
}; };
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
@ -22,7 +22,7 @@ pub struct SpaceHierarchyParentSummary {
feature = "compat", feature = "compat",
serde(default, deserialize_with = "ruma_common::serde::empty_string_as_none") serde(default, deserialize_with = "ruma_common::serde::empty_string_as_none")
)] )]
pub canonical_alias: Option<Box<RoomAliasId>>, pub canonical_alias: Option<OwnedRoomAliasId>,
/// The name of the room, if any. /// The name of the room, if any.
#[serde(skip_serializing_if = "Option::is_none")] #[serde(skip_serializing_if = "Option::is_none")]
@ -32,7 +32,7 @@ pub struct SpaceHierarchyParentSummary {
pub num_joined_members: UInt, pub num_joined_members: UInt,
/// The ID of the room. /// The ID of the room.
pub room_id: Box<RoomId>, pub room_id: OwnedRoomId,
/// The topic of the room, if any. /// The topic of the room, if any.
#[serde(skip_serializing_if = "Option::is_none")] #[serde(skip_serializing_if = "Option::is_none")]
@ -72,7 +72,7 @@ pub struct SpaceHierarchyParentSummary {
/// If the room is a restricted room, these are the room IDs which are specified by the join /// If the room is a restricted room, these are the room IDs which are specified by the join
/// rules. /// rules.
#[serde(default, skip_serializing_if = "ruma_common::serde::is_default")] #[serde(default, skip_serializing_if = "ruma_common::serde::is_default")]
pub allowed_room_ids: Vec<Box<RoomId>>, pub allowed_room_ids: Vec<OwnedRoomId>,
} }
/// Initial set of mandatory fields of `SpaceHierarchyParentSummary`. /// Initial set of mandatory fields of `SpaceHierarchyParentSummary`.
@ -86,7 +86,7 @@ pub struct SpaceHierarchyParentSummaryInit {
pub num_joined_members: UInt, pub num_joined_members: UInt,
/// The ID of the room. /// The ID of the room.
pub room_id: Box<RoomId>, pub room_id: OwnedRoomId,
/// Whether the room may be viewed by guest users without joining. /// Whether the room may be viewed by guest users without joining.
pub world_readable: bool, pub world_readable: bool,
@ -106,7 +106,7 @@ pub struct SpaceHierarchyParentSummaryInit {
/// If the room is a restricted room, these are the room IDs which are specified by the join /// If the room is a restricted room, these are the room IDs which are specified by the join
/// rules. /// rules.
pub allowed_room_ids: Vec<Box<RoomId>>, pub allowed_room_ids: Vec<OwnedRoomId>,
} }
impl From<SpaceHierarchyParentSummaryInit> for SpaceHierarchyParentSummary { impl From<SpaceHierarchyParentSummaryInit> for SpaceHierarchyParentSummary {
@ -151,7 +151,7 @@ pub struct SpaceHierarchyChildSummary {
feature = "compat", feature = "compat",
serde(default, deserialize_with = "ruma_common::serde::empty_string_as_none") serde(default, deserialize_with = "ruma_common::serde::empty_string_as_none")
)] )]
pub canonical_alias: Option<Box<RoomAliasId>>, pub canonical_alias: Option<OwnedRoomAliasId>,
/// The name of the room, if any. /// The name of the room, if any.
#[serde(skip_serializing_if = "Option::is_none")] #[serde(skip_serializing_if = "Option::is_none")]
@ -161,7 +161,7 @@ pub struct SpaceHierarchyChildSummary {
pub num_joined_members: UInt, pub num_joined_members: UInt,
/// The ID of the room. /// The ID of the room.
pub room_id: Box<RoomId>, pub room_id: OwnedRoomId,
/// The topic of the room, if any. /// The topic of the room, if any.
#[serde(skip_serializing_if = "Option::is_none")] #[serde(skip_serializing_if = "Option::is_none")]
@ -196,7 +196,7 @@ pub struct SpaceHierarchyChildSummary {
/// If the room is a restricted room, these are the room IDs which are specified by the join /// If the room is a restricted room, these are the room IDs which are specified by the join
/// rules. /// rules.
#[serde(default, skip_serializing_if = "ruma_common::serde::is_default")] #[serde(default, skip_serializing_if = "ruma_common::serde::is_default")]
pub allowed_room_ids: Vec<Box<RoomId>>, pub allowed_room_ids: Vec<OwnedRoomId>,
} }
/// Initial set of mandatory fields of `SpaceHierarchyChildSummary`. /// Initial set of mandatory fields of `SpaceHierarchyChildSummary`.
@ -210,7 +210,7 @@ pub struct SpaceHierarchyChildSummaryInit {
pub num_joined_members: UInt, pub num_joined_members: UInt,
/// The ID of the room. /// The ID of the room.
pub room_id: Box<RoomId>, pub room_id: OwnedRoomId,
/// Whether the room may be viewed by guest users without joining. /// Whether the room may be viewed by guest users without joining.
pub world_readable: bool, pub world_readable: bool,
@ -225,7 +225,7 @@ pub struct SpaceHierarchyChildSummaryInit {
/// If the room is a restricted room, these are the room IDs which are specified by the join /// If the room is a restricted room, these are the room IDs which are specified by the join
/// rules. /// rules.
pub allowed_room_ids: Vec<Box<RoomId>>, pub allowed_room_ids: Vec<OwnedRoomId>,
} }
impl From<SpaceHierarchyChildSummaryInit> for SpaceHierarchyChildSummary { impl From<SpaceHierarchyChildSummaryInit> for SpaceHierarchyChildSummary {

View File

@ -7,7 +7,7 @@ pub mod v1 {
//! //!
//! [spec]: https://spec.matrix.org/v1.2/server-server-api/#get_matrixfederationv1hierarchyroomid //! [spec]: https://spec.matrix.org/v1.2/server-server-api/#get_matrixfederationv1hierarchyroomid
use ruma_common::{api::ruma_api, RoomId}; use ruma_common::{api::ruma_api, OwnedRoomId, RoomId};
use crate::space::{SpaceHierarchyChildSummary, SpaceHierarchyParentSummary}; use crate::space::{SpaceHierarchyChildSummary, SpaceHierarchyParentSummary};
@ -46,7 +46,7 @@ pub mod v1 {
/// ///
/// Rooms which the responding server cannot provide details on will be outright /// Rooms which the responding server cannot provide details on will be outright
/// excluded from the response instead. /// excluded from the response instead.
pub inaccessible_children: Vec<Box<RoomId>>, pub inaccessible_children: Vec<OwnedRoomId>,
/// A summary of the requested room. /// A summary of the requested room.
pub room: SpaceHierarchyParentSummary, pub room: SpaceHierarchyParentSummary,

View File

@ -12,7 +12,8 @@ pub mod v1 {
use std::collections::BTreeMap; use std::collections::BTreeMap;
use ruma_common::{ use ruma_common::{
api::ruma_api, thirdparty::Medium, RoomId, ServerName, ServerSigningKeyId, UserId, api::ruma_api, thirdparty::Medium, OwnedRoomId, OwnedServerName, OwnedUserId,
ServerSigningKeyId, UserId,
}; };
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
@ -78,26 +79,26 @@ pub mod v1 {
pub address: String, pub address: String,
/// The now-bound user ID that received the invite. /// The now-bound user ID that received the invite.
pub mxid: Box<UserId>, pub mxid: OwnedUserId,
/// The room ID the invite is valid for. /// The room ID the invite is valid for.
pub room_id: Box<RoomId>, pub room_id: OwnedRoomId,
/// The user ID that sent the invite. /// The user ID that sent the invite.
pub sender: Box<UserId>, pub sender: OwnedUserId,
/// Signature from the identity server using a long-term private key. /// Signature from the identity server using a long-term private key.
pub signed: BTreeMap<Box<ServerName>, BTreeMap<Box<ServerSigningKeyId>, String>>, pub signed: BTreeMap<OwnedServerName, BTreeMap<Box<ServerSigningKeyId>, String>>,
} }
impl ThirdPartyInvite { impl ThirdPartyInvite {
/// Creates a new third party invite with the given parameters. /// Creates a new third party invite with the given parameters.
pub fn new( pub fn new(
address: String, address: String,
mxid: Box<UserId>, mxid: OwnedUserId,
room_id: Box<RoomId>, room_id: OwnedRoomId,
sender: Box<UserId>, sender: OwnedUserId,
signed: BTreeMap<Box<ServerName>, BTreeMap<Box<ServerSigningKeyId>, String>>, signed: BTreeMap<OwnedServerName, BTreeMap<Box<ServerSigningKeyId>, String>>,
) -> Self { ) -> Self {
Self { medium: Medium::Email, address, mxid, room_id, sender, signed } Self { medium: Medium::Email, address, mxid, room_id, sender, signed }
} }

View File

@ -9,7 +9,7 @@ use ruma_common::{
presence::PresenceState, presence::PresenceState,
serde::{from_raw_json_value, Raw}, serde::{from_raw_json_value, Raw},
to_device::DeviceIdOrAllDevices, to_device::DeviceIdOrAllDevices,
DeviceId, EventId, RoomId, TransactionId, UserId, OwnedDeviceId, OwnedEventId, OwnedRoomId, OwnedTransactionId, OwnedUserId,
}; };
use serde::{de, Deserialize, Serialize}; use serde::{de, Deserialize, Serialize};
use serde_json::{value::RawValue as RawJsonValue, Value as JsonValue}; use serde_json::{value::RawValue as RawJsonValue, Value as JsonValue};
@ -103,7 +103,7 @@ impl PresenceContent {
#[cfg_attr(not(feature = "unstable-exhaustive-types"), non_exhaustive)] #[cfg_attr(not(feature = "unstable-exhaustive-types"), non_exhaustive)]
pub struct PresenceUpdate { pub struct PresenceUpdate {
/// The user ID this presence EDU is for. /// The user ID this presence EDU is for.
pub user_id: Box<UserId>, pub user_id: OwnedUserId,
/// The presence of the user. /// The presence of the user.
pub presence: PresenceState, pub presence: PresenceState,
@ -124,7 +124,7 @@ pub struct PresenceUpdate {
impl PresenceUpdate { impl PresenceUpdate {
/// Creates a new `PresenceUpdate` with the given `user_id`, `presence` and `last_activity`. /// Creates a new `PresenceUpdate` with the given `user_id`, `presence` and `last_activity`.
pub fn new(user_id: Box<UserId>, presence: PresenceState, last_activity: UInt) -> Self { pub fn new(user_id: OwnedUserId, presence: PresenceState, last_activity: UInt) -> Self {
Self { Self {
user_id, user_id,
presence, presence,
@ -141,12 +141,12 @@ impl PresenceUpdate {
pub struct ReceiptContent { pub struct ReceiptContent {
/// Receipts for a particular room. /// Receipts for a particular room.
#[serde(flatten)] #[serde(flatten)]
pub receipts: BTreeMap<Box<RoomId>, ReceiptMap>, pub receipts: BTreeMap<OwnedRoomId, ReceiptMap>,
} }
impl ReceiptContent { impl ReceiptContent {
/// Creates a new `ReceiptContent`. /// Creates a new `ReceiptContent`.
pub fn new(receipts: BTreeMap<Box<RoomId>, ReceiptMap>) -> Self { pub fn new(receipts: BTreeMap<OwnedRoomId, ReceiptMap>) -> Self {
Self { receipts } Self { receipts }
} }
} }
@ -157,12 +157,12 @@ impl ReceiptContent {
pub struct ReceiptMap { pub struct ReceiptMap {
/// Read receipts for users in the room. /// Read receipts for users in the room.
#[serde(rename = "m.read")] #[serde(rename = "m.read")]
pub read: BTreeMap<Box<UserId>, ReceiptData>, pub read: BTreeMap<OwnedUserId, ReceiptData>,
} }
impl ReceiptMap { impl ReceiptMap {
/// Creates a new `ReceiptMap`. /// Creates a new `ReceiptMap`.
pub fn new(read: BTreeMap<Box<UserId>, ReceiptData>) -> Self { pub fn new(read: BTreeMap<OwnedUserId, ReceiptData>) -> Self {
Self { read } Self { read }
} }
} }
@ -175,12 +175,12 @@ pub struct ReceiptData {
pub data: Receipt, pub data: Receipt,
/// The extremity event ID the user has read up to. /// The extremity event ID the user has read up to.
pub event_ids: Vec<Box<EventId>>, pub event_ids: Vec<OwnedEventId>,
} }
impl ReceiptData { impl ReceiptData {
/// Creates a new `ReceiptData`. /// Creates a new `ReceiptData`.
pub fn new(data: Receipt, event_ids: Vec<Box<EventId>>) -> Self { pub fn new(data: Receipt, event_ids: Vec<OwnedEventId>) -> Self {
Self { data, event_ids } Self { data, event_ids }
} }
} }
@ -190,10 +190,10 @@ impl ReceiptData {
#[cfg_attr(not(feature = "unstable-exhaustive-types"), non_exhaustive)] #[cfg_attr(not(feature = "unstable-exhaustive-types"), non_exhaustive)]
pub struct TypingContent { pub struct TypingContent {
/// The room where the user's typing status has been updated. /// The room where the user's typing status has been updated.
pub room_id: Box<RoomId>, pub room_id: OwnedRoomId,
/// The user ID that has had their typing status changed. /// The user ID that has had their typing status changed.
pub user_id: Box<UserId>, pub user_id: OwnedUserId,
/// Whether the user is typing in the room or not. /// Whether the user is typing in the room or not.
pub typing: bool, pub typing: bool,
@ -201,7 +201,7 @@ pub struct TypingContent {
impl TypingContent { impl TypingContent {
/// Creates a new `TypingContent`. /// Creates a new `TypingContent`.
pub fn new(room_id: Box<RoomId>, user_id: Box<UserId>, typing: bool) -> Self { pub fn new(room_id: OwnedRoomId, user_id: OwnedUserId, typing: bool) -> Self {
Self { room_id, user_id, typing } Self { room_id, user_id, typing }
} }
} }
@ -211,10 +211,10 @@ impl TypingContent {
#[cfg_attr(not(feature = "unstable-exhaustive-types"), non_exhaustive)] #[cfg_attr(not(feature = "unstable-exhaustive-types"), non_exhaustive)]
pub struct DeviceListUpdateContent { pub struct DeviceListUpdateContent {
/// The user ID who owns the device. /// The user ID who owns the device.
pub user_id: Box<UserId>, pub user_id: OwnedUserId,
/// The ID of the device whose details are changing. /// The ID of the device whose details are changing.
pub device_id: Box<DeviceId>, pub device_id: OwnedDeviceId,
/// The public human-readable name of this device. /// The public human-readable name of this device.
/// ///
@ -242,7 +242,7 @@ pub struct DeviceListUpdateContent {
impl DeviceListUpdateContent { impl DeviceListUpdateContent {
/// Create a new `DeviceListUpdateContent` with the given `user_id`, `device_id` and /// Create a new `DeviceListUpdateContent` with the given `user_id`, `device_id` and
/// `stream_id`. /// `stream_id`.
pub fn new(user_id: Box<UserId>, device_id: Box<DeviceId>, stream_id: UInt) -> Self { pub fn new(user_id: OwnedUserId, device_id: OwnedDeviceId, stream_id: UInt) -> Self {
Self { Self {
user_id, user_id,
device_id, device_id,
@ -260,14 +260,14 @@ impl DeviceListUpdateContent {
#[cfg_attr(not(feature = "unstable-exhaustive-types"), non_exhaustive)] #[cfg_attr(not(feature = "unstable-exhaustive-types"), non_exhaustive)]
pub struct DirectDeviceContent { pub struct DirectDeviceContent {
/// The user ID of the sender. /// The user ID of the sender.
pub sender: Box<UserId>, pub sender: OwnedUserId,
/// Event type for the message. /// Event type for the message.
#[serde(rename = "type")] #[serde(rename = "type")]
pub ev_type: ToDeviceEventType, pub ev_type: ToDeviceEventType,
/// Unique utf8 string ID for the message, used for idempotency. /// Unique utf8 string ID for the message, used for idempotency.
pub message_id: Box<TransactionId>, pub message_id: OwnedTransactionId,
/// The contents of the messages to be sent. /// The contents of the messages to be sent.
/// ///
@ -279,9 +279,9 @@ pub struct DirectDeviceContent {
impl DirectDeviceContent { impl DirectDeviceContent {
/// Creates a new `DirectDeviceContent` with the given `sender, `ev_type` and `message_id`. /// Creates a new `DirectDeviceContent` with the given `sender, `ev_type` and `message_id`.
pub fn new( pub fn new(
sender: Box<UserId>, sender: OwnedUserId,
ev_type: ToDeviceEventType, ev_type: ToDeviceEventType,
message_id: Box<TransactionId>, message_id: OwnedTransactionId,
) -> Self { ) -> Self {
Self { sender, ev_type, message_id, messages: DirectDeviceMessages::new() } Self { sender, ev_type, message_id, messages: DirectDeviceMessages::new() }
} }
@ -291,14 +291,14 @@ impl DirectDeviceContent {
/// ///
/// Represented as a map of `{ user-ids => { device-ids => message-content } }`. /// Represented as a map of `{ user-ids => { device-ids => message-content } }`.
pub type DirectDeviceMessages = pub type DirectDeviceMessages =
BTreeMap<Box<UserId>, BTreeMap<DeviceIdOrAllDevices, Raw<AnyToDeviceEventContent>>>; BTreeMap<OwnedUserId, BTreeMap<DeviceIdOrAllDevices, Raw<AnyToDeviceEventContent>>>;
/// The content for an `m.signing_key_update` EDU. /// The content for an `m.signing_key_update` EDU.
#[derive(Clone, Debug, Deserialize, Serialize)] #[derive(Clone, Debug, Deserialize, Serialize)]
#[cfg_attr(not(feature = "unstable-exhaustive-types"), non_exhaustive)] #[cfg_attr(not(feature = "unstable-exhaustive-types"), non_exhaustive)]
pub struct SigningKeyUpdateContent { pub struct SigningKeyUpdateContent {
/// The user ID whose cross-signing keys have changed. /// The user ID whose cross-signing keys have changed.
pub user_id: Box<UserId>, pub user_id: OwnedUserId,
/// The user's master key, if it was updated. /// The user's master key, if it was updated.
#[serde(skip_serializing_if = "Option::is_none")] #[serde(skip_serializing_if = "Option::is_none")]
@ -311,7 +311,7 @@ pub struct SigningKeyUpdateContent {
impl SigningKeyUpdateContent { impl SigningKeyUpdateContent {
/// Creates a new `SigningKeyUpdateContent`. /// Creates a new `SigningKeyUpdateContent`.
pub fn new(user_id: Box<UserId>) -> Self { pub fn new(user_id: OwnedUserId) -> Self {
Self { user_id, master_key: None, self_signing_key: None } Self { user_id, master_key: None, self_signing_key: None }
} }
} }

View File

@ -8,7 +8,7 @@ pub mod v2 {
//! [spec]: https://spec.matrix.org/v1.2/identity-service-api/#post_matrixidentityv23pidbind //! [spec]: https://spec.matrix.org/v1.2/identity-service-api/#post_matrixidentityv23pidbind
use ruma_common::{ use ruma_common::{
api::ruma_api, thirdparty::Medium, ClientSecret, MilliSecondsSinceUnixEpoch, api::ruma_api, thirdparty::Medium, ClientSecret, MilliSecondsSinceUnixEpoch, OwnedUserId,
ServerSignatures, SessionId, UserId, ServerSignatures, SessionId, UserId,
}; };
@ -42,7 +42,7 @@ pub mod v2 {
pub medium: Medium, pub medium: Medium,
/// The Matrix user ID associated with the 3PID. /// The Matrix user ID associated with the 3PID.
pub mxid: Box<UserId>, pub mxid: OwnedUserId,
/// A UNIX timestamp before which the association is not known to be valid. /// A UNIX timestamp before which the association is not known to be valid.
pub not_before: MilliSecondsSinceUnixEpoch, pub not_before: MilliSecondsSinceUnixEpoch,
@ -72,7 +72,7 @@ pub mod v2 {
pub fn new( pub fn new(
address: String, address: String,
medium: Medium, medium: Medium,
mxid: Box<UserId>, mxid: OwnedUserId,
not_before: MilliSecondsSinceUnixEpoch, not_before: MilliSecondsSinceUnixEpoch,
not_after: MilliSecondsSinceUnixEpoch, not_after: MilliSecondsSinceUnixEpoch,
ts: MilliSecondsSinceUnixEpoch, ts: MilliSecondsSinceUnixEpoch,

View File

@ -8,7 +8,7 @@ pub mod v2 {
//! [spec]: https://spec.matrix.org/v1.2/identity-service-api/#post_matrixidentityv2validateemailrequesttoken //! [spec]: https://spec.matrix.org/v1.2/identity-service-api/#post_matrixidentityv2validateemailrequesttoken
use js_int::UInt; use js_int::UInt;
use ruma_common::{api::ruma_api, ClientSecret, SessionId}; use ruma_common::{api::ruma_api, ClientSecret, OwnedSessionId};
ruma_api! { ruma_api! {
metadata: { metadata: {
@ -42,7 +42,7 @@ pub mod v2 {
/// The session ID. /// The session ID.
/// ///
/// Session IDs are opaque strings generated by the identity server. /// Session IDs are opaque strings generated by the identity server.
pub sid: Box<SessionId>, pub sid: OwnedSessionId,
} }
} }
@ -61,7 +61,7 @@ pub mod v2 {
impl Response { impl Response {
/// Create a new `Response` with the given session ID. /// Create a new `Response` with the given session ID.
pub fn new(sid: Box<SessionId>) -> Self { pub fn new(sid: OwnedSessionId) -> Self {
Self { sid } Self { sid }
} }
} }

View File

@ -8,7 +8,7 @@ pub mod v2 {
//! [spec]: https://spec.matrix.org/v1.2/identity-service-api/#post_matrixidentityv2validatemsisdnrequesttoken //! [spec]: https://spec.matrix.org/v1.2/identity-service-api/#post_matrixidentityv2validatemsisdnrequesttoken
use js_int::UInt; use js_int::UInt;
use ruma_common::{api::ruma_api, ClientSecret, SessionId}; use ruma_common::{api::ruma_api, ClientSecret, OwnedSessionId};
ruma_api! { ruma_api! {
metadata: { metadata: {
@ -47,7 +47,7 @@ pub mod v2 {
/// The session ID. /// The session ID.
/// ///
/// Session IDs are opaque strings generated by the identity server. /// Session IDs are opaque strings generated by the identity server.
pub sid: Box<SessionId>, pub sid: OwnedSessionId,
} }
} }
@ -67,7 +67,7 @@ pub mod v2 {
impl Response { impl Response {
/// Create a new `Response` with the given session ID. /// Create a new `Response` with the given session ID.
pub fn new(sid: Box<SessionId>) -> Self { pub fn new(sid: OwnedSessionId) -> Self {
Self { sid } Self { sid }
} }
} }

View File

@ -8,7 +8,7 @@ pub mod v2 {
//! [spec]: https://spec.matrix.org/v1.2/identity-service-api/#post_matrixidentityv23pidunbind //! [spec]: https://spec.matrix.org/v1.2/identity-service-api/#post_matrixidentityv23pidunbind
use ruma_common::{ use ruma_common::{
api::ruma_api, thirdparty::Medium, user_id::UserId, ClientSecret, SessionId, api::ruma_api, thirdparty::Medium, user_id::UserId, ClientSecret, OwnedSessionId,
}; };
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
@ -89,7 +89,7 @@ pub mod v2 {
#[cfg_attr(not(feature = "unstable-exhaustive-types"), non_exhaustive)] #[cfg_attr(not(feature = "unstable-exhaustive-types"), non_exhaustive)]
pub struct ThreePidOwnershipProof { pub struct ThreePidOwnershipProof {
/// The Session ID generated by the `requestToken` call. /// The Session ID generated by the `requestToken` call.
pub sid: Box<SessionId>, pub sid: OwnedSessionId,
/// The client secret passed to the `requestToken` call. /// The client secret passed to the `requestToken` call.
pub client_secret: Box<ClientSecret>, pub client_secret: Box<ClientSecret>,
@ -97,7 +97,7 @@ pub mod v2 {
impl ThreePidOwnershipProof { impl ThreePidOwnershipProof {
/// Creates a new `ThreePidOwnershipProof` with the given session ID and client secret. /// Creates a new `ThreePidOwnershipProof` with the given session ID and client secret.
pub fn new(sid: Box<SessionId>, client_secret: Box<ClientSecret>) -> Self { pub fn new(sid: OwnedSessionId, client_secret: Box<ClientSecret>) -> Self {
Self { sid, client_secret } Self { sid, client_secret }
} }
} }

View File

@ -7,7 +7,7 @@ pub mod v2 {
//! //!
//! [spec]: https://spec.matrix.org/v1.2/identity-service-api/#get_matrixidentityv2account //! [spec]: https://spec.matrix.org/v1.2/identity-service-api/#get_matrixidentityv2account
use ruma_common::{api::ruma_api, UserId}; use ruma_common::{api::ruma_api, OwnedUserId};
ruma_api! { ruma_api! {
metadata: { metadata: {
@ -25,7 +25,7 @@ pub mod v2 {
response: { response: {
/// The user ID which registered the token. /// The user ID which registered the token.
pub user_id: Box<UserId>, pub user_id: OwnedUserId,
} }
} }
@ -38,7 +38,7 @@ pub mod v2 {
impl Response { impl Response {
/// Creates a new `Response` with the given `UserId`. /// Creates a new `Response` with the given `UserId`.
pub fn new(user_id: Box<UserId>) -> Self { pub fn new(user_id: OwnedUserId) -> Self {
Self { user_id } Self { user_id }
} }
} }

View File

@ -7,7 +7,7 @@ pub mod v2 {
//! //!
//! [spec]: https://spec.matrix.org/v1.2/identity-service-api/#post_matrixidentityv2sign-ed25519 //! [spec]: https://spec.matrix.org/v1.2/identity-service-api/#post_matrixidentityv2sign-ed25519
use ruma_common::{api::ruma_api, serde::Base64, ServerSignatures, UserId}; use ruma_common::{api::ruma_api, serde::Base64, OwnedUserId, ServerSignatures, UserId};
ruma_api! { ruma_api! {
metadata: { metadata: {
@ -33,10 +33,10 @@ pub mod v2 {
response: { response: {
/// The Matrix user ID of the user accepting the invitation. /// The Matrix user ID of the user accepting the invitation.
pub mxid: Box<UserId>, pub mxid: OwnedUserId,
/// The Matrix user ID of the user who sent the invitation. /// The Matrix user ID of the user who sent the invitation.
pub sender: Box<UserId>, pub sender: OwnedUserId,
/// The signature of the mxid, sender and token. /// The signature of the mxid, sender and token.
pub signatures: ServerSignatures, pub signatures: ServerSignatures,
@ -57,8 +57,8 @@ pub mod v2 {
/// Creates a `Response` with the given Matrix user ID, sender user ID, signatures and /// Creates a `Response` with the given Matrix user ID, sender user ID, signatures and
/// token. /// token.
pub fn new( pub fn new(
mxid: Box<UserId>, mxid: OwnedUserId,
sender: Box<UserId>, sender: OwnedUserId,
signatures: ServerSignatures, signatures: ServerSignatures,
token: String, token: String,
) -> Self { ) -> Self {

View File

@ -9,7 +9,7 @@ pub mod v2 {
use std::collections::BTreeMap; use std::collections::BTreeMap;
use ruma_common::{api::ruma_api, UserId}; use ruma_common::{api::ruma_api, OwnedUserId};
use crate::lookup::IdentifierHashingAlgorithm; use crate::lookup::IdentifierHashingAlgorithm;
@ -45,7 +45,7 @@ pub mod v2 {
/// ///
/// Addresses which do not have associations will not be included, which can make this /// Addresses which do not have associations will not be included, which can make this
/// property be an empty object. /// property be an empty object.
pub mappings: BTreeMap<String, Box<UserId>>, pub mappings: BTreeMap<String, OwnedUserId>,
} }
} }
@ -63,7 +63,7 @@ pub mod v2 {
impl Response { impl Response {
/// Create a `Response` with the BTreeMap which map addresses from the request which were /// Create a `Response` with the BTreeMap which map addresses from the request which were
/// found to their corresponding User IDs. /// found to their corresponding User IDs.
pub fn new(mappings: BTreeMap<String, Box<UserId>>) -> Self { pub fn new(mappings: BTreeMap<String, OwnedUserId>) -> Self {
Self { mappings } Self { mappings }
} }
} }

View File

@ -10,7 +10,7 @@ use std::{
use base64::{encode_config, STANDARD_NO_PAD, URL_SAFE_NO_PAD}; use base64::{encode_config, STANDARD_NO_PAD, URL_SAFE_NO_PAD};
use ruma_common::{ use ruma_common::{
serde::{base64::Standard, Base64, CanonicalJsonObject, CanonicalJsonValue}, serde::{base64::Standard, Base64, CanonicalJsonObject, CanonicalJsonValue},
EventId, OwnedServerName, RoomVersionId, UserId, OwnedEventId, OwnedServerName, RoomVersionId, UserId,
}; };
use serde_json::{from_str as from_json_str, to_string as to_json_string}; use serde_json::{from_str as from_json_str, to_string as to_json_string};
use sha2::{digest::Digest, Sha256}; use sha2::{digest::Digest, Sha256};
@ -821,7 +821,7 @@ fn servers_to_check_signatures(
match version { match version {
RoomVersionId::V1 | RoomVersionId::V2 => match object.get("event_id") { RoomVersionId::V1 | RoomVersionId::V2 => match object.get("event_id") {
Some(CanonicalJsonValue::String(raw_event_id)) => { Some(CanonicalJsonValue::String(raw_event_id)) => {
let event_id: Box<EventId> = let event_id: OwnedEventId =
raw_event_id.parse().map_err(|e| Error::from(ParseError::EventId(e)))?; raw_event_id.parse().map_err(|e| Error::from(ParseError::EventId(e)))?;
let server_name = event_id let server_name = event_id

View File

@ -16,7 +16,7 @@ pub trait Event {
pub type StateMap<T> = BTreeMap<(EventType, Option<String>), T>; pub type StateMap<T> = BTreeMap<(EventType, Option<String>), T>;
/// A mapping of `EventId` to `T`, usually a `OriginalStateEvent`. /// A mapping of `EventId` to `T`, usually a `OriginalStateEvent`.
pub type EventMap<T> = BTreeMap<Box<EventId>, T>; pub type EventMap<T> = BTreeMap<OwnedEventId, T>;
struct StateResolution { struct StateResolution {
// For now the StateResolution struct is empty. If "caching" `event_map` // For now the StateResolution struct is empty. If "caching" `event_map`
@ -30,10 +30,10 @@ impl StateResolution {
pub fn resolve<E: Event>( pub fn resolve<E: Event>(
room_id: &RoomId, room_id: &RoomId,
room_version: &RoomVersionId, room_version: &RoomVersionId,
state_sets: &[StateMap<Box<EventId>>], state_sets: &[StateMap<OwnedEventId>],
auth_events: Vec<Vec<Box<EventId>>>, auth_events: Vec<Vec<OwnedEventId>>,
event_map: &mut EventMap<Arc<E>>, event_map: &mut EventMap<Arc<E>>,
) -> Result<StateMap<Box<EventId>>> {; ) -> Result<StateMap<OwnedEventId>> {;
} }
``` ```

View File

@ -170,7 +170,7 @@ impl<E: Event> TestStore<E> {
} }
/// Returns the events that correspond to the `event_ids` sorted in the same order. /// Returns the events that correspond to the `event_ids` sorted in the same order.
fn get_events(&self, room_id: &RoomId, event_ids: &[Box<EventId>]) -> Result<Vec<Arc<E>>> { fn get_events(&self, room_id: &RoomId, event_ids: &[OwnedEventId]) -> Result<Vec<Arc<E>>> {
let mut events = vec![]; let mut events = vec![];
for id in event_ids { for id in event_ids {
events.push(self.get_event(room_id, id)?); events.push(self.get_event(room_id, id)?);

View File

@ -13,7 +13,7 @@ use ruma_common::{
RoomEventType, StateEventType, RoomEventType, StateEventType,
}, },
serde::{Base64, Raw}, serde::{Base64, Raw},
RoomVersionId, UserId, OwnedUserId, RoomVersionId, UserId,
}; };
use serde::{de::IgnoredAny, Deserialize}; use serde::{de::IgnoredAny, Deserialize};
use serde_json::{from_str as from_json_str, value::RawValue as RawJsonValue}; use serde_json::{from_str as from_json_str, value::RawValue as RawJsonValue};
@ -30,7 +30,7 @@ struct GetMembership {
#[derive(Deserialize)] #[derive(Deserialize)]
struct RoomMemberContentFields { struct RoomMemberContentFields {
membership: Option<Raw<MembershipState>>, membership: Option<Raw<MembershipState>>,
join_authorised_via_users_server: Option<Raw<Box<UserId>>>, join_authorised_via_users_server: Option<Raw<OwnedUserId>>,
} }
#[derive(Deserialize)] #[derive(Deserialize)]
@ -65,7 +65,7 @@ pub fn auth_types_for_event(
struct RoomMemberContentFields { struct RoomMemberContentFields {
membership: Option<Raw<MembershipState>>, membership: Option<Raw<MembershipState>>,
third_party_invite: Option<Raw<ThirdPartyInvite>>, third_party_invite: Option<Raw<ThirdPartyInvite>>,
join_authorised_via_users_server: Option<Raw<Box<UserId>>>, join_authorised_via_users_server: Option<Raw<OwnedUserId>>,
} }
if let Some(state_key) = state_key { if let Some(state_key) = state_key {

View File

@ -12,7 +12,7 @@ use ruma_common::{
room::member::{MembershipState, RoomMemberEventContent}, room::member::{MembershipState, RoomMemberEventContent},
RoomEventType, StateEventType, RoomEventType, StateEventType,
}, },
EventId, MilliSecondsSinceUnixEpoch, RoomVersionId, UserId, EventId, MilliSecondsSinceUnixEpoch, OwnedUserId, RoomVersionId,
}; };
use serde::Deserialize; use serde::Deserialize;
use serde_json::from_str as from_json_str; use serde_json::from_str as from_json_str;
@ -342,7 +342,7 @@ struct PowerLevelsContentFields {
serde(deserialize_with = "ruma_common::serde::btreemap_deserialize_v1_powerlevel_values") serde(deserialize_with = "ruma_common::serde::btreemap_deserialize_v1_powerlevel_values")
)] )]
#[serde(default, skip_serializing_if = "BTreeMap::is_empty")] #[serde(default, skip_serializing_if = "BTreeMap::is_empty")]
users: BTreeMap<Box<UserId>, Int>, users: BTreeMap<OwnedUserId, Int>,
#[cfg_attr( #[cfg_attr(
feature = "compat", feature = "compat",