From 4a1b6d56073639ec2ffaac38a98cdf530deca696 Mon Sep 17 00:00:00 2001 From: Jonas Platte Date: Thu, 13 Aug 2020 21:13:36 +0200 Subject: [PATCH] Use DeviceIdBox in ruma-events, ruma-*-api --- ruma-client-api/src/r0/account/register.rs | 4 ++-- ruma-client-api/src/r0/device.rs | 4 ++-- ruma-client-api/src/r0/device/delete_devices.rs | 4 ++-- ruma-client-api/src/r0/device/get_device.rs | 2 +- ruma-client-api/src/r0/device/update_device.rs | 2 +- ruma-client-api/src/r0/keys/claim_keys.rs | 6 +++--- ruma-client-api/src/r0/keys/get_keys.rs | 6 +++--- ruma-client-api/src/r0/session/login.rs | 6 +++--- ruma-client-api/src/r0/to_device.rs | 4 ++-- ruma-client/src/lib.rs | 4 ++-- ruma-client/src/session.rs | 6 +++--- ruma-common/src/encryption.rs | 4 ++-- ruma-events/src/key/verification/request.rs | 4 ++-- ruma-events/src/key/verification/start.rs | 4 ++-- ruma-events/src/room/encrypted.rs | 6 +++--- ruma-events/src/room_key_request.rs | 4 ++-- ruma-federation-api/src/device/get_devices/v1.rs | 4 ++-- ruma-federation-api/src/keys/claim_keys/v1.rs | 6 +++--- ruma-federation-api/src/keys/get_keys/v1.rs | 10 +++++----- 19 files changed, 45 insertions(+), 45 deletions(-) diff --git a/ruma-client-api/src/r0/account/register.rs b/ruma-client-api/src/r0/account/register.rs index 54c63d3b..7f21d41b 100644 --- a/ruma-client-api/src/r0/account/register.rs +++ b/ruma-client-api/src/r0/account/register.rs @@ -1,7 +1,7 @@ //! [POST /_matrix/client/r0/register](https://matrix.org/docs/spec/client_server/r0.6.0#post-matrix-client-r0-register) use ruma_api::ruma_api; -use ruma_identifiers::{DeviceId, UserId}; +use ruma_identifiers::{DeviceId, DeviceIdBox, UserId}; use serde::{Deserialize, Serialize}; use crate::r0::uiaa::{AuthData, IncomingAuthData, UiaaResponse}; @@ -78,7 +78,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>, + pub device_id: Option, } error: UiaaResponse diff --git a/ruma-client-api/src/r0/device.rs b/ruma-client-api/src/r0/device.rs index a49718be..ce3a7a1d 100644 --- a/ruma-client-api/src/r0/device.rs +++ b/ruma-client-api/src/r0/device.rs @@ -2,7 +2,7 @@ use std::time::SystemTime; -use ruma_identifiers::DeviceId; +use ruma_identifiers::DeviceIdBox; use serde::{Deserialize, Serialize}; pub mod delete_device; @@ -15,7 +15,7 @@ pub mod update_device; #[derive(Clone, Debug, Deserialize, Hash, PartialEq, Serialize)] pub struct Device { /// Device ID - pub device_id: Box, + pub device_id: DeviceIdBox, /// Public display name of the device. pub display_name: Option, diff --git a/ruma-client-api/src/r0/device/delete_devices.rs b/ruma-client-api/src/r0/device/delete_devices.rs index cb743e5a..7cdda999 100644 --- a/ruma-client-api/src/r0/device/delete_devices.rs +++ b/ruma-client-api/src/r0/device/delete_devices.rs @@ -1,7 +1,7 @@ //! [POST /_matrix/client/r0/delete_devices](https://matrix.org/docs/spec/client_server/r0.6.0#post-matrix-client-r0-delete-devices) use ruma_api::ruma_api; -use ruma_identifiers::DeviceId; +use ruma_identifiers::DeviceIdBox; use crate::r0::uiaa::{AuthData, IncomingAuthData, UiaaResponse}; @@ -17,7 +17,7 @@ ruma_api! { request: { /// List of devices to delete. - pub devices: &'a [Box], + pub devices: &'a [DeviceIdBox], /// Additional authentication information for the user-interactive authentication API. #[serde(skip_serializing_if = "Option::is_none")] diff --git a/ruma-client-api/src/r0/device/get_device.rs b/ruma-client-api/src/r0/device/get_device.rs index 8a57b59a..bd210607 100644 --- a/ruma-client-api/src/r0/device/get_device.rs +++ b/ruma-client-api/src/r0/device/get_device.rs @@ -17,7 +17,7 @@ ruma_api! { request: { /// The device to retrieve. #[ruma_api(path)] - pub device_id: Box, + pub device_id: &'a DeviceId, } response: { diff --git a/ruma-client-api/src/r0/device/update_device.rs b/ruma-client-api/src/r0/device/update_device.rs index b4c38c79..a5e7ba56 100644 --- a/ruma-client-api/src/r0/device/update_device.rs +++ b/ruma-client-api/src/r0/device/update_device.rs @@ -16,7 +16,7 @@ ruma_api! { request: { /// The device to update. #[ruma_api(path)] - pub device_id: Box, + pub device_id: &'a DeviceId, /// The new display name for this device. If this is `None`, the display name won't be /// changed. diff --git a/ruma-client-api/src/r0/keys/claim_keys.rs b/ruma-client-api/src/r0/keys/claim_keys.rs index 0b5f2bd9..8b1f4d84 100644 --- a/ruma-client-api/src/r0/keys/claim_keys.rs +++ b/ruma-client-api/src/r0/keys/claim_keys.rs @@ -5,7 +5,7 @@ use std::collections::BTreeMap; use std::time::Duration; use ruma_api::ruma_api; -use ruma_identifiers::{DeviceId, DeviceKeyAlgorithm, DeviceKeyId, UserId}; +use ruma_identifiers::{DeviceIdBox, DeviceKeyAlgorithm, DeviceKeyId, UserId}; use serde_json::Value as JsonValue; use super::OneTimeKey; @@ -31,7 +31,7 @@ ruma_api! { pub timeout: Option, /// The keys to be claimed. - pub one_time_keys: BTreeMap, DeviceKeyAlgorithm>>, + pub one_time_keys: BTreeMap>, } response: { @@ -47,4 +47,4 @@ ruma_api! { } /// The one-time keys for a given device. -pub type OneTimeKeys = BTreeMap, BTreeMap>; +pub type OneTimeKeys = BTreeMap>; diff --git a/ruma-client-api/src/r0/keys/get_keys.rs b/ruma-client-api/src/r0/keys/get_keys.rs index 029fe290..5a942d85 100644 --- a/ruma-client-api/src/r0/keys/get_keys.rs +++ b/ruma-client-api/src/r0/keys/get_keys.rs @@ -4,7 +4,7 @@ use std::{collections::BTreeMap, time::Duration}; use ruma_api::ruma_api; use ruma_common::encryption::DeviceKeys; -use ruma_identifiers::{DeviceId, UserId}; +use ruma_identifiers::{DeviceIdBox, UserId}; use serde_json::Value as JsonValue; #[cfg(feature = "unstable-pre-spec")] @@ -32,7 +32,7 @@ ruma_api! { /// The keys to be downloaded. An empty list indicates all devices for /// the corresponding user. - pub device_keys: BTreeMap>>, + pub device_keys: BTreeMap>, /// 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 @@ -52,7 +52,7 @@ ruma_api! { /// Information on the queried devices. #[serde(default, skip_serializing_if = "BTreeMap::is_empty")] - pub device_keys: BTreeMap, DeviceKeys>>, + pub device_keys: BTreeMap>, /// Information on the master cross-signing keys of the queried users. #[cfg(feature = "unstable-pre-spec")] diff --git a/ruma-client-api/src/r0/session/login.rs b/ruma-client-api/src/r0/session/login.rs index e5a75a25..8162cc6b 100644 --- a/ruma-client-api/src/r0/session/login.rs +++ b/ruma-client-api/src/r0/session/login.rs @@ -2,7 +2,7 @@ use ruma_api::ruma_api; use ruma_common::thirdparty::Medium; -use ruma_identifiers::{DeviceId, ServerName, UserId}; +use ruma_identifiers::{DeviceIdBox, ServerName, UserId}; use serde::{Deserialize, Serialize}; ruma_api! { @@ -26,7 +26,7 @@ ruma_api! { /// ID of the client device #[serde(skip_serializing_if = "Option::is_none")] - pub device_id: Option>, + pub device_id: Option, /// A display name to assign to the newly-created device. Ignored if device_id corresponds /// to a known device. @@ -52,7 +52,7 @@ ruma_api! { /// /// Will be the same as the corresponding parameter in the request, if one was /// specified. - pub device_id: Box, + pub device_id: DeviceIdBox, /// Client configuration provided by the server. /// diff --git a/ruma-client-api/src/r0/to_device.rs b/ruma-client-api/src/r0/to_device.rs index 1e60ea72..b96b8081 100644 --- a/ruma-client-api/src/r0/to_device.rs +++ b/ruma-client-api/src/r0/to_device.rs @@ -5,7 +5,7 @@ use std::{ fmt::{Display, Formatter, Result as FmtResult}, }; -use ruma_identifiers::DeviceId; +use ruma_identifiers::DeviceIdBox; use serde::{ de::{self, Unexpected}, Deserialize, Deserializer, Serialize, Serializer, @@ -17,7 +17,7 @@ pub mod send_event_to_device; #[derive(Clone, Debug, PartialEq, Eq, PartialOrd, Ord)] pub enum DeviceIdOrAllDevices { /// Represents a device Id for one of a user's devices. - DeviceId(Box), + DeviceId(DeviceIdBox), /// Represents all devices for a user. AllDevices, diff --git a/ruma-client/src/lib.rs b/ruma-client/src/lib.rs index 91af4265..25591b8b 100644 --- a/ruma-client/src/lib.rs +++ b/ruma-client/src/lib.rs @@ -117,7 +117,7 @@ use ruma_api::OutgoingRequest; use ruma_client_api::r0::sync::sync_events::{ Filter as SyncFilter, Request as SyncRequest, Response as SyncResponse, }; -use ruma_identifiers::DeviceId; +use ruma_identifiers::DeviceIdBox; use ruma_serde::urlencoded; use std::collections::BTreeMap; @@ -211,7 +211,7 @@ where &self, user: String, password: String, - device_id: Option>, + device_id: Option, initial_device_display_name: Option, ) -> Result> { use ruma_client_api::r0::session::login; diff --git a/ruma-client/src/session.rs b/ruma-client/src/session.rs index 41cbdba8..d77b83f8 100644 --- a/ruma-client/src/session.rs +++ b/ruma-client/src/session.rs @@ -1,6 +1,6 @@ //! User sessions. -use ruma_identifiers::{DeviceId, UserId}; +use ruma_identifiers::{DeviceId, DeviceIdBox, UserId}; /// A user session, containing an access token and information about the associated user account. #[derive(Clone, Debug, serde::Deserialize, Eq, Hash, PartialEq, serde::Serialize)] @@ -18,13 +18,13 @@ pub struct Identification { /// The user the access token was issued for. pub user_id: UserId, /// The ID of the client device - pub device_id: Box, + pub device_id: DeviceIdBox, } impl Session { /// Create a new user session from an access token and a user ID. #[deprecated] - pub fn new(access_token: String, user_id: UserId, device_id: Box) -> Self { + pub fn new(access_token: String, user_id: UserId, device_id: DeviceIdBox) -> Self { Self { access_token, identification: Some(Identification { user_id, device_id }) } } diff --git a/ruma-common/src/encryption.rs b/ruma-common/src/encryption.rs index d72ecbc0..ec3d3118 100644 --- a/ruma-common/src/encryption.rs +++ b/ruma-common/src/encryption.rs @@ -4,7 +4,7 @@ use std::collections::BTreeMap; -use ruma_identifiers::{DeviceId, DeviceKeyId, EventEncryptionAlgorithm, UserId}; +use ruma_identifiers::{DeviceIdBox, DeviceKeyId, EventEncryptionAlgorithm, UserId}; use serde::{Deserialize, Serialize}; /// Identity keys for a device. @@ -14,7 +14,7 @@ pub struct DeviceKeys { pub user_id: UserId, /// The ID of the device these keys belong to. Must match the device ID used when logging in. - pub device_id: Box, + pub device_id: DeviceIdBox, /// The encryption algorithms supported by this device. pub algorithms: Vec, diff --git a/ruma-events/src/key/verification/request.rs b/ruma-events/src/key/verification/request.rs index 262c20e9..b651d90d 100644 --- a/ruma-events/src/key/verification/request.rs +++ b/ruma-events/src/key/verification/request.rs @@ -3,7 +3,7 @@ use std::time::SystemTime; use ruma_events_macros::BasicEventContent; -use ruma_identifiers::DeviceId; +use ruma_identifiers::DeviceIdBox; use serde::{Deserialize, Serialize}; use super::VerificationMethod; @@ -19,7 +19,7 @@ pub type RequestEvent = BasicEvent; #[ruma_event(type = "m.key.verification.request")] pub struct RequestEventContent { /// The device ID which is initiating the request. - pub from_device: Box, + pub from_device: DeviceIdBox, /// An opaque identifier for the verification request. /// diff --git a/ruma-events/src/key/verification/start.rs b/ruma-events/src/key/verification/start.rs index 5521675b..4c1dcc48 100644 --- a/ruma-events/src/key/verification/start.rs +++ b/ruma-events/src/key/verification/start.rs @@ -3,7 +3,7 @@ use std::{collections::BTreeMap, convert::TryFrom}; use ruma_events_macros::BasicEventContent; -use ruma_identifiers::DeviceId; +use ruma_identifiers::DeviceIdBox; use serde::{Deserialize, Serialize}; use serde_json::Value as JsonValue; @@ -22,7 +22,7 @@ pub type StartEvent = BasicEvent; #[ruma_event(type = "m.key.verification.start")] pub struct StartEventContent { /// The device ID which is initiating the process. - pub from_device: Box, + pub from_device: DeviceIdBox, /// An opaque identifier for the verification process. /// diff --git a/ruma-events/src/room/encrypted.rs b/ruma-events/src/room/encrypted.rs index 699d10c4..7479e4bc 100644 --- a/ruma-events/src/room/encrypted.rs +++ b/ruma-events/src/room/encrypted.rs @@ -4,7 +4,7 @@ use std::collections::BTreeMap; use js_int::UInt; use ruma_events_macros::MessageEventContent; -use ruma_identifiers::DeviceId; +use ruma_identifiers::DeviceIdBox; use serde::{Deserialize, Serialize}; use crate::MessageEvent; @@ -80,7 +80,7 @@ pub struct MegolmV1AesSha2Content { pub sender_key: String, /// The ID of the sending device. - pub device_id: Box, + pub device_id: DeviceIdBox, /// The ID of the session used to encrypt the message. pub session_id: String, @@ -99,7 +99,7 @@ pub struct MegolmV1AesSha2ContentInit { pub sender_key: String, /// The ID of the sending device. - pub device_id: Box, + pub device_id: DeviceIdBox, /// The ID of the session used to encrypt the message. pub session_id: String, diff --git a/ruma-events/src/room_key_request.rs b/ruma-events/src/room_key_request.rs index eccafb2c..a6f096cf 100644 --- a/ruma-events/src/room_key_request.rs +++ b/ruma-events/src/room_key_request.rs @@ -1,7 +1,7 @@ //! Types for the *m.room_key_request* event. use ruma_events_macros::BasicEventContent; -use ruma_identifiers::{DeviceId, EventEncryptionAlgorithm, RoomId}; +use ruma_identifiers::{DeviceIdBox, EventEncryptionAlgorithm, RoomId}; use serde::{Deserialize, Serialize}; use strum::{Display, EnumString}; @@ -25,7 +25,7 @@ pub struct RoomKeyRequestEventContent { pub body: Option, /// ID of the device requesting the key. - pub requesting_device_id: Box, + pub requesting_device_id: DeviceIdBox, /// A random string uniquely identifying the request for a key. /// diff --git a/ruma-federation-api/src/device/get_devices/v1.rs b/ruma-federation-api/src/device/get_devices/v1.rs index 5bdb32b9..ab947975 100644 --- a/ruma-federation-api/src/device/get_devices/v1.rs +++ b/ruma-federation-api/src/device/get_devices/v1.rs @@ -3,7 +3,7 @@ use js_int::UInt; use ruma_api::ruma_api; use ruma_common::encryption::DeviceKeys; -use ruma_identifiers::{DeviceId, UserId}; +use ruma_identifiers::{DeviceIdBox, UserId}; use serde::{Deserialize, Serialize}; ruma_api! { @@ -40,7 +40,7 @@ ruma_api! { #[derive(Clone, Debug, Serialize, Deserialize)] pub struct UserDevice { /// The device ID. - pub device_id: Box, + pub device_id: DeviceIdBox, /// Identity keys for the device. pub keys: DeviceKeys, diff --git a/ruma-federation-api/src/keys/claim_keys/v1.rs b/ruma-federation-api/src/keys/claim_keys/v1.rs index 56cf22ef..55c2246f 100644 --- a/ruma-federation-api/src/keys/claim_keys/v1.rs +++ b/ruma-federation-api/src/keys/claim_keys/v1.rs @@ -4,7 +4,7 @@ use std::collections::BTreeMap; use ruma_api::ruma_api; -use ruma_identifiers::{DeviceId, DeviceKeyAlgorithm, DeviceKeyId, UserId}; +use ruma_identifiers::{DeviceIdBox, DeviceKeyAlgorithm, DeviceKeyId, UserId}; use serde::{Deserialize, Serialize}; ruma_api! { @@ -29,10 +29,10 @@ ruma_api! { } /// A claim for one time keys -pub type OneTimeKeyClaims = BTreeMap, DeviceKeyAlgorithm>>; +pub type OneTimeKeyClaims = BTreeMap>; /// One time keys for use in pre-key messages -pub type OneTimeKeys = BTreeMap, BTreeMap>>; +pub type OneTimeKeys = BTreeMap>>; /// A key and its signature #[non_exhaustive] diff --git a/ruma-federation-api/src/keys/get_keys/v1.rs b/ruma-federation-api/src/keys/get_keys/v1.rs index 374b2fa6..81e914ca 100644 --- a/ruma-federation-api/src/keys/get_keys/v1.rs +++ b/ruma-federation-api/src/keys/get_keys/v1.rs @@ -4,7 +4,7 @@ use std::collections::BTreeMap; use ruma_api::ruma_api; use ruma_common::encryption::DeviceKeys; -use ruma_identifiers::{DeviceId, UserId}; +use ruma_identifiers::{DeviceIdBox, UserId}; ruma_api! { metadata: { @@ -19,25 +19,25 @@ ruma_api! { request: { /// The keys to be downloaded. Gives all keys for a given user if the list of device ids is /// empty. - device_keys: BTreeMap>>, + device_keys: BTreeMap>, } response: { /// Keys from the queried devices. - device_keys: BTreeMap, DeviceKeys>>, + device_keys: BTreeMap>, } } impl Request { /// Creates a new `Request` asking for the given device keys. - pub fn new(device_keys: BTreeMap>>) -> Self { + pub fn new(device_keys: BTreeMap>) -> Self { Self { device_keys } } } impl Response { /// Creates a new `Response` with the given device keys. - pub fn new(device_keys: BTreeMap, DeviceKeys>>) -> Self { + pub fn new(device_keys: BTreeMap>) -> Self { Self { device_keys } } }