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
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;
ruma_api! {
@ -29,7 +31,7 @@ pub mod v1 {
/// The event IDs to backfill from.
#[ruma_api(query)]
pub v: &'a [Box<EventId>],
pub v: &'a [OwnedEventId],
/// The maximum number of PDUs to retrieve, including the given events.
#[ruma_api(query)]
@ -38,7 +40,7 @@ pub mod v1 {
response: {
/// 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.
pub origin_server_ts: MilliSecondsSinceUnixEpoch,
@ -53,7 +55,7 @@ pub mod v1 {
/// * the given room id.
/// * the event IDs to backfill from.
/// * 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 }
}
}
@ -64,7 +66,7 @@ pub mod v1 {
/// * the timestamp in milliseconds of when this transaction started.
/// * the list of persistent updates to rooms.
pub fn new(
origin: Box<ServerName>,
origin: OwnedServerName,
origin_server_ts: MilliSecondsSinceUnixEpoch,
pdus: Vec<Box<RawJsonValue>>,
) -> Self {

View File

@ -12,7 +12,7 @@ pub mod v1 {
api::ruma_api,
encryption::{CrossSigningKey, DeviceKeys},
serde::Raw,
DeviceId, UserId,
OwnedDeviceId, OwnedUserId, UserId,
};
use serde::{Deserialize, Serialize};
@ -37,7 +37,7 @@ pub mod v1 {
response: {
/// 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.
///
@ -69,7 +69,7 @@ pub mod v1 {
/// Creates a new `Response` with the given user id and stream id.
///
/// 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 {
user_id,
stream_id,
@ -85,7 +85,7 @@ pub mod v1 {
#[cfg_attr(not(feature = "unstable-exhaustive-types"), non_exhaustive)]
pub struct UserDevice {
/// The device ID.
pub device_id: Box<DeviceId>,
pub device_id: OwnedDeviceId,
/// Identity keys for the device.
pub keys: Raw<DeviceKeys>,
@ -97,7 +97,7 @@ pub mod v1 {
impl UserDevice {
/// 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 }
}
}

View File

@ -2,7 +2,7 @@
use std::collections::BTreeMap;
use ruma_common::{serde::Base64, MilliSecondsSinceUnixEpoch, ServerName, ServerSigningKeyId};
use ruma_common::{serde::Base64, MilliSecondsSinceUnixEpoch, OwnedServerName, ServerSigningKeyId};
use serde::{Deserialize, Serialize};
pub mod discover_homeserver;
@ -52,7 +52,7 @@ impl OldVerifyKey {
#[cfg_attr(not(feature = "unstable-exhaustive-types"), non_exhaustive)]
pub struct ServerSigningKeys {
/// DNS name of the homeserver.
pub server_name: Box<ServerName>,
pub server_name: OwnedServerName,
/// Public keys of the homeserver for verifying digital signatures.
pub verify_keys: BTreeMap<Box<ServerSigningKeyId>, VerifyKey>,
@ -63,7 +63,7 @@ pub struct ServerSigningKeys {
/// Digital signatures of this object signed using the verify_keys.
///
/// 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.
///
@ -75,7 +75,7 @@ impl ServerSigningKeys {
/// Creates a new `ServerSigningKeys` with the given server name and validity timestamp.
///
/// 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 {
server_name,
verify_keys: BTreeMap::new(),

View File

@ -2,7 +2,7 @@
//!
//! [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! {
metadata: {
@ -21,7 +21,7 @@ ruma_api! {
response: {
/// The server name to delegate server-server communications to, with optional port.
#[serde(rename = "m.server")]
pub server: Box<ServerName>,
pub server: OwnedServerName,
}
}
@ -34,7 +34,7 @@ impl Request {
impl Response {
/// Creates a new `Response` with the given homeserver.
pub fn new(server: Box<ServerName>) -> Self {
pub fn new(server: OwnedServerName) -> Self {
Self { server }
}
}

View File

@ -11,7 +11,7 @@ pub mod v2 {
use std::collections::BTreeMap;
use ruma_common::{
api::ruma_api, serde::Raw, MilliSecondsSinceUnixEpoch, ServerName, ServerSigningKeyId,
api::ruma_api, serde::Raw, MilliSecondsSinceUnixEpoch, OwnedServerName, ServerSigningKeyId,
};
use serde::{Deserialize, Serialize};
@ -37,7 +37,7 @@ pub mod v2 {
/// 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.
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.
pub fn new(
server_keys: BTreeMap<
Box<ServerName>,
OwnedServerName,
BTreeMap<Box<ServerSigningKeyId>, QueryCriteria>,
>,
) -> Self {

View File

@ -7,7 +7,7 @@ pub mod v1 {
//!
//! [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;
ruma_api! {
@ -29,7 +29,7 @@ pub mod v1 {
response: {
/// The `server_name` of the homeserver sending this transaction.
pub origin: Box<ServerName>,
pub origin: OwnedServerName,
/// Time on originating homeserver when this transaction started.
pub origin_server_ts: MilliSecondsSinceUnixEpoch,
@ -50,7 +50,7 @@ pub mod v1 {
impl Response {
/// Creates a new `Response` with the given server name, timestamp, and event.
pub fn new(
origin: Box<ServerName>,
origin: OwnedServerName,
origin_server_ts: MilliSecondsSinceUnixEpoch,
pdu: Box<RawJsonValue>,
) -> Self {

View File

@ -8,7 +8,7 @@ pub mod v1 {
//! [spec]: https://spec.matrix.org/v1.2/server-server-api/#post_matrixfederationv1get_missing_eventsroomid
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;
ruma_api! {
@ -42,10 +42,10 @@ pub mod v1 {
/// The latest event IDs that the sender already has.
///
/// 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.
pub latest_events: &'a [Box<EventId>],
pub latest_events: &'a [OwnedEventId],
}
#[derive(Default)]
@ -59,8 +59,8 @@ pub mod v1 {
/// Creates a new `Request` for events in the given room with the given constraints.
pub fn new(
room_id: &'a RoomId,
earliest_events: &'a [Box<EventId>],
latest_events: &'a [Box<EventId>],
earliest_events: &'a [OwnedEventId],
latest_events: &'a [OwnedEventId],
) -> Self {
Self {
room_id,

View File

@ -7,7 +7,7 @@ pub mod v1 {
//!
//! [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! {
metadata: {
@ -33,10 +33,10 @@ pub mod v1 {
response: {
/// The full set of authorization events that make up the state of the
/// 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.
pub pdu_ids: Vec<Box<EventId>>,
pub pdu_ids: Vec<OwnedEventId>,
}
}
@ -49,7 +49,7 @@ pub mod v1 {
impl Response {
/// 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 }
}
}

View File

@ -13,7 +13,7 @@ pub mod v1 {
api::ruma_api,
encryption::OneTimeKey,
serde::{Base64, Raw},
DeviceId, DeviceKeyAlgorithm, DeviceKeyId, UserId,
DeviceKeyAlgorithm, DeviceKeyId, OwnedDeviceId, OwnedUserId,
};
use serde::{Deserialize, Serialize};
@ -54,11 +54,11 @@ pub mod v1 {
}
/// 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
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
#[derive(Debug, Clone, Serialize, Deserialize)]
@ -68,14 +68,14 @@ pub mod v1 {
pub key: Base64,
/// Signature of the key object.
pub signatures: BTreeMap<Box<UserId>, BTreeMap<Box<DeviceKeyId>, String>>,
pub signatures: BTreeMap<OwnedUserId, BTreeMap<Box<DeviceKeyId>, String>>,
}
impl KeyObject {
/// Creates a new `KeyObject` with the given key and signatures.
pub fn new(
key: Base64,
signatures: BTreeMap<Box<UserId>, BTreeMap<Box<DeviceKeyId>, String>>,
signatures: BTreeMap<OwnedUserId, BTreeMap<Box<DeviceKeyId>, String>>,
) -> Self {
Self { key, signatures }
}

View File

@ -13,7 +13,7 @@ pub mod v1 {
api::ruma_api,
encryption::{CrossSigningKey, DeviceKeys},
serde::Raw,
DeviceId, UserId,
OwnedDeviceId, OwnedUserId,
};
ruma_api! {
@ -31,27 +31,27 @@ pub mod v1 {
/// The keys to be downloaded.
///
/// 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)]
response: {
/// 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.
#[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.
#[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 {
/// 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 }
}
}
@ -59,7 +59,7 @@ pub mod v1 {
impl Response {
/// Creates a new `Response` with the given device keys.
pub fn new(
device_keys: BTreeMap<Box<UserId>, BTreeMap<Box<DeviceId>, Raw<DeviceKeys>>>,
device_keys: BTreeMap<OwnedUserId, BTreeMap<OwnedDeviceId, Raw<DeviceKeys>>>,
) -> Self {
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
use ruma_common::{api::ruma_api, UserId};
use ruma_common::{api::ruma_api, OwnedUserId};
ruma_api! {
metadata: {
@ -28,7 +28,7 @@ pub mod v1 {
response: {
/// The Matrix User ID who generated the token.
pub sub: Box<UserId>,
pub sub: OwnedUserId,
}
}
@ -41,7 +41,7 @@ pub mod v1 {
impl Response {
/// Creates a new `Response` with the given user id.
pub fn new(sub: Box<UserId>) -> Self {
pub fn new(sub: OwnedUserId) -> Self {
Self { sub }
}
}

View File

@ -7,7 +7,7 @@ pub mod v1 {
//!
//! [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! {
metadata: {
@ -28,10 +28,10 @@ pub mod v1 {
response: {
/// 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.
pub servers: Vec<Box<ServerName>>,
pub servers: Vec<OwnedServerName>,
}
}
@ -44,7 +44,7 @@ pub mod v1 {
impl Response {
/// 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 }
}
}

View File

@ -3,7 +3,7 @@
use js_int::UInt;
use ruma_common::{
directory::PublicRoomJoinRule, events::space::child::HierarchySpaceChildEvent, room::RoomType,
serde::Raw, MxcUri, RoomAliasId, RoomId, RoomName,
serde::Raw, MxcUri, OwnedRoomAliasId, OwnedRoomId, RoomName,
};
use serde::{Deserialize, Serialize};
@ -22,7 +22,7 @@ pub struct SpaceHierarchyParentSummary {
feature = "compat",
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.
#[serde(skip_serializing_if = "Option::is_none")]
@ -32,7 +32,7 @@ pub struct SpaceHierarchyParentSummary {
pub num_joined_members: UInt,
/// The ID of the room.
pub room_id: Box<RoomId>,
pub room_id: OwnedRoomId,
/// The topic of the room, if any.
#[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
/// rules.
#[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`.
@ -86,7 +86,7 @@ pub struct SpaceHierarchyParentSummaryInit {
pub num_joined_members: UInt,
/// 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.
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
/// rules.
pub allowed_room_ids: Vec<Box<RoomId>>,
pub allowed_room_ids: Vec<OwnedRoomId>,
}
impl From<SpaceHierarchyParentSummaryInit> for SpaceHierarchyParentSummary {
@ -151,7 +151,7 @@ pub struct SpaceHierarchyChildSummary {
feature = "compat",
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.
#[serde(skip_serializing_if = "Option::is_none")]
@ -161,7 +161,7 @@ pub struct SpaceHierarchyChildSummary {
pub num_joined_members: UInt,
/// The ID of the room.
pub room_id: Box<RoomId>,
pub room_id: OwnedRoomId,
/// The topic of the room, if any.
#[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
/// rules.
#[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`.
@ -210,7 +210,7 @@ pub struct SpaceHierarchyChildSummaryInit {
pub num_joined_members: UInt,
/// 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.
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
/// rules.
pub allowed_room_ids: Vec<Box<RoomId>>,
pub allowed_room_ids: Vec<OwnedRoomId>,
}
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
use ruma_common::{api::ruma_api, RoomId};
use ruma_common::{api::ruma_api, OwnedRoomId, RoomId};
use crate::space::{SpaceHierarchyChildSummary, SpaceHierarchyParentSummary};
@ -46,7 +46,7 @@ pub mod v1 {
///
/// Rooms which the responding server cannot provide details on will be outright
/// excluded from the response instead.
pub inaccessible_children: Vec<Box<RoomId>>,
pub inaccessible_children: Vec<OwnedRoomId>,
/// A summary of the requested room.
pub room: SpaceHierarchyParentSummary,

View File

@ -12,7 +12,8 @@ pub mod v1 {
use std::collections::BTreeMap;
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};
@ -78,26 +79,26 @@ pub mod v1 {
pub address: String,
/// The now-bound user ID that received the invite.
pub mxid: Box<UserId>,
pub mxid: OwnedUserId,
/// The room ID the invite is valid for.
pub room_id: Box<RoomId>,
pub room_id: OwnedRoomId,
/// 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.
pub signed: BTreeMap<Box<ServerName>, BTreeMap<Box<ServerSigningKeyId>, String>>,
pub signed: BTreeMap<OwnedServerName, BTreeMap<Box<ServerSigningKeyId>, String>>,
}
impl ThirdPartyInvite {
/// Creates a new third party invite with the given parameters.
pub fn new(
address: String,
mxid: Box<UserId>,
room_id: Box<RoomId>,
sender: Box<UserId>,
signed: BTreeMap<Box<ServerName>, BTreeMap<Box<ServerSigningKeyId>, String>>,
mxid: OwnedUserId,
room_id: OwnedRoomId,
sender: OwnedUserId,
signed: BTreeMap<OwnedServerName, BTreeMap<Box<ServerSigningKeyId>, String>>,
) -> Self {
Self { medium: Medium::Email, address, mxid, room_id, sender, signed }
}

View File

@ -9,7 +9,7 @@ use ruma_common::{
presence::PresenceState,
serde::{from_raw_json_value, Raw},
to_device::DeviceIdOrAllDevices,
DeviceId, EventId, RoomId, TransactionId, UserId,
OwnedDeviceId, OwnedEventId, OwnedRoomId, OwnedTransactionId, OwnedUserId,
};
use serde::{de, Deserialize, Serialize};
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)]
pub struct PresenceUpdate {
/// The user ID this presence EDU is for.
pub user_id: Box<UserId>,
pub user_id: OwnedUserId,
/// The presence of the user.
pub presence: PresenceState,
@ -124,7 +124,7 @@ pub struct PresenceUpdate {
impl PresenceUpdate {
/// 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 {
user_id,
presence,
@ -141,12 +141,12 @@ impl PresenceUpdate {
pub struct ReceiptContent {
/// Receipts for a particular room.
#[serde(flatten)]
pub receipts: BTreeMap<Box<RoomId>, ReceiptMap>,
pub receipts: BTreeMap<OwnedRoomId, ReceiptMap>,
}
impl ReceiptContent {
/// Creates a new `ReceiptContent`.
pub fn new(receipts: BTreeMap<Box<RoomId>, ReceiptMap>) -> Self {
pub fn new(receipts: BTreeMap<OwnedRoomId, ReceiptMap>) -> Self {
Self { receipts }
}
}
@ -157,12 +157,12 @@ impl ReceiptContent {
pub struct ReceiptMap {
/// Read receipts for users in the room.
#[serde(rename = "m.read")]
pub read: BTreeMap<Box<UserId>, ReceiptData>,
pub read: BTreeMap<OwnedUserId, ReceiptData>,
}
impl ReceiptMap {
/// Creates a new `ReceiptMap`.
pub fn new(read: BTreeMap<Box<UserId>, ReceiptData>) -> Self {
pub fn new(read: BTreeMap<OwnedUserId, ReceiptData>) -> Self {
Self { read }
}
}
@ -175,12 +175,12 @@ pub struct ReceiptData {
pub data: Receipt,
/// The extremity event ID the user has read up to.
pub event_ids: Vec<Box<EventId>>,
pub event_ids: Vec<OwnedEventId>,
}
impl 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 }
}
}
@ -190,10 +190,10 @@ impl ReceiptData {
#[cfg_attr(not(feature = "unstable-exhaustive-types"), non_exhaustive)]
pub struct TypingContent {
/// 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.
pub user_id: Box<UserId>,
pub user_id: OwnedUserId,
/// Whether the user is typing in the room or not.
pub typing: bool,
@ -201,7 +201,7 @@ pub struct TypingContent {
impl 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 }
}
}
@ -211,10 +211,10 @@ impl TypingContent {
#[cfg_attr(not(feature = "unstable-exhaustive-types"), non_exhaustive)]
pub struct DeviceListUpdateContent {
/// 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.
pub device_id: Box<DeviceId>,
pub device_id: OwnedDeviceId,
/// The public human-readable name of this device.
///
@ -242,7 +242,7 @@ pub struct DeviceListUpdateContent {
impl DeviceListUpdateContent {
/// Create a new `DeviceListUpdateContent` with the given `user_id`, `device_id` and
/// `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 {
user_id,
device_id,
@ -260,14 +260,14 @@ impl DeviceListUpdateContent {
#[cfg_attr(not(feature = "unstable-exhaustive-types"), non_exhaustive)]
pub struct DirectDeviceContent {
/// The user ID of the sender.
pub sender: Box<UserId>,
pub sender: OwnedUserId,
/// Event type for the message.
#[serde(rename = "type")]
pub ev_type: ToDeviceEventType,
/// 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.
///
@ -279,9 +279,9 @@ pub struct DirectDeviceContent {
impl DirectDeviceContent {
/// Creates a new `DirectDeviceContent` with the given `sender, `ev_type` and `message_id`.
pub fn new(
sender: Box<UserId>,
sender: OwnedUserId,
ev_type: ToDeviceEventType,
message_id: Box<TransactionId>,
message_id: OwnedTransactionId,
) -> Self {
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 } }`.
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.
#[derive(Clone, Debug, Deserialize, Serialize)]
#[cfg_attr(not(feature = "unstable-exhaustive-types"), non_exhaustive)]
pub struct SigningKeyUpdateContent {
/// 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.
#[serde(skip_serializing_if = "Option::is_none")]
@ -311,7 +311,7 @@ pub struct SigningKeyUpdateContent {
impl 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 }
}
}

View File

@ -8,7 +8,7 @@ pub mod v2 {
//! [spec]: https://spec.matrix.org/v1.2/identity-service-api/#post_matrixidentityv23pidbind
use ruma_common::{
api::ruma_api, thirdparty::Medium, ClientSecret, MilliSecondsSinceUnixEpoch,
api::ruma_api, thirdparty::Medium, ClientSecret, MilliSecondsSinceUnixEpoch, OwnedUserId,
ServerSignatures, SessionId, UserId,
};
@ -42,7 +42,7 @@ pub mod v2 {
pub medium: Medium,
/// 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.
pub not_before: MilliSecondsSinceUnixEpoch,
@ -72,7 +72,7 @@ pub mod v2 {
pub fn new(
address: String,
medium: Medium,
mxid: Box<UserId>,
mxid: OwnedUserId,
not_before: MilliSecondsSinceUnixEpoch,
not_after: MilliSecondsSinceUnixEpoch,
ts: MilliSecondsSinceUnixEpoch,

View File

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

View File

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

View File

@ -8,7 +8,7 @@ pub mod v2 {
//! [spec]: https://spec.matrix.org/v1.2/identity-service-api/#post_matrixidentityv23pidunbind
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};
@ -89,7 +89,7 @@ pub mod v2 {
#[cfg_attr(not(feature = "unstable-exhaustive-types"), non_exhaustive)]
pub struct ThreePidOwnershipProof {
/// The Session ID generated by the `requestToken` call.
pub sid: Box<SessionId>,
pub sid: OwnedSessionId,
/// The client secret passed to the `requestToken` call.
pub client_secret: Box<ClientSecret>,
@ -97,7 +97,7 @@ pub mod v2 {
impl ThreePidOwnershipProof {
/// 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 }
}
}

View File

@ -7,7 +7,7 @@ pub mod v2 {
//!
//! [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! {
metadata: {
@ -25,7 +25,7 @@ pub mod v2 {
response: {
/// 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 {
/// 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 }
}
}

View File

@ -7,7 +7,7 @@ pub mod v2 {
//!
//! [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! {
metadata: {
@ -33,10 +33,10 @@ pub mod v2 {
response: {
/// 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.
pub sender: Box<UserId>,
pub sender: OwnedUserId,
/// The signature of the mxid, sender and token.
pub signatures: ServerSignatures,
@ -57,8 +57,8 @@ pub mod v2 {
/// Creates a `Response` with the given Matrix user ID, sender user ID, signatures and
/// token.
pub fn new(
mxid: Box<UserId>,
sender: Box<UserId>,
mxid: OwnedUserId,
sender: OwnedUserId,
signatures: ServerSignatures,
token: String,
) -> Self {

View File

@ -9,7 +9,7 @@ pub mod v2 {
use std::collections::BTreeMap;
use ruma_common::{api::ruma_api, UserId};
use ruma_common::{api::ruma_api, OwnedUserId};
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
/// 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 {
/// Create a `Response` with the BTreeMap which map addresses from the request which were
/// 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 }
}
}

View File

@ -10,7 +10,7 @@ use std::{
use base64::{encode_config, STANDARD_NO_PAD, URL_SAFE_NO_PAD};
use ruma_common::{
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 sha2::{digest::Digest, Sha256};
@ -821,7 +821,7 @@ fn servers_to_check_signatures(
match version {
RoomVersionId::V1 | RoomVersionId::V2 => match object.get("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)))?;
let server_name = event_id

View File

@ -16,7 +16,7 @@ pub trait Event {
pub type StateMap<T> = BTreeMap<(EventType, Option<String>), T>;
/// 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 {
// For now the StateResolution struct is empty. If "caching" `event_map`
@ -30,10 +30,10 @@ impl StateResolution {
pub fn resolve<E: Event>(
room_id: &RoomId,
room_version: &RoomVersionId,
state_sets: &[StateMap<Box<EventId>>],
auth_events: Vec<Vec<Box<EventId>>>,
state_sets: &[StateMap<OwnedEventId>],
auth_events: Vec<Vec<OwnedEventId>>,
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.
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![];
for id in event_ids {
events.push(self.get_event(room_id, id)?);

View File

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

View File

@ -12,7 +12,7 @@ use ruma_common::{
room::member::{MembershipState, RoomMemberEventContent},
RoomEventType, StateEventType,
},
EventId, MilliSecondsSinceUnixEpoch, RoomVersionId, UserId,
EventId, MilliSecondsSinceUnixEpoch, OwnedUserId, RoomVersionId,
};
use serde::Deserialize;
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(default, skip_serializing_if = "BTreeMap::is_empty")]
users: BTreeMap<Box<UserId>, Int>,
users: BTreeMap<OwnedUserId, Int>,
#[cfg_attr(
feature = "compat",