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)
use ruma_api::ruma_api;
use ruma_identifiers::{DeviceId, DeviceIdBox, UserId};
use ruma_identifiers::{DeviceId, UserId};
use serde::{Deserialize, Serialize};
use crate::r0::uiaa::{AuthData, IncomingAuthData, UiaaResponse};
@ -88,7 +88,7 @@ ruma_api! {
/// ID of the registered device.
///
/// 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

View File

@ -2,7 +2,7 @@
use js_int::UInt;
use ruma_api::ruma_api;
use ruma_identifiers::{ClientSecret, SessionIdBox};
use ruma_identifiers::{ClientSecret, SessionId};
use super::{IdentityServerInfo, IncomingIdentityServerInfo};
@ -39,7 +39,7 @@ ruma_api! {
response: {
/// The session identifier given by the identity server.
pub sid: SessionIdBox,
pub sid: Box<SessionId>,
/// URL to submit validation token to.
///
@ -67,7 +67,7 @@ impl<'a> Request<'a> {
impl Response {
/// 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 }
}
}

View File

@ -2,7 +2,7 @@
use js_int::UInt;
use ruma_api::ruma_api;
use ruma_identifiers::{ClientSecret, SessionIdBox};
use ruma_identifiers::{ClientSecret, SessionId};
use super::{IdentityServerInfo, IncomingIdentityServerInfo};
@ -42,7 +42,7 @@ ruma_api! {
response: {
/// The session identifier given by the identity server.
pub sid: SessionIdBox,
pub sid: Box<SessionId>,
/// URL to submit validation token to.
///
@ -83,7 +83,7 @@ impl<'a> Request<'a> {
impl Response {
/// 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 }
}
}

View File

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

View File

@ -2,7 +2,7 @@
use js_int::UInt;
use ruma_api::ruma_api;
use ruma_identifiers::{ClientSecret, SessionIdBox};
use ruma_identifiers::{ClientSecret, SessionId};
use super::{IdentityServerInfo, IncomingIdentityServerInfo};
@ -39,7 +39,7 @@ ruma_api! {
response: {
/// The session identifier given by the identity server.
pub sid: SessionIdBox,
pub sid: Box<SessionId>,
/// URL to submit validation token to.
///
@ -68,7 +68,7 @@ impl<'a> Request<'a> {
impl Response {
/// 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 }
}
}

View File

@ -2,7 +2,7 @@
use js_int::UInt;
use ruma_api::ruma_api;
use ruma_identifiers::{ClientSecret, SessionIdBox};
use ruma_identifiers::{ClientSecret, SessionId};
ruma_api! {
metadata: {
@ -34,7 +34,7 @@ ruma_api! {
response: {
/// The session identifier given by the identity server.
pub sid: SessionIdBox,
pub sid: Box<SessionId>,
/// URL to submit validation token to.
///
@ -68,7 +68,7 @@ impl<'a> Request<'a> {
impl Response {
/// 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 }
}
}

View File

@ -2,7 +2,7 @@
use js_int::UInt;
use ruma_api::ruma_api;
use ruma_identifiers::{ClientSecret, SessionIdBox};
use ruma_identifiers::{ClientSecret, SessionId};
use super::{IdentityServerInfo, IncomingIdentityServerInfo};
@ -39,7 +39,7 @@ ruma_api! {
response: {
/// The session identifier given by the identity server.
pub sid: SessionIdBox,
pub sid: Box<SessionId>,
/// URL to submit validation token to.
///
@ -68,7 +68,7 @@ impl<'a> Request<'a> {
impl Response {
/// 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 }
}
}

View File

@ -2,7 +2,7 @@
use js_int::UInt;
use ruma_api::ruma_api;
use ruma_identifiers::{ClientSecret, SessionIdBox};
use ruma_identifiers::{ClientSecret, SessionId};
use super::{IdentityServerInfo, IncomingIdentityServerInfo};
@ -42,7 +42,7 @@ ruma_api! {
response: {
/// The session identifier given by the identity server.
pub sid: SessionIdBox,
pub sid: Box<SessionId>,
/// URL to submit validation token to.
///
@ -83,7 +83,7 @@ impl<'a> Request<'a> {
impl Response {
/// 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 }
}
}

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)
use ruma_api::ruma_api;
use ruma_identifiers::{RoomAliasId, RoomId, ServerNameBox};
use ruma_identifiers::{RoomAliasId, RoomId, ServerName};
ruma_api! {
metadata: {
@ -24,7 +24,7 @@ ruma_api! {
pub room_id: RoomId,
/// A list of servers that are aware of this room ID.
pub servers: Vec<ServerNameBox>,
pub servers: Vec<Box<ServerName>>,
}
error: crate::Error
@ -39,7 +39,7 @@ impl<'a> Request<'a> {
impl Response {
/// 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 }
}
}

View File

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

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)
use ruma_api::ruma_api;
use ruma_identifiers::DeviceIdBox;
use ruma_identifiers::DeviceId;
use crate::r0::uiaa::{AuthData, IncomingAuthData, UiaaResponse};
@ -17,7 +17,7 @@ ruma_api! {
request: {
/// List of devices to delete.
pub devices: &'a [DeviceIdBox],
pub devices: &'a [Box<DeviceId>],
/// Additional authentication information for the user-interactive authentication API.
#[serde(skip_serializing_if = "Option::is_none")]
@ -32,7 +32,7 @@ ruma_api! {
impl<'a> Request<'a> {
/// 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 }
}
}

View File

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

View File

@ -4,7 +4,7 @@ use std::{collections::BTreeMap, time::Duration};
use ruma_api::ruma_api;
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;
ruma_api! {
@ -28,7 +28,7 @@ ruma_api! {
pub timeout: Option<Duration>,
/// 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: {
@ -45,7 +45,9 @@ ruma_api! {
impl Request {
/// 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 }
}
}
@ -58,4 +60,4 @@ impl Response {
}
/// 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_common::encryption::DeviceKeys;
use ruma_identifiers::{DeviceIdBox, UserId};
use ruma_identifiers::{DeviceId, UserId};
use serde_json::Value as JsonValue;
#[cfg(feature = "unstable-pre-spec")]
@ -35,7 +35,7 @@ ruma_api! {
/// The keys to be downloaded.
///
/// 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
/// 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.
#[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.
#[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)
use ruma_api::ruma_api;
use ruma_identifiers::{RoomId, RoomIdOrAliasId, ServerNameBox};
use ruma_identifiers::{RoomId, RoomIdOrAliasId, ServerName};
ruma_api! {
metadata: {
@ -27,7 +27,7 @@ ruma_api! {
/// One of the servers must be participating in the room.
#[ruma_api(query)]
#[serde(default, skip_serializing_if = "<[_]>::is_empty")]
pub server_name: &'a [ServerNameBox],
pub server_name: &'a [Box<ServerName>],
}
response: {

View File

@ -15,7 +15,7 @@ pub mod unban_user;
use std::collections::BTreeMap;
use ruma_common::thirdparty::Medium;
use ruma_identifiers::{ServerNameBox, ServerSigningKeyId, UserId};
use ruma_identifiers::{ServerName, ServerSigningKeyId, UserId};
use ruma_serde::Outgoing;
use serde::Serialize;
@ -34,7 +34,7 @@ pub struct ThirdPartySigned<'a> {
pub token: &'a str,
/// 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> {
@ -44,7 +44,7 @@ impl<'a> ThirdPartySigned<'a> {
sender: &'a UserId,
mxid: &'a UserId,
token: &'a str,
signatures: BTreeMap<ServerNameBox, BTreeMap<ServerSigningKeyId, String>>,
signatures: BTreeMap<Box<ServerName>, BTreeMap<ServerSigningKeyId, String>>,
) -> Self {
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)
use ruma_api::ruma_api;
use ruma_identifiers::{RoomId, RoomIdOrAliasId, ServerNameBox};
use ruma_identifiers::{RoomId, RoomIdOrAliasId, ServerName};
use super::{IncomingThirdPartySigned, ThirdPartySigned};
@ -25,7 +25,7 @@ ruma_api! {
/// One of the servers must be participating in the room.
#[ruma_api(query)]
#[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
/// 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)
use ruma_api::ruma_api;
use ruma_identifiers::{DeviceId, DeviceIdBox, ServerNameBox, UserId};
use ruma_identifiers::{DeviceId, ServerName, UserId};
use ruma_serde::{JsonObject, Outgoing};
use serde::{
de::{self, DeserializeOwned},
@ -49,13 +49,13 @@ ruma_api! {
/// Deprecated: Clients should instead use the `user_id.server_name()`
/// method if they require it.
#[serde(skip_serializing_if = "Option::is_none")]
pub home_server: Option<ServerNameBox>,
pub home_server: Option<Box<ServerName>>,
/// ID of the logged-in device.
///
/// Will be the same as the corresponding parameter in the request, if one was
/// specified.
pub device_id: DeviceIdBox,
pub device_id: Box<DeviceId>,
/// Client configuration provided by the server.
///
@ -76,7 +76,7 @@ impl<'a> Request<'a> {
impl Response {
/// 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 }
}
}

View File

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

View File

@ -4,7 +4,7 @@
use std::collections::BTreeMap;
use ruma_identifiers::{DeviceIdBox, DeviceKeyId, EventEncryptionAlgorithm, UserId};
use ruma_identifiers::{DeviceId, DeviceKeyId, EventEncryptionAlgorithm, UserId};
use serde::{Deserialize, Serialize};
/// Identity keys for a device.
@ -19,7 +19,7 @@ pub struct DeviceKeys {
/// The ID of the device these keys belong to.
///
/// 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.
pub algorithms: Vec<EventEncryptionAlgorithm>,
@ -41,7 +41,7 @@ impl DeviceKeys {
/// signatures.
pub fn new(
user_id: UserId,
device_id: DeviceIdBox,
device_id: Box<DeviceId>,
algorithms: Vec<EventEncryptionAlgorithm>,
keys: BTreeMap<DeviceKeyId, String>,
signatures: BTreeMap<UserId, BTreeMap<DeviceKeyId, String>>,

View File

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

View File

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

View File

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

View File

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

View File

@ -9,7 +9,7 @@ use std::collections::BTreeMap;
use js_int::UInt;
use ruma_common::MilliSecondsSinceUnixEpoch;
use ruma_identifiers::{EventId, RoomId, ServerNameBox, ServerSigningKeyId, UserId};
use ruma_identifiers::{EventId, RoomId, ServerName, ServerSigningKeyId, UserId};
use serde::{
de::{Error as _, IgnoredAny},
Deserialize, Deserializer, Serialize,
@ -89,7 +89,7 @@ pub struct RoomV1Pdu {
pub hashes: EventHash,
/// 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.
@ -146,7 +146,7 @@ pub struct RoomV3Pdu {
pub hashes: EventHash,
/// Signatures for the PDU.
pub signatures: BTreeMap<ServerNameBox, BTreeMap<ServerSigningKeyId, String>>,
pub signatures: BTreeMap<Box<ServerName>, BTreeMap<ServerSigningKeyId, String>>,
}
/// Content hashes of a PDU.

View File

@ -4,7 +4,7 @@ use std::collections::BTreeMap;
use js_int::UInt;
use ruma_events_macros::EventContent;
use ruma_identifiers::DeviceIdBox;
use ruma_identifiers::DeviceId;
#[cfg(feature = "unstable-pre-spec")]
use ruma_identifiers::EventId;
use serde::{Deserialize, Serialize};
@ -212,7 +212,7 @@ pub struct MegolmV1AesSha2Content {
pub sender_key: String,
/// 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.
pub session_id: String,
@ -232,7 +232,7 @@ pub struct MegolmV1AesSha2ContentInit {
pub sender_key: String,
/// 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.
pub session_id: String,

View File

@ -3,7 +3,7 @@
use std::collections::BTreeMap;
use ruma_events_macros::EventContent;
use ruma_identifiers::{MxcUri, ServerNameBox, ServerSigningKeyId, UserId};
use ruma_identifiers::{MxcUri, ServerName, ServerSigningKeyId, UserId};
use ruma_serde::StringEnum;
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
/// 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.
pub token: String,
@ -188,7 +188,7 @@ impl SignedContent {
/// Creates a new `SignedContent` with the given mxid, signature and token.
pub fn new(
mxid: UserId,
signatures: BTreeMap<ServerNameBox, BTreeMap<ServerSigningKeyId, String>>,
signatures: BTreeMap<Box<ServerName>, BTreeMap<ServerSigningKeyId, String>>,
token: String,
) -> Self {
Self { mxid, signatures, token }

View File

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

View File

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

View File

@ -1,7 +1,7 @@
//! Types for the `m.room_key_request` event.
use ruma_events_macros::EventContent;
use ruma_identifiers::{DeviceIdBox, EventEncryptionAlgorithm, RoomId};
use ruma_identifiers::{DeviceId, EventEncryptionAlgorithm, RoomId};
use ruma_serde::StringEnum;
use serde::{Deserialize, Serialize};
@ -19,7 +19,7 @@ pub struct ToDeviceRoomKeyRequestEventContent {
pub body: Option<RequestedKeyInfo>,
/// 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.
///
@ -34,7 +34,7 @@ impl ToDeviceRoomKeyRequestEventContent {
pub fn new(
action: Action,
body: Option<RequestedKeyInfo>,
requesting_device_id: DeviceIdBox,
requesting_device_id: Box<DeviceId>,
request_id: String,
) -> Self {
Self { action, body, requesting_device_id, request_id }

View File

@ -3,7 +3,7 @@
use std::convert::TryFrom;
use ruma_events_macros::EventContent;
use ruma_identifiers::DeviceIdBox;
use ruma_identifiers::DeviceId;
use ruma_serde::StringEnum;
use serde::{ser::SerializeStruct, Deserialize, Serialize};
@ -21,7 +21,7 @@ pub struct ToDeviceSecretRequestEventContent {
pub action: RequestAction,
/// 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
/// target for a secret.
@ -36,7 +36,7 @@ impl ToDeviceSecretRequestEventContent {
/// request ID.
pub fn new(
action: RequestAction,
requesting_device_id: DeviceIdBox,
requesting_device_id: Box<DeviceId>,
request_id: String,
) -> Self {
Self { action, requesting_device_id, request_id }

View File

@ -1,7 +1,7 @@
//! Types for the `m.space.child` event.
use ruma_events_macros::EventContent;
use ruma_identifiers::ServerNameBox;
use ruma_identifiers::ServerName;
use serde::{Deserialize, Serialize};
/// The content of an `m.space.child` event.
@ -17,7 +17,7 @@ use serde::{Deserialize, Serialize};
pub struct SpaceChildEventContent {
/// List of candidate servers that can be used to join the room.
#[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.
///

View File

@ -1,7 +1,7 @@
//! Types for the `m.space.child` event.
use ruma_events_macros::EventContent;
use ruma_identifiers::ServerNameBox;
use ruma_identifiers::ServerName;
use serde::{Deserialize, Serialize};
/// The content of an `m.space.parent` event.
@ -17,7 +17,7 @@ use serde::{Deserialize, Serialize};
pub struct SpaceParentEventContent {
/// List of candidate servers that can be used to join the room.
#[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.
///

View File

@ -2,7 +2,7 @@ use std::convert::TryFrom;
use matches::assert_matches;
use ruma_events::{AnyInitialStateEvent, InitialStateEvent};
use ruma_identifiers::RoomNameBox;
use ruma_identifiers::RoomName;
use serde_json::json;
#[test]
@ -14,7 +14,7 @@ fn deserialize_initial_state_event() {
}))
.unwrap(),
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()
);
}

View File

@ -16,7 +16,7 @@ use ruma_events::{
Unsigned,
};
#[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 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")]
fn verification_request_deserialization() {
let user_id = user_id!("@example2:localhost");
let device_id: DeviceIdBox = "XOWLHHFSWM".into();
let device_id: Box<DeviceId> = "XOWLHHFSWM".into();
let json_data = json!({
"body": "@example:localhost is requesting to verify your key, ...",
@ -334,7 +334,7 @@ fn verification_request_deserialization() {
#[cfg(feature = "unstable-pre-spec")]
fn verification_request_serialization() {
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 methods = vec![

View File

@ -5,7 +5,7 @@ use ruma_events::{
room::{join_rules::JoinRule, topic::RoomTopicEventContent},
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};
#[test]
@ -96,7 +96,7 @@ fn deserialize_stripped_state_events() {
let event = from_json_value::<AnyStrippedStateEvent>(name_event).unwrap();
match 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.sender.to_string(), "@example:localhost");
}

View File

@ -3,7 +3,7 @@
use js_int::UInt;
use ruma_api::ruma_api;
use ruma_common::MilliSecondsSinceUnixEpoch;
use ruma_identifiers::{EventId, RoomId, ServerNameBox};
use ruma_identifiers::{EventId, RoomId, ServerName};
use serde_json::value::RawValue as RawJsonValue;
@ -33,7 +33,7 @@ ruma_api! {
response: {
/// 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.
pub origin_server_ts: MilliSecondsSinceUnixEpoch,
@ -59,7 +59,7 @@ impl Response {
/// * the timestamp in milliseconds of when this transaction started.
/// * the list of persistent updates to rooms.
pub fn new(
origin: ServerNameBox,
origin: Box<ServerName>,
origin_server_ts: MilliSecondsSinceUnixEpoch,
pdus: Vec<Box<RawJsonValue>>,
) -> Self {

View File

@ -3,7 +3,7 @@
use js_int::UInt;
use ruma_api::ruma_api;
use ruma_common::encryption::DeviceKeys;
use ruma_identifiers::{DeviceIdBox, UserId};
use ruma_identifiers::{DeviceId, UserId};
use serde::{Deserialize, Serialize};
ruma_api! {
@ -60,7 +60,7 @@ impl Response {
#[cfg_attr(not(feature = "unstable-exhaustive-types"), non_exhaustive)]
pub struct UserDevice {
/// The device ID.
pub device_id: DeviceIdBox,
pub device_id: Box<DeviceId>,
/// Identity keys for the device.
pub keys: DeviceKeys,
@ -72,7 +72,7 @@ pub struct UserDevice {
impl UserDevice {
/// 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 }
}
}

View File

@ -3,7 +3,7 @@
use std::collections::BTreeMap;
use ruma_common::MilliSecondsSinceUnixEpoch;
use ruma_identifiers::{ServerNameBox, ServerSigningKeyId};
use ruma_identifiers::{ServerName, ServerSigningKeyId};
use serde::{Deserialize, Serialize};
pub mod discover_homeserver;
@ -51,7 +51,7 @@ impl OldVerifyKey {
#[cfg_attr(not(feature = "unstable-exhaustive-types"), non_exhaustive)]
pub struct ServerSigningKeys {
/// DNS name of the homeserver.
pub server_name: ServerNameBox,
pub server_name: Box<ServerName>,
/// Public keys of the homeserver for verifying digital signatures.
pub verify_keys: BTreeMap<ServerSigningKeyId, VerifyKey>,
@ -61,8 +61,8 @@ 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<ServerNameBox, BTreeMap<ServerSigningKeyId, String>>,
/// Map of server name to keys by key ID.
pub signatures: BTreeMap<Box<ServerName>, BTreeMap<ServerSigningKeyId, String>>,
/// 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.
///
/// 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 {
server_name,
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)
use ruma_api::ruma_api;
use ruma_identifiers::ServerNameBox;
use ruma_identifiers::ServerName;
ruma_api! {
metadata: {
@ -19,7 +19,7 @@ ruma_api! {
response: {
/// The server name to delegate server-server communications to, with optional port.
#[serde(rename = "m.server")]
pub server: ServerNameBox,
pub server: Box<ServerName>,
}
}
@ -32,7 +32,7 @@ impl Request {
impl Response {
/// Creates a new `Response` with the given homeserver.
pub fn new(server: ServerNameBox) -> Self {
pub fn new(server: Box<ServerName>) -> Self {
Self { server }
}
}

View File

@ -4,7 +4,7 @@ use std::collections::BTreeMap;
use ruma_api::ruma_api;
use ruma_common::MilliSecondsSinceUnixEpoch;
use ruma_identifiers::{ServerNameBox, ServerSigningKeyId};
use ruma_identifiers::{ServerName, ServerSigningKeyId};
use serde::{Deserialize, Serialize};
use crate::discovery::ServerSigningKeys;
@ -28,7 +28,7 @@ ruma_api! {
/// 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<ServerNameBox, BTreeMap<ServerSigningKeyId, QueryCriteria>>,
pub server_keys: BTreeMap<Box<ServerName>, BTreeMap<ServerSigningKeyId, QueryCriteria>>,
}
@ -41,7 +41,7 @@ ruma_api! {
impl Request {
/// Creates a new `Request` with the given query criteria.
pub fn new(
server_keys: BTreeMap<ServerNameBox, BTreeMap<ServerSigningKeyId, QueryCriteria>>,
server_keys: BTreeMap<Box<ServerName>, BTreeMap<ServerSigningKeyId, QueryCriteria>>,
) -> Self {
Self { server_keys }
}

View File

@ -2,7 +2,7 @@
use ruma_api::ruma_api;
use ruma_common::MilliSecondsSinceUnixEpoch;
use ruma_identifiers::{EventId, ServerNameBox};
use ruma_identifiers::{EventId, ServerName};
use serde_json::value::RawValue as RawJsonValue;
@ -24,7 +24,7 @@ ruma_api! {
response: {
/// The `server_name` of the homeserver sending this transaction.
pub origin: ServerNameBox,
pub origin: Box<ServerName>,
/// Time on originating homeserver when this transaction started.
pub origin_server_ts: MilliSecondsSinceUnixEpoch,
@ -45,7 +45,7 @@ impl<'a> Request<'a> {
impl Response {
/// Creates a new `Response` with the given server name, timestamp, and event.
pub fn new(
origin: ServerNameBox,
origin: Box<ServerName>,
origin_server_ts: MilliSecondsSinceUnixEpoch,
pdu: Box<RawJsonValue>,
) -> Self {

View File

@ -5,7 +5,7 @@ use std::collections::BTreeMap;
use ruma_api::ruma_api;
use ruma_common::encryption::OneTimeKey;
use ruma_identifiers::{DeviceIdBox, DeviceKeyAlgorithm, DeviceKeyId, UserId};
use ruma_identifiers::{DeviceId, DeviceKeyAlgorithm, DeviceKeyId, UserId};
use serde::{Deserialize, Serialize};
ruma_api! {
@ -44,10 +44,10 @@ impl Response {
}
/// 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
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
#[derive(Debug, Clone, Serialize, Deserialize)]

View File

@ -6,7 +6,7 @@ use ruma_api::ruma_api;
#[cfg(feature = "unstable-pre-spec")]
use ruma_common::encryption::CrossSigningKey;
use ruma_common::encryption::DeviceKeys;
use ruma_identifiers::{DeviceIdBox, UserId};
use ruma_identifiers::{DeviceId, UserId};
ruma_api! {
metadata: {
@ -22,13 +22,13 @@ ruma_api! {
/// The keys to be downloaded.
///
/// 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)]
response: {
/// 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.
#[cfg(feature = "unstable-pre-spec")]
@ -44,14 +44,14 @@ ruma_api! {
impl Request {
/// 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 }
}
}
impl Response {
/// 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() }
}
}

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)
use ruma_api::ruma_api;
use ruma_identifiers::{RoomAliasId, RoomId, ServerNameBox};
use ruma_identifiers::{RoomAliasId, RoomId, ServerName};
ruma_api! {
metadata: {
@ -24,7 +24,7 @@ ruma_api! {
pub room_id: RoomId,
/// 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 {
/// 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 }
}
}

View File

@ -4,7 +4,7 @@ use std::collections::BTreeMap;
use ruma_api::ruma_api;
use ruma_common::thirdparty::Medium;
use ruma_identifiers::{RoomId, ServerNameBox, ServerSigningKeyId, UserId};
use ruma_identifiers::{RoomId, ServerName, ServerSigningKeyId, UserId};
use serde::{Deserialize, Serialize};
ruma_api! {
@ -77,7 +77,7 @@ pub struct ThirdPartyInvite {
pub sender: UserId,
/// 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 {
@ -87,7 +87,7 @@ impl ThirdPartyInvite {
mxid: UserId,
room_id: RoomId,
sender: UserId,
signed: BTreeMap<ServerNameBox, BTreeMap<ServerSigningKeyId, String>>,
signed: BTreeMap<Box<ServerName>, BTreeMap<ServerSigningKeyId, String>>,
) -> Self {
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,
};
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 serde::{de, Deserialize, Serialize};
use serde_json::{value::RawValue as RawJsonValue, Value as JsonValue};
@ -206,7 +206,7 @@ pub struct DeviceListUpdateContent {
pub user_id: UserId,
/// 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.
///
@ -234,7 +234,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: UserId, device_id: DeviceIdBox, stream_id: UInt) -> Self {
pub fn new(user_id: UserId, device_id: Box<DeviceId>, stream_id: UInt) -> Self {
Self {
user_id,
device_id,

View File

@ -72,7 +72,7 @@ Breaking changes:
Improvements:
* 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
* Allow crypto algorithm enums to contain any string, for forwards compatibility
and to allow experimentation with non-specified ones

View File

@ -26,7 +26,6 @@ unstable-pre-spec = []
[dependencies]
either = { version = "1.6.1", optional = true }
paste = "1.0.5"
percent-encoding = "2.1.0"
rand = { version = "0.8.3", optional = true }
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)]
pub use crate::{
client_secret::{ClientSecret, ClientSecretBox},
client_secret::ClientSecret,
crypto_algorithms::{DeviceKeyAlgorithm, EventEncryptionAlgorithm, SigningKeyAlgorithm},
device_id::{DeviceId, DeviceIdBox},
device_id::DeviceId,
device_key_id::DeviceKeyId,
event_id::EventId,
key_id::{DeviceSigningKeyId, KeyId, ServerSigningKeyId, SigningKeyId},
key_name::{KeyName, KeyNameBox},
key_name::KeyName,
matrix_to::MatrixToRef,
mxc_uri::MxcUri,
room_alias_id::RoomAliasId,
room_id::RoomId,
room_id_or_room_alias_id::RoomIdOrAliasId,
room_name::{RoomName, RoomNameBox},
room_name::RoomName,
room_version_id::RoomVersionId,
server_name::{ServerName, ServerNameBox},
session_id::{SessionId, SessionIdBox},
server_name::ServerName,
session_id::SessionId,
signatures::{DeviceSignatures, EntitySignatures, ServerSignatures, Signatures},
user_id::UserId,
};

View File

@ -168,13 +168,6 @@ macro_rules! opaque_identifier {
#[repr(transparent)]
pub struct $id(str);
paste::paste! {
doc_concat! {
#[doc = concat!("An owned [", stringify!($id), "].")]
pub type [<$id Box>] = Box<$id>;
}
}
impl $id {
fn from_borrowed(s: &str) -> &Self {
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"))]
pub struct $id(str);
paste::paste! {
doc_concat! {
#[doc = concat!("An owned [", stringify!($id), "].")]
pub type [<$id Box>] = Box<$id>;
}
}
impl $id {
#[allow(clippy::transmute_ptr_to_ptr)]
fn from_borrowed(s: &str) -> &Self {

View File

@ -1,6 +1,6 @@
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.
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.
pub type ServerSignatures = Signatures<ServerNameBox, KeyNameBox>;
pub type ServerSignatures = Signatures<Box<ServerName>, Box<KeyName>>;
/// 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 ruma_api::ruma_api;
use ruma_identifiers::{ClientSecret, SessionIdBox};
use ruma_identifiers::{ClientSecret, SessionId};
ruma_api! {
metadata: {
@ -35,7 +35,7 @@ ruma_api! {
/// The session ID.
///
/// 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 {
/// Create a new `Response` with the given session ID.
pub fn new(sid: SessionIdBox) -> Self {
pub fn new(sid: Box<SessionId>) -> Self {
Self { sid }
}
}

View File

@ -2,7 +2,7 @@
use js_int::UInt;
use ruma_api::ruma_api;
use ruma_identifiers::{ClientSecret, SessionIdBox};
use ruma_identifiers::{ClientSecret, SessionId};
ruma_api! {
metadata: {
@ -40,7 +40,7 @@ ruma_api! {
/// The session ID.
///
/// 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 {
/// Create a new `Response` with the given session ID.
pub fn new(sid: SessionIdBox) -> Self {
pub fn new(sid: Box<SessionId>) -> Self {
Self { sid }
}
}

View File

@ -2,7 +2,7 @@
use ruma_api::ruma_api;
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};
ruma_api! {
@ -81,15 +81,15 @@ impl ThirdPartyId {
#[cfg_attr(not(feature = "unstable-exhaustive-types"), non_exhaustive)]
pub struct ThreePidOwnershipProof {
/// The Session ID generated by the `requestToken` call.
pub sid: SessionIdBox,
pub sid: Box<SessionId>,
/// The client secret passed to the `requestToken` call.
pub client_secret: ClientSecretBox,
pub client_secret: Box<ClientSecret>,
}
impl ThreePidOwnershipProof {
/// 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 }
}
}

View File

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

View File

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

View File

@ -83,11 +83,10 @@ pub use ruma_serde::Outgoing;
pub use ruma_identifiers::{
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,
DeviceIdBox, DeviceKeyAlgorithm, DeviceKeyId, DeviceSignatures, DeviceSigningKeyId,
EntitySignatures, EventEncryptionAlgorithm, EventId, KeyId, KeyName, KeyNameBox, MxcUri,
RoomAliasId, RoomId, RoomIdOrAliasId, RoomVersionId, ServerName, ServerNameBox,
ServerSignatures, ServerSigningKeyId, SessionId, SessionIdBox, Signatures, SigningKeyAlgorithm,
server_name, server_signing_key_id, user_id, ClientSecret, DeviceId, DeviceKeyAlgorithm,
DeviceKeyId, DeviceSignatures, DeviceSigningKeyId, EntitySignatures, EventEncryptionAlgorithm,
EventId, KeyId, KeyName, MxcUri, RoomAliasId, RoomId, RoomIdOrAliasId, RoomVersionId,
ServerName, ServerSignatures, ServerSigningKeyId, SessionId, Signatures, SigningKeyAlgorithm,
UserId,
};