identifiers: Remove Box<$id> aliases

This commit is contained in:
Jonas Platte 2021-09-17 20:46:57 +02:00
parent c38084432f
commit 438efee143
No known key found for this signature in database
GPG Key ID: 7D261D771D915378
58 changed files with 186 additions and 202 deletions

View File

@ -1,7 +1,7 @@
//! [POST /_matrix/client/r0/register](https://matrix.org/docs/spec/client_server/r0.6.1#post-matrix-client-r0-register) //! [POST /_matrix/client/r0/register](https://matrix.org/docs/spec/client_server/r0.6.1#post-matrix-client-r0-register)
use ruma_api::ruma_api; use ruma_api::ruma_api;
use ruma_identifiers::{DeviceId, DeviceIdBox, UserId}; use ruma_identifiers::{DeviceId, UserId};
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
use crate::r0::uiaa::{AuthData, IncomingAuthData, UiaaResponse}; use crate::r0::uiaa::{AuthData, IncomingAuthData, UiaaResponse};
@ -88,7 +88,7 @@ ruma_api! {
/// ID of the registered device. /// ID of the registered device.
/// ///
/// Will be the same as the corresponding parameter in the request, if one was specified. /// Will be the same as the corresponding parameter in the request, if one was specified.
pub device_id: Option<DeviceIdBox>, pub device_id: Option<Box<DeviceId>>,
} }
error: UiaaResponse error: UiaaResponse

View File

@ -2,7 +2,7 @@
use js_int::UInt; use js_int::UInt;
use ruma_api::ruma_api; use ruma_api::ruma_api;
use ruma_identifiers::{ClientSecret, SessionIdBox}; use ruma_identifiers::{ClientSecret, SessionId};
use super::{IdentityServerInfo, IncomingIdentityServerInfo}; use super::{IdentityServerInfo, IncomingIdentityServerInfo};
@ -39,7 +39,7 @@ ruma_api! {
response: { response: {
/// The session identifier given by the identity server. /// The session identifier given by the identity server.
pub sid: SessionIdBox, pub sid: Box<SessionId>,
/// URL to submit validation token to. /// URL to submit validation token to.
/// ///
@ -67,7 +67,7 @@ impl<'a> Request<'a> {
impl Response { impl Response {
/// Creates a new `Response` with the given session identifier. /// Creates a new `Response` with the given session identifier.
pub fn new(sid: SessionIdBox) -> Self { pub fn new(sid: Box<SessionId>) -> Self {
Self { sid, submit_url: None } Self { sid, submit_url: None }
} }
} }

View File

@ -2,7 +2,7 @@
use js_int::UInt; use js_int::UInt;
use ruma_api::ruma_api; use ruma_api::ruma_api;
use ruma_identifiers::{ClientSecret, SessionIdBox}; use ruma_identifiers::{ClientSecret, SessionId};
use super::{IdentityServerInfo, IncomingIdentityServerInfo}; use super::{IdentityServerInfo, IncomingIdentityServerInfo};
@ -42,7 +42,7 @@ ruma_api! {
response: { response: {
/// The session identifier given by the identity server. /// The session identifier given by the identity server.
pub sid: SessionIdBox, pub sid: Box<SessionId>,
/// URL to submit validation token to. /// URL to submit validation token to.
/// ///
@ -83,7 +83,7 @@ impl<'a> Request<'a> {
impl Response { impl Response {
/// Creates a new `Response` with the given session identifier. /// Creates a new `Response` with the given session identifier.
pub fn new(sid: SessionIdBox) -> Self { pub fn new(sid: Box<SessionId>) -> Self {
Self { sid, submit_url: None } Self { sid, submit_url: None }
} }
} }

View File

@ -4,7 +4,7 @@ use std::time::Duration;
use ruma_api::ruma_api; use ruma_api::ruma_api;
use ruma_common::authentication::TokenType; use ruma_common::authentication::TokenType;
use ruma_identifiers::{ServerNameBox, UserId}; use ruma_identifiers::{ServerName, UserId};
ruma_api! { ruma_api! {
metadata: { metadata: {
@ -30,7 +30,7 @@ ruma_api! {
pub token_type: TokenType, pub token_type: TokenType,
/// Homeserver domain for verification of user's identity. /// Homeserver domain for verification of user's identity.
pub matrix_server_name: ServerNameBox, pub matrix_server_name: Box<ServerName>,
/// Seconds until token expiration. /// Seconds until token expiration.
#[serde(with = "ruma_serde::duration::secs")] #[serde(with = "ruma_serde::duration::secs")]
@ -53,7 +53,7 @@ impl Response {
pub fn new( pub fn new(
access_token: String, access_token: String,
token_type: TokenType, token_type: TokenType,
matrix_server_name: ServerNameBox, matrix_server_name: Box<ServerName>,
expires_in: Duration, expires_in: Duration,
) -> Self { ) -> Self {
Self { access_token, token_type, matrix_server_name, expires_in } Self { access_token, token_type, matrix_server_name, expires_in }

View File

@ -2,7 +2,7 @@
use js_int::UInt; use js_int::UInt;
use ruma_api::ruma_api; use ruma_api::ruma_api;
use ruma_identifiers::{ClientSecret, SessionIdBox}; use ruma_identifiers::{ClientSecret, SessionId};
use super::{IdentityServerInfo, IncomingIdentityServerInfo}; use super::{IdentityServerInfo, IncomingIdentityServerInfo};
@ -39,7 +39,7 @@ ruma_api! {
response: { response: {
/// The session identifier given by the identity server. /// The session identifier given by the identity server.
pub sid: SessionIdBox, pub sid: Box<SessionId>,
/// URL to submit validation token to. /// URL to submit validation token to.
/// ///
@ -68,7 +68,7 @@ impl<'a> Request<'a> {
impl Response { impl Response {
/// Creates a new `Response` with the given session identifier. /// Creates a new `Response` with the given session identifier.
pub fn new(sid: SessionIdBox) -> Self { pub fn new(sid: Box<SessionId>) -> Self {
Self { sid, submit_url: None } Self { sid, submit_url: None }
} }
} }

View File

@ -2,7 +2,7 @@
use js_int::UInt; use js_int::UInt;
use ruma_api::ruma_api; use ruma_api::ruma_api;
use ruma_identifiers::{ClientSecret, SessionIdBox}; use ruma_identifiers::{ClientSecret, SessionId};
ruma_api! { ruma_api! {
metadata: { metadata: {
@ -34,7 +34,7 @@ ruma_api! {
response: { response: {
/// The session identifier given by the identity server. /// The session identifier given by the identity server.
pub sid: SessionIdBox, pub sid: Box<SessionId>,
/// URL to submit validation token to. /// URL to submit validation token to.
/// ///
@ -68,7 +68,7 @@ impl<'a> Request<'a> {
impl Response { impl Response {
/// Creates a new `Response` with the given session identifier. /// Creates a new `Response` with the given session identifier.
pub fn new(sid: SessionIdBox) -> Self { pub fn new(sid: Box<SessionId>) -> Self {
Self { sid, submit_url: None } Self { sid, submit_url: None }
} }
} }

View File

@ -2,7 +2,7 @@
use js_int::UInt; use js_int::UInt;
use ruma_api::ruma_api; use ruma_api::ruma_api;
use ruma_identifiers::{ClientSecret, SessionIdBox}; use ruma_identifiers::{ClientSecret, SessionId};
use super::{IdentityServerInfo, IncomingIdentityServerInfo}; use super::{IdentityServerInfo, IncomingIdentityServerInfo};
@ -39,7 +39,7 @@ ruma_api! {
response: { response: {
/// The session identifier given by the identity server. /// The session identifier given by the identity server.
pub sid: SessionIdBox, pub sid: Box<SessionId>,
/// URL to submit validation token to. /// URL to submit validation token to.
/// ///
@ -68,7 +68,7 @@ impl<'a> Request<'a> {
impl Response { impl Response {
/// Creates a new `Response` with the given session identifier. /// Creates a new `Response` with the given session identifier.
pub fn new(sid: SessionIdBox) -> Self { pub fn new(sid: Box<SessionId>) -> Self {
Self { sid, submit_url: None } Self { sid, submit_url: None }
} }
} }

View File

@ -2,7 +2,7 @@
use js_int::UInt; use js_int::UInt;
use ruma_api::ruma_api; use ruma_api::ruma_api;
use ruma_identifiers::{ClientSecret, SessionIdBox}; use ruma_identifiers::{ClientSecret, SessionId};
use super::{IdentityServerInfo, IncomingIdentityServerInfo}; use super::{IdentityServerInfo, IncomingIdentityServerInfo};
@ -42,7 +42,7 @@ ruma_api! {
response: { response: {
/// The session identifier given by the identity server. /// The session identifier given by the identity server.
pub sid: SessionIdBox, pub sid: Box<SessionId>,
/// URL to submit validation token to. /// URL to submit validation token to.
/// ///
@ -83,7 +83,7 @@ impl<'a> Request<'a> {
impl Response { impl Response {
/// Creates a new `Response` with the given session identifier. /// Creates a new `Response` with the given session identifier.
pub fn new(sid: SessionIdBox) -> Self { pub fn new(sid: Box<SessionId>) -> Self {
Self { sid, submit_url: None } Self { sid, submit_url: None }
} }
} }

View File

@ -1,7 +1,7 @@
//! [GET /_matrix/client/r0/directory/room/{roomAlias}](https://matrix.org/docs/spec/client_server/r0.6.1#get-matrix-client-r0-directory-room-roomalias) //! [GET /_matrix/client/r0/directory/room/{roomAlias}](https://matrix.org/docs/spec/client_server/r0.6.1#get-matrix-client-r0-directory-room-roomalias)
use ruma_api::ruma_api; use ruma_api::ruma_api;
use ruma_identifiers::{RoomAliasId, RoomId, ServerNameBox}; use ruma_identifiers::{RoomAliasId, RoomId, ServerName};
ruma_api! { ruma_api! {
metadata: { metadata: {
@ -24,7 +24,7 @@ ruma_api! {
pub room_id: RoomId, pub room_id: RoomId,
/// A list of servers that are aware of this room ID. /// A list of servers that are aware of this room ID.
pub servers: Vec<ServerNameBox>, pub servers: Vec<Box<ServerName>>,
} }
error: crate::Error error: crate::Error
@ -39,7 +39,7 @@ impl<'a> Request<'a> {
impl Response { impl Response {
/// Creates a new `Response` with the given room id and servers /// Creates a new `Response` with the given room id and servers
pub fn new(room_id: RoomId, servers: Vec<ServerNameBox>) -> Self { pub fn new(room_id: RoomId, servers: Vec<Box<ServerName>>) -> Self {
Self { room_id, servers } Self { room_id, servers }
} }
} }

View File

@ -1,7 +1,7 @@
//! Endpoints for managing devices. //! Endpoints for managing devices.
use ruma_common::MilliSecondsSinceUnixEpoch; use ruma_common::MilliSecondsSinceUnixEpoch;
use ruma_identifiers::DeviceIdBox; use ruma_identifiers::DeviceId;
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
pub mod delete_device; pub mod delete_device;
@ -15,7 +15,7 @@ pub mod update_device;
#[cfg_attr(not(feature = "unstable-exhaustive-types"), non_exhaustive)] #[cfg_attr(not(feature = "unstable-exhaustive-types"), non_exhaustive)]
pub struct Device { pub struct Device {
/// Device ID /// Device ID
pub device_id: DeviceIdBox, pub device_id: Box<DeviceId>,
/// Public display name of the device. /// Public display name of the device.
pub display_name: Option<String>, pub display_name: Option<String>,
@ -30,7 +30,7 @@ pub struct Device {
impl Device { impl Device {
/// Creates a new `Device` with the given device ID. /// Creates a new `Device` with the given device ID.
pub fn new(device_id: DeviceIdBox) -> Self { pub fn new(device_id: Box<DeviceId>) -> Self {
Self { device_id, display_name: None, last_seen_ip: None, last_seen_ts: None } Self { device_id, display_name: None, last_seen_ip: None, last_seen_ts: None }
} }
} }

View File

@ -1,7 +1,7 @@
//! [POST /_matrix/client/r0/delete_devices](https://matrix.org/docs/spec/client_server/r0.6.1#post-matrix-client-r0-delete-devices) //! [POST /_matrix/client/r0/delete_devices](https://matrix.org/docs/spec/client_server/r0.6.1#post-matrix-client-r0-delete-devices)
use ruma_api::ruma_api; use ruma_api::ruma_api;
use ruma_identifiers::DeviceIdBox; use ruma_identifiers::DeviceId;
use crate::r0::uiaa::{AuthData, IncomingAuthData, UiaaResponse}; use crate::r0::uiaa::{AuthData, IncomingAuthData, UiaaResponse};
@ -17,7 +17,7 @@ ruma_api! {
request: { request: {
/// List of devices to delete. /// List of devices to delete.
pub devices: &'a [DeviceIdBox], pub devices: &'a [Box<DeviceId>],
/// Additional authentication information for the user-interactive authentication API. /// Additional authentication information for the user-interactive authentication API.
#[serde(skip_serializing_if = "Option::is_none")] #[serde(skip_serializing_if = "Option::is_none")]
@ -32,7 +32,7 @@ ruma_api! {
impl<'a> Request<'a> { impl<'a> Request<'a> {
/// Creates a new `Request` with the given device list. /// Creates a new `Request` with the given device list.
pub fn new(devices: &'a [DeviceIdBox]) -> Self { pub fn new(devices: &'a [Box<DeviceId>]) -> Self {
Self { devices, auth: None } Self { devices, auth: None }
} }
} }

View File

@ -8,7 +8,7 @@ pub mod set_room_visibility;
use js_int::{uint, UInt}; use js_int::{uint, UInt};
#[cfg(feature = "unstable-pre-spec")] #[cfg(feature = "unstable-pre-spec")]
use ruma_events::room::join_rules::JoinRule; use ruma_events::room::join_rules::JoinRule;
use ruma_identifiers::{MxcUri, RoomAliasId, RoomId, RoomNameBox}; use ruma_identifiers::{MxcUri, RoomAliasId, RoomId, RoomName};
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
/// A chunk of a room list response, describing one room /// A chunk of a room list response, describing one room
@ -25,7 +25,7 @@ pub struct PublicRoomsChunk {
/// 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")]
pub name: Option<RoomNameBox>, pub name: Option<Box<RoomName>>,
/// The number of members joined to the room. /// The number of members joined to the room.
pub num_joined_members: UInt, pub num_joined_members: UInt,

View File

@ -4,7 +4,7 @@ use std::{collections::BTreeMap, time::Duration};
use ruma_api::ruma_api; use ruma_api::ruma_api;
use ruma_common::encryption::OneTimeKey; use ruma_common::encryption::OneTimeKey;
use ruma_identifiers::{DeviceIdBox, DeviceKeyAlgorithm, DeviceKeyId, UserId}; use ruma_identifiers::{DeviceId, DeviceKeyAlgorithm, DeviceKeyId, UserId};
use serde_json::Value as JsonValue; use serde_json::Value as JsonValue;
ruma_api! { ruma_api! {
@ -28,7 +28,7 @@ ruma_api! {
pub timeout: Option<Duration>, pub timeout: Option<Duration>,
/// The keys to be claimed. /// The keys to be claimed.
pub one_time_keys: BTreeMap<UserId, BTreeMap<DeviceIdBox, DeviceKeyAlgorithm>>, pub one_time_keys: BTreeMap<UserId, BTreeMap<Box<DeviceId>, DeviceKeyAlgorithm>>,
} }
response: { response: {
@ -45,7 +45,9 @@ ruma_api! {
impl Request { impl Request {
/// Creates a new `Request` with the given key claims and the recommended 10 second timeout. /// Creates a new `Request` with the given key claims and the recommended 10 second timeout.
pub fn new(one_time_keys: BTreeMap<UserId, BTreeMap<DeviceIdBox, DeviceKeyAlgorithm>>) -> Self { pub fn new(
one_time_keys: BTreeMap<UserId, BTreeMap<Box<DeviceId>, DeviceKeyAlgorithm>>,
) -> Self {
Self { timeout: Some(Duration::from_secs(10)), one_time_keys } Self { timeout: Some(Duration::from_secs(10)), one_time_keys }
} }
} }
@ -58,4 +60,4 @@ impl Response {
} }
/// The one-time keys for a given device. /// The one-time keys for a given device.
pub type OneTimeKeys = BTreeMap<DeviceIdBox, BTreeMap<DeviceKeyId, OneTimeKey>>; pub type OneTimeKeys = BTreeMap<Box<DeviceId>, BTreeMap<DeviceKeyId, OneTimeKey>>;

View File

@ -4,7 +4,7 @@ use std::{collections::BTreeMap, time::Duration};
use ruma_api::ruma_api; use ruma_api::ruma_api;
use ruma_common::encryption::DeviceKeys; use ruma_common::encryption::DeviceKeys;
use ruma_identifiers::{DeviceIdBox, UserId}; use ruma_identifiers::{DeviceId, UserId};
use serde_json::Value as JsonValue; use serde_json::Value as JsonValue;
#[cfg(feature = "unstable-pre-spec")] #[cfg(feature = "unstable-pre-spec")]
@ -35,7 +35,7 @@ ruma_api! {
/// The keys to be downloaded. /// The keys to be downloaded.
/// ///
/// An empty list indicates all devices for the corresponding user. /// An empty list indicates all devices for the corresponding user.
pub device_keys: BTreeMap<UserId, Vec<DeviceIdBox>>, pub device_keys: BTreeMap<UserId, Vec<Box<DeviceId>>>,
/// If the client is fetching keys as a result of a device update received in a sync /// If the client is fetching keys as a result of a device update received in a sync
/// request, this should be the 'since' token of that sync request, or any later sync token. /// request, this should be the 'since' token of that sync request, or any later sync token.
@ -56,7 +56,7 @@ ruma_api! {
/// Information on the queried devices. /// Information on the queried devices.
#[serde(default, skip_serializing_if = "BTreeMap::is_empty")] #[serde(default, skip_serializing_if = "BTreeMap::is_empty")]
pub device_keys: BTreeMap<UserId, BTreeMap<DeviceIdBox, DeviceKeys>>, pub device_keys: BTreeMap<UserId, BTreeMap<Box<DeviceId>, DeviceKeys>>,
/// Information on the master cross-signing keys of the queried users. /// Information on the master cross-signing keys of the queried users.
#[cfg(feature = "unstable-pre-spec")] #[cfg(feature = "unstable-pre-spec")]

View File

@ -1,7 +1,7 @@
//! [POST /_matrix/client/r0/knock/{roomIdOrAlias}](https://spec.matrix.org/unstable/client-server-api/#post_matrixclientr0knockroomidoralias) //! [POST /_matrix/client/r0/knock/{roomIdOrAlias}](https://spec.matrix.org/unstable/client-server-api/#post_matrixclientr0knockroomidoralias)
use ruma_api::ruma_api; use ruma_api::ruma_api;
use ruma_identifiers::{RoomId, RoomIdOrAliasId, ServerNameBox}; use ruma_identifiers::{RoomId, RoomIdOrAliasId, ServerName};
ruma_api! { ruma_api! {
metadata: { metadata: {
@ -27,7 +27,7 @@ ruma_api! {
/// One of the servers must be participating in the room. /// One of the servers must be participating in the room.
#[ruma_api(query)] #[ruma_api(query)]
#[serde(default, skip_serializing_if = "<[_]>::is_empty")] #[serde(default, skip_serializing_if = "<[_]>::is_empty")]
pub server_name: &'a [ServerNameBox], pub server_name: &'a [Box<ServerName>],
} }
response: { response: {

View File

@ -15,7 +15,7 @@ pub mod unban_user;
use std::collections::BTreeMap; use std::collections::BTreeMap;
use ruma_common::thirdparty::Medium; use ruma_common::thirdparty::Medium;
use ruma_identifiers::{ServerNameBox, ServerSigningKeyId, UserId}; use ruma_identifiers::{ServerName, ServerSigningKeyId, UserId};
use ruma_serde::Outgoing; use ruma_serde::Outgoing;
use serde::Serialize; use serde::Serialize;
@ -34,7 +34,7 @@ pub struct ThirdPartySigned<'a> {
pub token: &'a str, pub token: &'a str,
/// A signatures object containing a signature of the entire signed object. /// A signatures object containing a signature of the entire signed object.
pub signatures: BTreeMap<ServerNameBox, BTreeMap<ServerSigningKeyId, String>>, pub signatures: BTreeMap<Box<ServerName>, BTreeMap<ServerSigningKeyId, String>>,
} }
impl<'a> ThirdPartySigned<'a> { impl<'a> ThirdPartySigned<'a> {
@ -44,7 +44,7 @@ impl<'a> ThirdPartySigned<'a> {
sender: &'a UserId, sender: &'a UserId,
mxid: &'a UserId, mxid: &'a UserId,
token: &'a str, token: &'a str,
signatures: BTreeMap<ServerNameBox, BTreeMap<ServerSigningKeyId, String>>, signatures: BTreeMap<Box<ServerName>, BTreeMap<ServerSigningKeyId, String>>,
) -> Self { ) -> Self {
Self { sender, mxid, token, signatures } Self { sender, mxid, token, signatures }
} }

View File

@ -1,7 +1,7 @@
//! [POST /_matrix/client/r0/join/{roomIdOrAlias}](https://matrix.org/docs/spec/client_server/r0.6.1#post-matrix-client-r0-join-roomidoralias) //! [POST /_matrix/client/r0/join/{roomIdOrAlias}](https://matrix.org/docs/spec/client_server/r0.6.1#post-matrix-client-r0-join-roomidoralias)
use ruma_api::ruma_api; use ruma_api::ruma_api;
use ruma_identifiers::{RoomId, RoomIdOrAliasId, ServerNameBox}; use ruma_identifiers::{RoomId, RoomIdOrAliasId, ServerName};
use super::{IncomingThirdPartySigned, ThirdPartySigned}; use super::{IncomingThirdPartySigned, ThirdPartySigned};
@ -25,7 +25,7 @@ ruma_api! {
/// One of the servers must be participating in the room. /// One of the servers must be participating in the room.
#[ruma_api(query)] #[ruma_api(query)]
#[serde(default, skip_serializing_if = "<[_]>::is_empty")] #[serde(default, skip_serializing_if = "<[_]>::is_empty")]
pub server_name: &'a [ServerNameBox], pub server_name: &'a [Box<ServerName>],
/// The signature of a `m.third_party_invite` token to prove that this user owns a third /// The signature of a `m.third_party_invite` token to prove that this user owns a third
/// party identity which has been invited to the room. /// party identity which has been invited to the room.

View File

@ -1,7 +1,7 @@
//! [POST /_matrix/client/r0/login](https://matrix.org/docs/spec/client_server/r0.6.1#post-matrix-client-r0-login) //! [POST /_matrix/client/r0/login](https://matrix.org/docs/spec/client_server/r0.6.1#post-matrix-client-r0-login)
use ruma_api::ruma_api; use ruma_api::ruma_api;
use ruma_identifiers::{DeviceId, DeviceIdBox, ServerNameBox, UserId}; use ruma_identifiers::{DeviceId, ServerName, UserId};
use ruma_serde::{JsonObject, Outgoing}; use ruma_serde::{JsonObject, Outgoing};
use serde::{ use serde::{
de::{self, DeserializeOwned}, de::{self, DeserializeOwned},
@ -49,13 +49,13 @@ ruma_api! {
/// Deprecated: Clients should instead use the `user_id.server_name()` /// Deprecated: Clients should instead use the `user_id.server_name()`
/// method if they require it. /// method if they require it.
#[serde(skip_serializing_if = "Option::is_none")] #[serde(skip_serializing_if = "Option::is_none")]
pub home_server: Option<ServerNameBox>, pub home_server: Option<Box<ServerName>>,
/// ID of the logged-in device. /// ID of the logged-in device.
/// ///
/// Will be the same as the corresponding parameter in the request, if one was /// Will be the same as the corresponding parameter in the request, if one was
/// specified. /// specified.
pub device_id: DeviceIdBox, pub device_id: Box<DeviceId>,
/// Client configuration provided by the server. /// Client configuration provided by the server.
/// ///
@ -76,7 +76,7 @@ impl<'a> Request<'a> {
impl Response { impl Response {
/// Creates a new `Response` with the given user ID, access token and device ID. /// Creates a new `Response` with the given user ID, access token and device ID.
pub fn new(user_id: UserId, access_token: String, device_id: DeviceIdBox) -> Self { pub fn new(user_id: UserId, access_token: String, device_id: Box<DeviceId>) -> Self {
Self { user_id, access_token, home_server: None, device_id, well_known: None } Self { user_id, access_token, home_server: None, device_id, well_known: None }
} }
} }

View File

@ -3,7 +3,7 @@
use std::fmt; use std::fmt;
use js_int::UInt; use js_int::UInt;
use ruma_identifiers::{MxcUri, RoomAliasId, RoomId, RoomNameBox}; use ruma_identifiers::{MxcUri, RoomAliasId, RoomId, RoomName};
use ruma_serde::Outgoing; use ruma_serde::Outgoing;
use serde::{ use serde::{
de::{Error, MapAccess, Visitor}, de::{Error, MapAccess, Visitor},
@ -29,7 +29,7 @@ pub struct PublicRoomsChunk {
/// 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")]
pub name: Option<RoomNameBox>, pub name: Option<Box<RoomName>>,
/// The number of members joined to the room. /// The number of members joined to the room.
pub num_joined_members: UInt, pub num_joined_members: UInt,

View File

@ -4,7 +4,7 @@
use std::collections::BTreeMap; use std::collections::BTreeMap;
use ruma_identifiers::{DeviceIdBox, DeviceKeyId, EventEncryptionAlgorithm, UserId}; use ruma_identifiers::{DeviceId, DeviceKeyId, EventEncryptionAlgorithm, UserId};
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
/// Identity keys for a device. /// Identity keys for a device.
@ -19,7 +19,7 @@ pub struct DeviceKeys {
/// The ID of the device these keys belong to. /// The ID of the device these keys belong to.
/// ///
/// Must match the device ID used when logging in. /// Must match the device ID used when logging in.
pub device_id: DeviceIdBox, pub device_id: Box<DeviceId>,
/// The encryption algorithms supported by this device. /// The encryption algorithms supported by this device.
pub algorithms: Vec<EventEncryptionAlgorithm>, pub algorithms: Vec<EventEncryptionAlgorithm>,
@ -41,7 +41,7 @@ impl DeviceKeys {
/// signatures. /// signatures.
pub fn new( pub fn new(
user_id: UserId, user_id: UserId,
device_id: DeviceIdBox, device_id: Box<DeviceId>,
algorithms: Vec<EventEncryptionAlgorithm>, algorithms: Vec<EventEncryptionAlgorithm>,
keys: BTreeMap<DeviceKeyId, String>, keys: BTreeMap<DeviceKeyId, String>,
signatures: BTreeMap<UserId, BTreeMap<DeviceKeyId, String>>, signatures: BTreeMap<UserId, BTreeMap<DeviceKeyId, String>>,

View File

@ -7,7 +7,7 @@ use std::{
fmt::{Display, Formatter, Result as FmtResult}, fmt::{Display, Formatter, Result as FmtResult},
}; };
use ruma_identifiers::DeviceIdBox; use ruma_identifiers::DeviceId;
use serde::{ use serde::{
de::{self, Unexpected}, de::{self, Unexpected},
Deserialize, Deserializer, Serialize, Serializer, Deserialize, Deserializer, Serialize, Serializer,
@ -18,7 +18,7 @@ use serde::{
#[allow(clippy::exhaustive_enums)] #[allow(clippy::exhaustive_enums)]
pub enum DeviceIdOrAllDevices { pub enum DeviceIdOrAllDevices {
/// Represents a device Id for one of a user's devices. /// Represents a device Id for one of a user's devices.
DeviceId(DeviceIdBox), DeviceId(Box<DeviceId>),
/// Represents all devices for a user. /// Represents all devices for a user.
AllDevices, AllDevices,
@ -33,8 +33,8 @@ impl Display for DeviceIdOrAllDevices {
} }
} }
impl From<DeviceIdBox> for DeviceIdOrAllDevices { impl From<Box<DeviceId>> for DeviceIdOrAllDevices {
fn from(d: DeviceIdBox) -> Self { fn from(d: Box<DeviceId>) -> Self {
DeviceIdOrAllDevices::DeviceId(d) DeviceIdOrAllDevices::DeviceId(d)
} }
} }

View File

@ -1,7 +1,7 @@
//! Types for the `m.key.verification.ready` event. //! Types for the `m.key.verification.ready` event.
use ruma_events_macros::EventContent; use ruma_events_macros::EventContent;
use ruma_identifiers::DeviceIdBox; use ruma_identifiers::DeviceId;
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
use super::{Relation, VerificationMethod}; use super::{Relation, VerificationMethod};
@ -14,7 +14,7 @@ use super::{Relation, VerificationMethod};
#[ruma_event(type = "m.key.verification.ready", kind = ToDevice)] #[ruma_event(type = "m.key.verification.ready", kind = ToDevice)]
pub struct ToDeviceKeyVerificationReadyEventContent { pub struct ToDeviceKeyVerificationReadyEventContent {
/// The device ID which is initiating the request. /// The device ID which is initiating the request.
pub from_device: DeviceIdBox, pub from_device: Box<DeviceId>,
/// The verification methods supported by the sender. /// The verification methods supported by the sender.
pub methods: Vec<VerificationMethod>, pub methods: Vec<VerificationMethod>,
@ -31,7 +31,7 @@ impl ToDeviceKeyVerificationReadyEventContent {
/// Creates a new `ToDeviceKeyVerificationReadyEventContent` with the given device ID, /// Creates a new `ToDeviceKeyVerificationReadyEventContent` with the given device ID,
/// verification methods and transaction ID. /// verification methods and transaction ID.
pub fn new( pub fn new(
from_device: DeviceIdBox, from_device: Box<DeviceId>,
methods: Vec<VerificationMethod>, methods: Vec<VerificationMethod>,
transaction_id: String, transaction_id: String,
) -> Self { ) -> Self {
@ -47,7 +47,7 @@ impl ToDeviceKeyVerificationReadyEventContent {
#[ruma_event(type = "m.key.verification.ready", kind = Message)] #[ruma_event(type = "m.key.verification.ready", kind = Message)]
pub struct KeyVerificationReadyEventContent { pub struct KeyVerificationReadyEventContent {
/// The device ID which is initiating the request. /// The device ID which is initiating the request.
pub from_device: DeviceIdBox, pub from_device: Box<DeviceId>,
/// The verification methods supported by the sender. /// The verification methods supported by the sender.
pub methods: Vec<VerificationMethod>, pub methods: Vec<VerificationMethod>,
@ -62,7 +62,7 @@ impl KeyVerificationReadyEventContent {
/// Creates a new `KeyVerificationReadyEventContent` with the given device ID, methods and /// Creates a new `KeyVerificationReadyEventContent` with the given device ID, methods and
/// relation. /// relation.
pub fn new( pub fn new(
from_device: DeviceIdBox, from_device: Box<DeviceId>,
methods: Vec<VerificationMethod>, methods: Vec<VerificationMethod>,
relates_to: Relation, relates_to: Relation,
) -> Self { ) -> Self {
@ -73,7 +73,7 @@ impl KeyVerificationReadyEventContent {
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {
use matches::assert_matches; use matches::assert_matches;
use ruma_identifiers::{event_id, DeviceIdBox}; use ruma_identifiers::{event_id, DeviceId};
use serde_json::{from_value as from_json_value, json, to_value as to_json_value}; use serde_json::{from_value as from_json_value, json, to_value as to_json_value};
use super::{KeyVerificationReadyEventContent, ToDeviceKeyVerificationReadyEventContent}; use super::{KeyVerificationReadyEventContent, ToDeviceKeyVerificationReadyEventContent};
@ -82,7 +82,7 @@ mod tests {
#[test] #[test]
fn serialization() { fn serialization() {
let event_id = event_id!("$1598361704261elfgc:localhost"); let event_id = event_id!("$1598361704261elfgc:localhost");
let device: DeviceIdBox = "123".into(); let device: Box<DeviceId> = "123".into();
let json_data = json!({ let json_data = json!({
"from_device": device, "from_device": device,
@ -119,7 +119,7 @@ mod tests {
#[test] #[test]
fn deserialization() { fn deserialization() {
let id = event_id!("$1598361704261elfgc:localhost"); let id = event_id!("$1598361704261elfgc:localhost");
let device: DeviceIdBox = "123".into(); let device: Box<DeviceId> = "123".into();
let json_data = json!({ let json_data = json!({
"from_device": device, "from_device": device,

View File

@ -2,7 +2,7 @@
use ruma_common::MilliSecondsSinceUnixEpoch; use ruma_common::MilliSecondsSinceUnixEpoch;
use ruma_events_macros::EventContent; use ruma_events_macros::EventContent;
use ruma_identifiers::DeviceIdBox; use ruma_identifiers::DeviceId;
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
use super::VerificationMethod; use super::VerificationMethod;
@ -13,7 +13,7 @@ use super::VerificationMethod;
#[ruma_event(type = "m.key.verification.request", kind = ToDevice)] #[ruma_event(type = "m.key.verification.request", kind = ToDevice)]
pub struct ToDeviceKeyVerificationRequestEventContent { pub struct ToDeviceKeyVerificationRequestEventContent {
/// The device ID which is initiating the request. /// The device ID which is initiating the request.
pub from_device: DeviceIdBox, pub from_device: Box<DeviceId>,
/// An opaque identifier for the verification request. /// An opaque identifier for the verification request.
/// ///
@ -34,7 +34,7 @@ impl ToDeviceKeyVerificationRequestEventContent {
/// Creates a new `ToDeviceKeyVerificationRequestEventContent` with the given device ID, /// Creates a new `ToDeviceKeyVerificationRequestEventContent` with the given device ID,
/// transaction ID, methods and timestamp. /// transaction ID, methods and timestamp.
pub fn new( pub fn new(
from_device: DeviceIdBox, from_device: Box<DeviceId>,
transaction_id: String, transaction_id: String,
methods: Vec<VerificationMethod>, methods: Vec<VerificationMethod>,
timestamp: MilliSecondsSinceUnixEpoch, timestamp: MilliSecondsSinceUnixEpoch,

View File

@ -3,7 +3,7 @@
use std::collections::BTreeMap; use std::collections::BTreeMap;
use ruma_events_macros::EventContent; use ruma_events_macros::EventContent;
use ruma_identifiers::DeviceIdBox; use ruma_identifiers::DeviceId;
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
use serde_json::Value as JsonValue; use serde_json::Value as JsonValue;
@ -21,7 +21,7 @@ use super::{
#[ruma_event(type = "m.key.verification.start", kind = ToDevice)] #[ruma_event(type = "m.key.verification.start", kind = ToDevice)]
pub struct ToDeviceKeyVerificationStartEventContent { pub struct ToDeviceKeyVerificationStartEventContent {
/// The device ID which is initiating the process. /// The device ID which is initiating the process.
pub from_device: DeviceIdBox, pub from_device: Box<DeviceId>,
/// An opaque identifier for the verification process. /// An opaque identifier for the verification process.
/// ///
@ -38,7 +38,7 @@ pub struct ToDeviceKeyVerificationStartEventContent {
impl ToDeviceKeyVerificationStartEventContent { impl ToDeviceKeyVerificationStartEventContent {
/// Creates a new `ToDeviceKeyVerificationStartEventContent` with the given device ID, /// Creates a new `ToDeviceKeyVerificationStartEventContent` with the given device ID,
/// transaction ID and method specific content. /// transaction ID and method specific content.
pub fn new(from_device: DeviceIdBox, transaction_id: String, method: StartMethod) -> Self { pub fn new(from_device: Box<DeviceId>, transaction_id: String, method: StartMethod) -> Self {
Self { from_device, transaction_id, method } Self { from_device, transaction_id, method }
} }
} }
@ -52,7 +52,7 @@ impl ToDeviceKeyVerificationStartEventContent {
#[ruma_event(type = "m.key.verification.start", kind = Message)] #[ruma_event(type = "m.key.verification.start", kind = Message)]
pub struct KeyVerificationStartEventContent { pub struct KeyVerificationStartEventContent {
/// The device ID which is initiating the process. /// The device ID which is initiating the process.
pub from_device: DeviceIdBox, pub from_device: Box<DeviceId>,
/// Method specific content. /// Method specific content.
#[serde(flatten)] #[serde(flatten)]
@ -67,7 +67,7 @@ pub struct KeyVerificationStartEventContent {
impl KeyVerificationStartEventContent { impl KeyVerificationStartEventContent {
/// Creates a new `KeyVerificationStartEventContent` with the given device ID, method and /// Creates a new `KeyVerificationStartEventContent` with the given device ID, method and
/// relation. /// relation.
pub fn new(from_device: DeviceIdBox, method: StartMethod, relates_to: Relation) -> Self { pub fn new(from_device: Box<DeviceId>, method: StartMethod, relates_to: Relation) -> Self {
Self { from_device, method, relates_to } Self { from_device, method, relates_to }
} }
} }

View File

@ -9,7 +9,7 @@ use std::collections::BTreeMap;
use js_int::UInt; use js_int::UInt;
use ruma_common::MilliSecondsSinceUnixEpoch; use ruma_common::MilliSecondsSinceUnixEpoch;
use ruma_identifiers::{EventId, RoomId, ServerNameBox, ServerSigningKeyId, UserId}; use ruma_identifiers::{EventId, RoomId, ServerName, ServerSigningKeyId, UserId};
use serde::{ use serde::{
de::{Error as _, IgnoredAny}, de::{Error as _, IgnoredAny},
Deserialize, Deserializer, Serialize, Deserialize, Deserializer, Serialize,
@ -89,7 +89,7 @@ pub struct RoomV1Pdu {
pub hashes: EventHash, pub hashes: EventHash,
/// Signatures for the PDU. /// Signatures for the PDU.
pub signatures: BTreeMap<ServerNameBox, BTreeMap<ServerSigningKeyId, String>>, pub signatures: BTreeMap<Box<ServerName>, BTreeMap<ServerSigningKeyId, String>>,
} }
/// A 'persistent data unit' (event) for room versions 3 and beyond. /// A 'persistent data unit' (event) for room versions 3 and beyond.
@ -146,7 +146,7 @@ pub struct RoomV3Pdu {
pub hashes: EventHash, pub hashes: EventHash,
/// Signatures for the PDU. /// Signatures for the PDU.
pub signatures: BTreeMap<ServerNameBox, BTreeMap<ServerSigningKeyId, String>>, pub signatures: BTreeMap<Box<ServerName>, BTreeMap<ServerSigningKeyId, String>>,
} }
/// Content hashes of a PDU. /// Content hashes of a PDU.

View File

@ -4,7 +4,7 @@ use std::collections::BTreeMap;
use js_int::UInt; use js_int::UInt;
use ruma_events_macros::EventContent; use ruma_events_macros::EventContent;
use ruma_identifiers::DeviceIdBox; use ruma_identifiers::DeviceId;
#[cfg(feature = "unstable-pre-spec")] #[cfg(feature = "unstable-pre-spec")]
use ruma_identifiers::EventId; use ruma_identifiers::EventId;
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
@ -212,7 +212,7 @@ pub struct MegolmV1AesSha2Content {
pub sender_key: String, pub sender_key: String,
/// The ID of the sending device. /// The ID of the sending device.
pub device_id: DeviceIdBox, pub device_id: Box<DeviceId>,
/// The ID of the session used to encrypt the message. /// The ID of the session used to encrypt the message.
pub session_id: String, pub session_id: String,
@ -232,7 +232,7 @@ pub struct MegolmV1AesSha2ContentInit {
pub sender_key: String, pub sender_key: String,
/// The ID of the sending device. /// The ID of the sending device.
pub device_id: DeviceIdBox, pub device_id: Box<DeviceId>,
/// The ID of the session used to encrypt the message. /// The ID of the session used to encrypt the message.
pub session_id: String, pub session_id: String,

View File

@ -3,7 +3,7 @@
use std::collections::BTreeMap; use std::collections::BTreeMap;
use ruma_events_macros::EventContent; use ruma_events_macros::EventContent;
use ruma_identifiers::{MxcUri, ServerNameBox, ServerSigningKeyId, UserId}; use ruma_identifiers::{MxcUri, ServerName, ServerSigningKeyId, UserId};
use ruma_serde::StringEnum; use ruma_serde::StringEnum;
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
@ -178,7 +178,7 @@ pub struct SignedContent {
/// A single signature from the verifying server, in the format specified by the Signing Events /// A single signature from the verifying server, in the format specified by the Signing Events
/// section of the server-server API. /// section of the server-server API.
pub signatures: BTreeMap<ServerNameBox, BTreeMap<ServerSigningKeyId, String>>, pub signatures: BTreeMap<Box<ServerName>, BTreeMap<ServerSigningKeyId, String>>,
/// The token property of the containing `third_party_invite` object. /// The token property of the containing `third_party_invite` object.
pub token: String, pub token: String,
@ -188,7 +188,7 @@ impl SignedContent {
/// Creates a new `SignedContent` with the given mxid, signature and token. /// Creates a new `SignedContent` with the given mxid, signature and token.
pub fn new( pub fn new(
mxid: UserId, mxid: UserId,
signatures: BTreeMap<ServerNameBox, BTreeMap<ServerSigningKeyId, String>>, signatures: BTreeMap<Box<ServerName>, BTreeMap<ServerSigningKeyId, String>>,
token: String, token: String,
) -> Self { ) -> Self {
Self { mxid, signatures, token } Self { mxid, signatures, token }

View File

@ -5,7 +5,7 @@ use std::{borrow::Cow, fmt};
use js_int::UInt; use js_int::UInt;
use ruma_events_macros::EventContent; use ruma_events_macros::EventContent;
#[cfg(feature = "unstable-pre-spec")] #[cfg(feature = "unstable-pre-spec")]
use ruma_identifiers::{DeviceIdBox, UserId}; use ruma_identifiers::{DeviceId, UserId};
use ruma_identifiers::{EventId, MxcUri}; use ruma_identifiers::{EventId, MxcUri};
use ruma_serde::{JsonObject, StringEnum}; use ruma_serde::{JsonObject, StringEnum};
use serde::{de::DeserializeOwned, Deserialize, Serialize}; use serde::{de::DeserializeOwned, Deserialize, Serialize};
@ -968,7 +968,7 @@ pub struct KeyVerificationRequestEventContent {
pub methods: Vec<VerificationMethod>, pub methods: Vec<VerificationMethod>,
/// The device ID which is initiating the request. /// The device ID which is initiating the request.
pub from_device: DeviceIdBox, pub from_device: Box<DeviceId>,
/// The user ID which should receive the request. /// The user ID which should receive the request.
/// ///
@ -985,7 +985,7 @@ impl KeyVerificationRequestEventContent {
pub fn new( pub fn new(
body: String, body: String,
methods: Vec<VerificationMethod>, methods: Vec<VerificationMethod>,
from_device: DeviceIdBox, from_device: Box<DeviceId>,
to: UserId, to: UserId,
) -> Self { ) -> Self {
Self { body, methods, from_device, to } Self { body, methods, from_device, to }

View File

@ -1,7 +1,7 @@
//! Types for the `m.room.name` event. //! Types for the `m.room.name` event.
use ruma_events_macros::EventContent; use ruma_events_macros::EventContent;
use ruma_identifiers::RoomNameBox; use ruma_identifiers::RoomName;
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
/// The content of an `m.room.name` event. /// The content of an `m.room.name` event.
@ -13,24 +13,24 @@ use serde::{Deserialize, Serialize};
pub struct RoomNameEventContent { pub struct RoomNameEventContent {
/// The name of the room. /// The name of the room.
#[serde(default, deserialize_with = "ruma_serde::empty_string_as_none")] #[serde(default, deserialize_with = "ruma_serde::empty_string_as_none")]
pub name: Option<RoomNameBox>, pub name: Option<Box<RoomName>>,
} }
impl RoomNameEventContent { impl RoomNameEventContent {
/// Create a new `RoomNameEventContent` with the given name. /// Create a new `RoomNameEventContent` with the given name.
pub fn new(name: Option<RoomNameBox>) -> Self { pub fn new(name: Option<Box<RoomName>>) -> Self {
Self { name } Self { name }
} }
} }
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {
use std::convert::TryFrom; use std::convert::TryInto;
use js_int::{int, uint}; use js_int::{int, uint};
use matches::assert_matches; use matches::assert_matches;
use ruma_common::MilliSecondsSinceUnixEpoch; use ruma_common::MilliSecondsSinceUnixEpoch;
use ruma_identifiers::{event_id, room_id, user_id, RoomNameBox}; use ruma_identifiers::{event_id, room_id, user_id};
use ruma_serde::Raw; use ruma_serde::Raw;
use serde_json::{from_value as from_json_value, json, to_value as to_json_value}; use serde_json::{from_value as from_json_value, json, to_value as to_json_value};
@ -40,7 +40,7 @@ mod tests {
#[test] #[test]
fn serialization_with_optional_fields_as_none() { fn serialization_with_optional_fields_as_none() {
let name_event = StateEvent { let name_event = StateEvent {
content: RoomNameEventContent { name: RoomNameBox::try_from("The room name").ok() }, content: RoomNameEventContent { name: "The room name".try_into().ok() },
event_id: event_id!("$h29iv0s8:example.com"), event_id: event_id!("$h29iv0s8:example.com"),
origin_server_ts: MilliSecondsSinceUnixEpoch(uint!(1)), origin_server_ts: MilliSecondsSinceUnixEpoch(uint!(1)),
prev_content: None, prev_content: None,
@ -69,12 +69,10 @@ mod tests {
#[test] #[test]
fn serialization_with_all_fields() { fn serialization_with_all_fields() {
let name_event = StateEvent { let name_event = StateEvent {
content: RoomNameEventContent { name: RoomNameBox::try_from("The room name").ok() }, content: RoomNameEventContent { name: "The room name".try_into().ok() },
event_id: event_id!("$h29iv0s8:example.com"), event_id: event_id!("$h29iv0s8:example.com"),
origin_server_ts: MilliSecondsSinceUnixEpoch(uint!(1)), origin_server_ts: MilliSecondsSinceUnixEpoch(uint!(1)),
prev_content: Some(RoomNameEventContent { prev_content: Some(RoomNameEventContent { name: "The old name".try_into().ok() }),
name: RoomNameBox::try_from("The old name").ok(),
}),
room_id: room_id!("!n8f893n9:example.com"), room_id: room_id!("!n8f893n9:example.com"),
sender: user_id!("@carl:example.com"), sender: user_id!("@carl:example.com"),
state_key: "".into(), state_key: "".into(),
@ -141,7 +139,7 @@ mod tests {
#[test] #[test]
fn new_with_empty_name_creates_content_as_none() { fn new_with_empty_name_creates_content_as_none() {
assert_matches!( assert_matches!(
RoomNameEventContent::new(RoomNameBox::try_from(String::new()).ok()), RoomNameEventContent::new("".try_into().ok()),
RoomNameEventContent { name: None } RoomNameEventContent { name: None }
); );
} }
@ -186,7 +184,7 @@ mod tests {
#[test] #[test]
fn nonempty_field_as_some() { fn nonempty_field_as_some() {
let name = RoomNameBox::try_from("The room name").ok(); let name = "The room name".try_into().ok();
let json_data = json!({ let json_data = json!({
"content": { "content": {
"name": "The room name" "name": "The room name"

View File

@ -1,7 +1,7 @@
//! Types for the `m.room_key_request` event. //! Types for the `m.room_key_request` event.
use ruma_events_macros::EventContent; use ruma_events_macros::EventContent;
use ruma_identifiers::{DeviceIdBox, EventEncryptionAlgorithm, RoomId}; use ruma_identifiers::{DeviceId, EventEncryptionAlgorithm, RoomId};
use ruma_serde::StringEnum; use ruma_serde::StringEnum;
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
@ -19,7 +19,7 @@ pub struct ToDeviceRoomKeyRequestEventContent {
pub body: Option<RequestedKeyInfo>, pub body: Option<RequestedKeyInfo>,
/// ID of the device requesting the key. /// ID of the device requesting the key.
pub requesting_device_id: DeviceIdBox, pub requesting_device_id: Box<DeviceId>,
/// A random string uniquely identifying the request for a key. /// A random string uniquely identifying the request for a key.
/// ///
@ -34,7 +34,7 @@ impl ToDeviceRoomKeyRequestEventContent {
pub fn new( pub fn new(
action: Action, action: Action,
body: Option<RequestedKeyInfo>, body: Option<RequestedKeyInfo>,
requesting_device_id: DeviceIdBox, requesting_device_id: Box<DeviceId>,
request_id: String, request_id: String,
) -> Self { ) -> Self {
Self { action, body, requesting_device_id, request_id } Self { action, body, requesting_device_id, request_id }

View File

@ -3,7 +3,7 @@
use std::convert::TryFrom; use std::convert::TryFrom;
use ruma_events_macros::EventContent; use ruma_events_macros::EventContent;
use ruma_identifiers::DeviceIdBox; use ruma_identifiers::DeviceId;
use ruma_serde::StringEnum; use ruma_serde::StringEnum;
use serde::{ser::SerializeStruct, Deserialize, Serialize}; use serde::{ser::SerializeStruct, Deserialize, Serialize};
@ -21,7 +21,7 @@ pub struct ToDeviceSecretRequestEventContent {
pub action: RequestAction, pub action: RequestAction,
/// The ID of the device requesting the event. /// The ID of the device requesting the event.
pub requesting_device_id: DeviceIdBox, pub requesting_device_id: Box<DeviceId>,
/// A random string uniquely identifying (with respect to the requester and the target) the /// A random string uniquely identifying (with respect to the requester and the target) the
/// target for a secret. /// target for a secret.
@ -36,7 +36,7 @@ impl ToDeviceSecretRequestEventContent {
/// request ID. /// request ID.
pub fn new( pub fn new(
action: RequestAction, action: RequestAction,
requesting_device_id: DeviceIdBox, requesting_device_id: Box<DeviceId>,
request_id: String, request_id: String,
) -> Self { ) -> Self {
Self { action, requesting_device_id, request_id } Self { action, requesting_device_id, request_id }

View File

@ -1,7 +1,7 @@
//! Types for the `m.space.child` event. //! Types for the `m.space.child` event.
use ruma_events_macros::EventContent; use ruma_events_macros::EventContent;
use ruma_identifiers::ServerNameBox; use ruma_identifiers::ServerName;
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
/// The content of an `m.space.child` event. /// The content of an `m.space.child` event.
@ -17,7 +17,7 @@ use serde::{Deserialize, Serialize};
pub struct SpaceChildEventContent { pub struct SpaceChildEventContent {
/// List of candidate servers that can be used to join the room. /// List of candidate servers that can be used to join the room.
#[serde(skip_serializing_if = "Option::is_none")] #[serde(skip_serializing_if = "Option::is_none")]
pub via: Option<Vec<ServerNameBox>>, pub via: Option<Vec<Box<ServerName>>>,
/// Provide a default ordering of siblings in the room list. /// Provide a default ordering of siblings in the room list.
/// ///

View File

@ -1,7 +1,7 @@
//! Types for the `m.space.child` event. //! Types for the `m.space.child` event.
use ruma_events_macros::EventContent; use ruma_events_macros::EventContent;
use ruma_identifiers::ServerNameBox; use ruma_identifiers::ServerName;
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
/// The content of an `m.space.parent` event. /// The content of an `m.space.parent` event.
@ -17,7 +17,7 @@ use serde::{Deserialize, Serialize};
pub struct SpaceParentEventContent { pub struct SpaceParentEventContent {
/// List of candidate servers that can be used to join the room. /// List of candidate servers that can be used to join the room.
#[serde(skip_serializing_if = "Option::is_none")] #[serde(skip_serializing_if = "Option::is_none")]
pub via: Option<Vec<ServerNameBox>>, pub via: Option<Vec<Box<ServerName>>>,
/// Determines whether this is the main parent for the space. /// Determines whether this is the main parent for the space.
/// ///

View File

@ -2,7 +2,7 @@ use std::convert::TryFrom;
use matches::assert_matches; use matches::assert_matches;
use ruma_events::{AnyInitialStateEvent, InitialStateEvent}; use ruma_events::{AnyInitialStateEvent, InitialStateEvent};
use ruma_identifiers::RoomNameBox; use ruma_identifiers::RoomName;
use serde_json::json; use serde_json::json;
#[test] #[test]
@ -14,7 +14,7 @@ fn deserialize_initial_state_event() {
})) }))
.unwrap(), .unwrap(),
AnyInitialStateEvent::RoomName(InitialStateEvent { content, state_key}) AnyInitialStateEvent::RoomName(InitialStateEvent { content, state_key})
if content.name == Some(RoomNameBox::try_from("foo").unwrap()) if content.name == Some(Box::<RoomName>::try_from("foo").unwrap())
&& state_key.is_empty() && state_key.is_empty()
); );
} }

View File

@ -16,7 +16,7 @@ use ruma_events::{
Unsigned, Unsigned,
}; };
#[cfg(feature = "unstable-pre-spec")] #[cfg(feature = "unstable-pre-spec")]
use ruma_identifiers::DeviceIdBox; use ruma_identifiers::DeviceId;
use ruma_identifiers::{event_id, mxc_uri, room_id, user_id}; use ruma_identifiers::{event_id, mxc_uri, room_id, user_id};
use serde_json::{from_value as from_json_value, json, to_value as to_json_value}; use serde_json::{from_value as from_json_value, json, to_value as to_json_value};
@ -298,7 +298,7 @@ fn edit_deserialization_future() {
#[cfg(feature = "unstable-pre-spec")] #[cfg(feature = "unstable-pre-spec")]
fn verification_request_deserialization() { fn verification_request_deserialization() {
let user_id = user_id!("@example2:localhost"); let user_id = user_id!("@example2:localhost");
let device_id: DeviceIdBox = "XOWLHHFSWM".into(); let device_id: Box<DeviceId> = "XOWLHHFSWM".into();
let json_data = json!({ let json_data = json!({
"body": "@example:localhost is requesting to verify your key, ...", "body": "@example:localhost is requesting to verify your key, ...",
@ -334,7 +334,7 @@ fn verification_request_deserialization() {
#[cfg(feature = "unstable-pre-spec")] #[cfg(feature = "unstable-pre-spec")]
fn verification_request_serialization() { fn verification_request_serialization() {
let user_id = user_id!("@example2:localhost"); let user_id = user_id!("@example2:localhost");
let device_id: DeviceIdBox = "XOWLHHFSWM".into(); let device_id: Box<DeviceId> = "XOWLHHFSWM".into();
let body = "@example:localhost is requesting to verify your key, ...".to_owned(); let body = "@example:localhost is requesting to verify your key, ...".to_owned();
let methods = vec![ let methods = vec![

View File

@ -5,7 +5,7 @@ use ruma_events::{
room::{join_rules::JoinRule, topic::RoomTopicEventContent}, room::{join_rules::JoinRule, topic::RoomTopicEventContent},
AnyStrippedStateEvent, StrippedStateEvent, AnyStrippedStateEvent, StrippedStateEvent,
}; };
use ruma_identifiers::{mxc_uri, user_id, RoomNameBox}; use ruma_identifiers::{mxc_uri, user_id, RoomName};
use serde_json::{from_value as from_json_value, json, to_value as to_json_value}; use serde_json::{from_value as from_json_value, json, to_value as to_json_value};
#[test] #[test]
@ -96,7 +96,7 @@ fn deserialize_stripped_state_events() {
let event = from_json_value::<AnyStrippedStateEvent>(name_event).unwrap(); let event = from_json_value::<AnyStrippedStateEvent>(name_event).unwrap();
match event { match event {
AnyStrippedStateEvent::RoomName(event) => { AnyStrippedStateEvent::RoomName(event) => {
assert_eq!(event.content.name, Some(RoomNameBox::try_from("Ruma").unwrap())); assert_eq!(event.content.name, Some(Box::<RoomName>::try_from("Ruma").unwrap()));
assert_eq!(event.state_key, ""); assert_eq!(event.state_key, "");
assert_eq!(event.sender.to_string(), "@example:localhost"); assert_eq!(event.sender.to_string(), "@example:localhost");
} }

View File

@ -3,7 +3,7 @@
use js_int::UInt; use js_int::UInt;
use ruma_api::ruma_api; use ruma_api::ruma_api;
use ruma_common::MilliSecondsSinceUnixEpoch; use ruma_common::MilliSecondsSinceUnixEpoch;
use ruma_identifiers::{EventId, RoomId, ServerNameBox}; use ruma_identifiers::{EventId, RoomId, ServerName};
use serde_json::value::RawValue as RawJsonValue; use serde_json::value::RawValue as RawJsonValue;
@ -33,7 +33,7 @@ ruma_api! {
response: { response: {
/// The `server_name` of the homeserver sending this transaction. /// The `server_name` of the homeserver sending this transaction.
pub origin: ServerNameBox, pub origin: Box<ServerName>,
/// 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,
@ -59,7 +59,7 @@ impl Response {
/// * 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: ServerNameBox, origin: Box<ServerName>,
origin_server_ts: MilliSecondsSinceUnixEpoch, origin_server_ts: MilliSecondsSinceUnixEpoch,
pdus: Vec<Box<RawJsonValue>>, pdus: Vec<Box<RawJsonValue>>,
) -> Self { ) -> Self {

View File

@ -3,7 +3,7 @@
use js_int::UInt; use js_int::UInt;
use ruma_api::ruma_api; use ruma_api::ruma_api;
use ruma_common::encryption::DeviceKeys; use ruma_common::encryption::DeviceKeys;
use ruma_identifiers::{DeviceIdBox, UserId}; use ruma_identifiers::{DeviceId, UserId};
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
ruma_api! { ruma_api! {
@ -60,7 +60,7 @@ impl Response {
#[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: DeviceIdBox, pub device_id: Box<DeviceId>,
/// Identity keys for the device. /// Identity keys for the device.
pub keys: DeviceKeys, pub keys: DeviceKeys,
@ -72,7 +72,7 @@ pub struct UserDevice {
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: DeviceIdBox, keys: DeviceKeys) -> Self { pub fn new(device_id: Box<DeviceId>, keys: DeviceKeys) -> Self {
Self { device_id, keys, device_display_name: None } Self { device_id, keys, device_display_name: None }
} }
} }

View File

@ -3,7 +3,7 @@
use std::collections::BTreeMap; use std::collections::BTreeMap;
use ruma_common::MilliSecondsSinceUnixEpoch; use ruma_common::MilliSecondsSinceUnixEpoch;
use ruma_identifiers::{ServerNameBox, ServerSigningKeyId}; use ruma_identifiers::{ServerName, ServerSigningKeyId};
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
pub mod discover_homeserver; pub mod discover_homeserver;
@ -51,7 +51,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: ServerNameBox, pub server_name: Box<ServerName>,
/// Public keys of the homeserver for verifying digital signatures. /// Public keys of the homeserver for verifying digital signatures.
pub verify_keys: BTreeMap<ServerSigningKeyId, VerifyKey>, pub verify_keys: BTreeMap<ServerSigningKeyId, VerifyKey>,
@ -61,8 +61,8 @@ 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<ServerNameBox, BTreeMap<ServerSigningKeyId, String>>, pub signatures: BTreeMap<Box<ServerName>, BTreeMap<ServerSigningKeyId, String>>,
/// Timestamp when the keys should be refreshed. /// Timestamp when the keys should be refreshed.
/// ///
@ -74,7 +74,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: ServerNameBox, valid_until_ts: MilliSecondsSinceUnixEpoch) -> Self { pub fn new(server_name: Box<ServerName>, valid_until_ts: MilliSecondsSinceUnixEpoch) -> Self {
Self { Self {
server_name, server_name,
verify_keys: BTreeMap::new(), verify_keys: BTreeMap::new(),

View File

@ -1,7 +1,7 @@
//! [GET /.well-known/matrix/server](https://matrix.org/docs/spec/server_server/r0.1.4#get-well-known-matrix-server) //! [GET /.well-known/matrix/server](https://matrix.org/docs/spec/server_server/r0.1.4#get-well-known-matrix-server)
use ruma_api::ruma_api; use ruma_api::ruma_api;
use ruma_identifiers::ServerNameBox; use ruma_identifiers::ServerName;
ruma_api! { ruma_api! {
metadata: { metadata: {
@ -19,7 +19,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: ServerNameBox, pub server: Box<ServerName>,
} }
} }
@ -32,7 +32,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: ServerNameBox) -> Self { pub fn new(server: Box<ServerName>) -> Self {
Self { server } Self { server }
} }
} }

View File

@ -4,7 +4,7 @@ use std::collections::BTreeMap;
use ruma_api::ruma_api; use ruma_api::ruma_api;
use ruma_common::MilliSecondsSinceUnixEpoch; use ruma_common::MilliSecondsSinceUnixEpoch;
use ruma_identifiers::{ServerNameBox, ServerSigningKeyId}; use ruma_identifiers::{ServerName, ServerSigningKeyId};
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
use crate::discovery::ServerSigningKeys; use crate::discovery::ServerSigningKeys;
@ -28,7 +28,7 @@ ruma_api! {
/// 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<ServerNameBox, BTreeMap<ServerSigningKeyId, QueryCriteria>>, pub server_keys: BTreeMap<Box<ServerName>, BTreeMap<ServerSigningKeyId, QueryCriteria>>,
} }
@ -41,7 +41,7 @@ ruma_api! {
impl Request { impl Request {
/// 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<ServerNameBox, BTreeMap<ServerSigningKeyId, QueryCriteria>>, server_keys: BTreeMap<Box<ServerName>, BTreeMap<ServerSigningKeyId, QueryCriteria>>,
) -> Self { ) -> Self {
Self { server_keys } Self { server_keys }
} }

View File

@ -2,7 +2,7 @@
use ruma_api::ruma_api; use ruma_api::ruma_api;
use ruma_common::MilliSecondsSinceUnixEpoch; use ruma_common::MilliSecondsSinceUnixEpoch;
use ruma_identifiers::{EventId, ServerNameBox}; use ruma_identifiers::{EventId, ServerName};
use serde_json::value::RawValue as RawJsonValue; use serde_json::value::RawValue as RawJsonValue;
@ -24,7 +24,7 @@ ruma_api! {
response: { response: {
/// The `server_name` of the homeserver sending this transaction. /// The `server_name` of the homeserver sending this transaction.
pub origin: ServerNameBox, pub origin: Box<ServerName>,
/// 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,
@ -45,7 +45,7 @@ impl<'a> Request<'a> {
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: ServerNameBox, origin: Box<ServerName>,
origin_server_ts: MilliSecondsSinceUnixEpoch, origin_server_ts: MilliSecondsSinceUnixEpoch,
pdu: Box<RawJsonValue>, pdu: Box<RawJsonValue>,
) -> Self { ) -> Self {

View File

@ -5,7 +5,7 @@ use std::collections::BTreeMap;
use ruma_api::ruma_api; use ruma_api::ruma_api;
use ruma_common::encryption::OneTimeKey; use ruma_common::encryption::OneTimeKey;
use ruma_identifiers::{DeviceIdBox, DeviceKeyAlgorithm, DeviceKeyId, UserId}; use ruma_identifiers::{DeviceId, DeviceKeyAlgorithm, DeviceKeyId, UserId};
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
ruma_api! { ruma_api! {
@ -44,10 +44,10 @@ impl Response {
} }
/// A claim for one time keys /// A claim for one time keys
pub type OneTimeKeyClaims = BTreeMap<UserId, BTreeMap<DeviceIdBox, DeviceKeyAlgorithm>>; pub type OneTimeKeyClaims = BTreeMap<UserId, BTreeMap<Box<DeviceId>, DeviceKeyAlgorithm>>;
/// One time keys for use in pre-key messages /// One time keys for use in pre-key messages
pub type OneTimeKeys = BTreeMap<UserId, BTreeMap<DeviceIdBox, BTreeMap<DeviceKeyId, OneTimeKey>>>; pub type OneTimeKeys = BTreeMap<UserId, BTreeMap<Box<DeviceId>, BTreeMap<DeviceKeyId, OneTimeKey>>>;
/// A key and its signature /// A key and its signature
#[derive(Debug, Clone, Serialize, Deserialize)] #[derive(Debug, Clone, Serialize, Deserialize)]

View File

@ -6,7 +6,7 @@ use ruma_api::ruma_api;
#[cfg(feature = "unstable-pre-spec")] #[cfg(feature = "unstable-pre-spec")]
use ruma_common::encryption::CrossSigningKey; use ruma_common::encryption::CrossSigningKey;
use ruma_common::encryption::DeviceKeys; use ruma_common::encryption::DeviceKeys;
use ruma_identifiers::{DeviceIdBox, UserId}; use ruma_identifiers::{DeviceId, UserId};
ruma_api! { ruma_api! {
metadata: { metadata: {
@ -22,13 +22,13 @@ ruma_api! {
/// 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<UserId, Vec<DeviceIdBox>>, pub device_keys: BTreeMap<UserId, Vec<Box<DeviceId>>>,
} }
#[derive(Default)] #[derive(Default)]
response: { response: {
/// Keys from the queried devices. /// Keys from the queried devices.
pub device_keys: BTreeMap<UserId, BTreeMap<DeviceIdBox, DeviceKeys>>, pub device_keys: BTreeMap<UserId, BTreeMap<Box<DeviceId>, DeviceKeys>>,
/// Information on the master cross-signing keys of the queried users. /// Information on the master cross-signing keys of the queried users.
#[cfg(feature = "unstable-pre-spec")] #[cfg(feature = "unstable-pre-spec")]
@ -44,14 +44,14 @@ ruma_api! {
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<UserId, Vec<DeviceIdBox>>) -> Self { pub fn new(device_keys: BTreeMap<UserId, Vec<Box<DeviceId>>>) -> Self {
Self { device_keys } Self { device_keys }
} }
} }
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(device_keys: BTreeMap<UserId, BTreeMap<DeviceIdBox, DeviceKeys>>) -> Self { pub fn new(device_keys: BTreeMap<UserId, BTreeMap<Box<DeviceId>, DeviceKeys>>) -> Self {
Self { device_keys, ..Default::default() } Self { device_keys, ..Default::default() }
} }
} }

View File

@ -1,7 +1,7 @@
//! [GET /_matrix/federation/v1/query/directory](https://matrix.org/docs/spec/server_server/r0.1.4#get-matrix-federation-v1-query-directory) //! [GET /_matrix/federation/v1/query/directory](https://matrix.org/docs/spec/server_server/r0.1.4#get-matrix-federation-v1-query-directory)
use ruma_api::ruma_api; use ruma_api::ruma_api;
use ruma_identifiers::{RoomAliasId, RoomId, ServerNameBox}; use ruma_identifiers::{RoomAliasId, RoomId, ServerName};
ruma_api! { ruma_api! {
metadata: { metadata: {
@ -24,7 +24,7 @@ ruma_api! {
pub room_id: RoomId, pub room_id: RoomId,
/// 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<ServerNameBox>, pub servers: Vec<Box<ServerName>>,
} }
} }
@ -37,7 +37,7 @@ impl<'a> Request<'a> {
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: RoomId, servers: Vec<ServerNameBox>) -> Self { pub fn new(room_id: RoomId, servers: Vec<Box<ServerName>>) -> Self {
Self { room_id, servers } Self { room_id, servers }
} }
} }

View File

@ -4,7 +4,7 @@ use std::collections::BTreeMap;
use ruma_api::ruma_api; use ruma_api::ruma_api;
use ruma_common::thirdparty::Medium; use ruma_common::thirdparty::Medium;
use ruma_identifiers::{RoomId, ServerNameBox, ServerSigningKeyId, UserId}; use ruma_identifiers::{RoomId, ServerName, ServerSigningKeyId, UserId};
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
ruma_api! { ruma_api! {
@ -77,7 +77,7 @@ pub struct ThirdPartyInvite {
pub sender: UserId, pub sender: UserId,
/// 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<ServerNameBox, BTreeMap<ServerSigningKeyId, String>>, pub signed: BTreeMap<Box<ServerName>, BTreeMap<ServerSigningKeyId, String>>,
} }
impl ThirdPartyInvite { impl ThirdPartyInvite {
@ -87,7 +87,7 @@ impl ThirdPartyInvite {
mxid: UserId, mxid: UserId,
room_id: RoomId, room_id: RoomId,
sender: UserId, sender: UserId,
signed: BTreeMap<ServerNameBox, BTreeMap<ServerSigningKeyId, String>>, signed: BTreeMap<Box<ServerName>, BTreeMap<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

@ -7,7 +7,7 @@ use ruma_common::{
encryption::DeviceKeys, presence::PresenceState, to_device::DeviceIdOrAllDevices, encryption::DeviceKeys, presence::PresenceState, to_device::DeviceIdOrAllDevices,
}; };
use ruma_events::{from_raw_json_value, receipt::Receipt, AnyToDeviceEventContent, EventType}; use ruma_events::{from_raw_json_value, receipt::Receipt, AnyToDeviceEventContent, EventType};
use ruma_identifiers::{DeviceIdBox, EventId, RoomId, UserId}; use ruma_identifiers::{DeviceId, EventId, RoomId, UserId};
use ruma_serde::Raw; use ruma_serde::Raw;
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};
@ -206,7 +206,7 @@ pub struct DeviceListUpdateContent {
pub user_id: UserId, pub user_id: UserId,
/// The ID of the device whose details are changing. /// The ID of the device whose details are changing.
pub device_id: DeviceIdBox, pub device_id: Box<DeviceId>,
/// The public human-readable name of this device. /// The public human-readable name of this device.
/// ///
@ -234,7 +234,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: UserId, device_id: DeviceIdBox, stream_id: UInt) -> Self { pub fn new(user_id: UserId, device_id: Box<DeviceId>, stream_id: UInt) -> Self {
Self { Self {
user_id, user_id,
device_id, device_id,

View File

@ -72,7 +72,7 @@ Breaking changes:
Improvements: Improvements:
* Add `DeviceKeyId::from_parts` and `SigningKeyId::from_parts` * Add `DeviceKeyId::from_parts` and `SigningKeyId::from_parts`
* Add `DeviceIdBox` and `ServerNameBox` type aliases * Add `DeviceId` and `ServerNameBox` type aliases
* Clean up debug logs for identifiers * Clean up debug logs for identifiers
* Allow crypto algorithm enums to contain any string, for forwards compatibility * Allow crypto algorithm enums to contain any string, for forwards compatibility
and to allow experimentation with non-specified ones and to allow experimentation with non-specified ones

View File

@ -26,7 +26,6 @@ unstable-pre-spec = []
[dependencies] [dependencies]
either = { version = "1.6.1", optional = true } either = { version = "1.6.1", optional = true }
paste = "1.0.5"
percent-encoding = "2.1.0" percent-encoding = "2.1.0"
rand = { version = "0.8.3", optional = true } rand = { version = "0.8.3", optional = true }
ruma-identifiers-macros = { version = "=0.20.0", path = "../ruma-identifiers-macros" } ruma-identifiers-macros = { version = "=0.20.0", path = "../ruma-identifiers-macros" }

View File

@ -21,22 +21,22 @@ use serde::de::{self, Deserializer, Unexpected};
#[doc(inline)] #[doc(inline)]
pub use crate::{ pub use crate::{
client_secret::{ClientSecret, ClientSecretBox}, client_secret::ClientSecret,
crypto_algorithms::{DeviceKeyAlgorithm, EventEncryptionAlgorithm, SigningKeyAlgorithm}, crypto_algorithms::{DeviceKeyAlgorithm, EventEncryptionAlgorithm, SigningKeyAlgorithm},
device_id::{DeviceId, DeviceIdBox}, device_id::DeviceId,
device_key_id::DeviceKeyId, device_key_id::DeviceKeyId,
event_id::EventId, event_id::EventId,
key_id::{DeviceSigningKeyId, KeyId, ServerSigningKeyId, SigningKeyId}, key_id::{DeviceSigningKeyId, KeyId, ServerSigningKeyId, SigningKeyId},
key_name::{KeyName, KeyNameBox}, key_name::KeyName,
matrix_to::MatrixToRef, matrix_to::MatrixToRef,
mxc_uri::MxcUri, mxc_uri::MxcUri,
room_alias_id::RoomAliasId, room_alias_id::RoomAliasId,
room_id::RoomId, room_id::RoomId,
room_id_or_room_alias_id::RoomIdOrAliasId, room_id_or_room_alias_id::RoomIdOrAliasId,
room_name::{RoomName, RoomNameBox}, room_name::RoomName,
room_version_id::RoomVersionId, room_version_id::RoomVersionId,
server_name::{ServerName, ServerNameBox}, server_name::ServerName,
session_id::{SessionId, SessionIdBox}, session_id::SessionId,
signatures::{DeviceSignatures, EntitySignatures, ServerSignatures, Signatures}, signatures::{DeviceSignatures, EntitySignatures, ServerSignatures, Signatures},
user_id::UserId, user_id::UserId,
}; };

View File

@ -168,13 +168,6 @@ macro_rules! opaque_identifier {
#[repr(transparent)] #[repr(transparent)]
pub struct $id(str); pub struct $id(str);
paste::paste! {
doc_concat! {
#[doc = concat!("An owned [", stringify!($id), "].")]
pub type [<$id Box>] = Box<$id>;
}
}
impl $id { impl $id {
fn from_borrowed(s: &str) -> &Self { fn from_borrowed(s: &str) -> &Self {
unsafe { std::mem::transmute(s) } unsafe { std::mem::transmute(s) }
@ -300,13 +293,6 @@ macro_rules! opaque_identifier_validated {
#[cfg_attr(feature = "serde", derive(serde::Serialize), serde(transparent, crate = "serde"))] #[cfg_attr(feature = "serde", derive(serde::Serialize), serde(transparent, crate = "serde"))]
pub struct $id(str); pub struct $id(str);
paste::paste! {
doc_concat! {
#[doc = concat!("An owned [", stringify!($id), "].")]
pub type [<$id Box>] = Box<$id>;
}
}
impl $id { impl $id {
#[allow(clippy::transmute_ptr_to_ptr)] #[allow(clippy::transmute_ptr_to_ptr)]
fn from_borrowed(s: &str) -> &Self { fn from_borrowed(s: &str) -> &Self {

View File

@ -1,6 +1,6 @@
use std::{borrow::Borrow, collections::BTreeMap}; use std::{borrow::Borrow, collections::BTreeMap};
use crate::{DeviceIdBox, KeyNameBox, ServerNameBox, SigningKeyId, UserId}; use crate::{DeviceId, KeyName, ServerName, SigningKeyId, UserId};
/// Map of key identifier to signature values. /// Map of key identifier to signature values.
pub type EntitySignatures<K> = BTreeMap<SigningKeyId<K>, String>; pub type EntitySignatures<K> = BTreeMap<SigningKeyId<K>, String>;
@ -52,7 +52,7 @@ impl<E: Ord, K: ?Sized> Signatures<E, K> {
} }
/// Map of server signatures for an event, grouped by server. /// Map of server signatures for an event, grouped by server.
pub type ServerSignatures = Signatures<ServerNameBox, KeyNameBox>; pub type ServerSignatures = Signatures<Box<ServerName>, Box<KeyName>>;
/// Map of device signatures for an event, grouped by user. /// Map of device signatures for an event, grouped by user.
pub type DeviceSignatures = Signatures<UserId, DeviceIdBox>; pub type DeviceSignatures = Signatures<UserId, Box<DeviceId>>;

View File

@ -2,7 +2,7 @@
use js_int::UInt; use js_int::UInt;
use ruma_api::ruma_api; use ruma_api::ruma_api;
use ruma_identifiers::{ClientSecret, SessionIdBox}; use ruma_identifiers::{ClientSecret, SessionId};
ruma_api! { ruma_api! {
metadata: { metadata: {
@ -35,7 +35,7 @@ ruma_api! {
/// 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: SessionIdBox, pub sid: Box<SessionId>,
} }
} }
@ -54,7 +54,7 @@ impl<'a> Request<'a> {
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: SessionIdBox) -> Self { pub fn new(sid: Box<SessionId>) -> Self {
Self { sid } Self { sid }
} }
} }

View File

@ -2,7 +2,7 @@
use js_int::UInt; use js_int::UInt;
use ruma_api::ruma_api; use ruma_api::ruma_api;
use ruma_identifiers::{ClientSecret, SessionIdBox}; use ruma_identifiers::{ClientSecret, SessionId};
ruma_api! { ruma_api! {
metadata: { metadata: {
@ -40,7 +40,7 @@ ruma_api! {
/// 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: SessionIdBox, pub sid: Box<SessionId>,
} }
} }
@ -60,7 +60,7 @@ impl<'a> Request<'a> {
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: SessionIdBox) -> Self { pub fn new(sid: Box<SessionId>) -> Self {
Self { sid } Self { sid }
} }
} }

View File

@ -2,7 +2,7 @@
use ruma_api::ruma_api; use ruma_api::ruma_api;
use ruma_common::thirdparty::Medium; use ruma_common::thirdparty::Medium;
use ruma_identifiers::{user_id::UserId, ClientSecretBox, SessionIdBox}; use ruma_identifiers::{user_id::UserId, ClientSecret, SessionId};
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
ruma_api! { ruma_api! {
@ -81,15 +81,15 @@ impl ThirdPartyId {
#[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: SessionIdBox, pub sid: Box<SessionId>,
/// The client secret passed to the `requestToken` call. /// The client secret passed to the `requestToken` call.
pub client_secret: ClientSecretBox, pub client_secret: Box<ClientSecret>,
} }
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: SessionIdBox, client_secret: ClientSecretBox) -> Self { pub fn new(sid: Box<SessionId>, client_secret: Box<ClientSecret>) -> Self {
Self { sid, client_secret } Self { sid, client_secret }
} }
} }

View File

@ -1,4 +1,4 @@
use ruma_identifiers::{EventId, RoomVersionId, ServerNameBox}; use ruma_identifiers::{EventId, RoomVersionId, ServerName};
use thiserror::Error; use thiserror::Error;
/// `ruma-signature`'s error type, wraps a number of other error types. /// `ruma-signature`'s error type, wraps a number of other error types.
@ -136,11 +136,11 @@ pub enum JsonType {
pub enum VerificationError { pub enum VerificationError {
/// For when a signature cannot be found for a `target`. /// For when a signature cannot be found for a `target`.
#[error("Could not find signatures for {0:?}")] #[error("Could not find signatures for {0:?}")]
SignatureNotFound(ServerNameBox), SignatureNotFound(Box<ServerName>),
/// For when a public key cannot be found for a `target`. /// For when a public key cannot be found for a `target`.
#[error("Could not find public key for {0:?}")] #[error("Could not find public key for {0:?}")]
PublicKeyNotFound(ServerNameBox), PublicKeyNotFound(Box<ServerName>),
/// For when no public key matches the signature given. /// For when no public key matches the signature given.
#[error("Not signed with any of the given public keys")] #[error("Not signed with any of the given public keys")]
@ -152,11 +152,11 @@ pub enum VerificationError {
} }
impl VerificationError { impl VerificationError {
pub(crate) fn signature_not_found<T: Into<ServerNameBox>>(target: T) -> Error { pub(crate) fn signature_not_found<T: Into<Box<ServerName>>>(target: T) -> Error {
Self::SignatureNotFound(target.into()).into() Self::SignatureNotFound(target.into()).into()
} }
pub(crate) fn public_key_not_found<T: Into<ServerNameBox>>(target: T) -> Error { pub(crate) fn public_key_not_found<T: Into<Box<ServerName>>>(target: T) -> Error {
Self::PublicKeyNotFound(target.into()).into() Self::PublicKeyNotFound(target.into()).into()
} }
} }

View File

@ -9,7 +9,7 @@ use std::{
use base64::{decode_config, encode_config, Config, STANDARD_NO_PAD, URL_SAFE_NO_PAD}; use base64::{decode_config, encode_config, Config, STANDARD_NO_PAD, URL_SAFE_NO_PAD};
use ed25519_dalek::Digest; use ed25519_dalek::Digest;
use ruma_identifiers::{EventId, RoomVersionId, ServerNameBox, UserId}; use ruma_identifiers::{EventId, RoomVersionId, ServerName, UserId};
use ruma_serde::{CanonicalJsonObject, CanonicalJsonValue}; use ruma_serde::{CanonicalJsonObject, CanonicalJsonValue};
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::Sha256; use sha2::Sha256;
@ -774,7 +774,7 @@ pub fn redact(
fn servers_to_check_signatures( fn servers_to_check_signatures(
object: &CanonicalJsonObject, object: &CanonicalJsonObject,
version: &RoomVersionId, version: &RoomVersionId,
) -> Result<BTreeSet<ServerNameBox>, Error> { ) -> Result<BTreeSet<Box<ServerName>>, Error> {
let mut servers_to_check = BTreeSet::new(); let mut servers_to_check = BTreeSet::new();
if !is_third_party_invite(object)? { if !is_third_party_invite(object)? {

View File

@ -83,11 +83,10 @@ pub use ruma_serde::Outgoing;
pub use ruma_identifiers::{ pub use ruma_identifiers::{
device_id, device_key_id, event_id, mxc_uri, room_alias_id, room_id, room_version_id, device_id, device_key_id, event_id, mxc_uri, room_alias_id, room_id, room_version_id,
server_name, server_signing_key_id, user_id, ClientSecret, ClientSecretBox, DeviceId, server_name, server_signing_key_id, user_id, ClientSecret, DeviceId, DeviceKeyAlgorithm,
DeviceIdBox, DeviceKeyAlgorithm, DeviceKeyId, DeviceSignatures, DeviceSigningKeyId, DeviceKeyId, DeviceSignatures, DeviceSigningKeyId, EntitySignatures, EventEncryptionAlgorithm,
EntitySignatures, EventEncryptionAlgorithm, EventId, KeyId, KeyName, KeyNameBox, MxcUri, EventId, KeyId, KeyName, MxcUri, RoomAliasId, RoomId, RoomIdOrAliasId, RoomVersionId,
RoomAliasId, RoomId, RoomIdOrAliasId, RoomVersionId, ServerName, ServerNameBox, ServerName, ServerSignatures, ServerSigningKeyId, SessionId, Signatures, SigningKeyAlgorithm,
ServerSignatures, ServerSigningKeyId, SessionId, SessionIdBox, Signatures, SigningKeyAlgorithm,
UserId, UserId,
}; };