events: Replace most Box<Id>s with new owned ID types
This commit is contained in:
parent
026ccd7e5b
commit
489f51e231
@ -5,7 +5,7 @@
|
||||
use ruma_macros::EventContent;
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
use crate::{EventEncryptionAlgorithm, RoomId};
|
||||
use crate::{EventEncryptionAlgorithm, OwnedRoomId};
|
||||
|
||||
/// The content of an `m.forwarded_room_key` event.
|
||||
///
|
||||
@ -19,7 +19,7 @@ pub struct ToDeviceForwardedRoomKeyEventContent {
|
||||
pub algorithm: EventEncryptionAlgorithm,
|
||||
|
||||
/// The room where the key is used.
|
||||
pub room_id: Box<RoomId>,
|
||||
pub room_id: OwnedRoomId,
|
||||
|
||||
/// The Curve25519 key of the device which initiated the session originally.
|
||||
pub sender_key: String,
|
||||
@ -57,7 +57,7 @@ pub struct ToDeviceForwardedRoomKeyEventContentInit {
|
||||
pub algorithm: EventEncryptionAlgorithm,
|
||||
|
||||
/// The room where the key is used.
|
||||
pub room_id: Box<RoomId>,
|
||||
pub room_id: OwnedRoomId,
|
||||
|
||||
/// The Curve25519 key of the device which initiated the session originally.
|
||||
pub sender_key: String,
|
||||
|
@ -5,7 +5,7 @@
|
||||
use ruma_macros::EventContent;
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
use crate::EventId;
|
||||
use crate::OwnedEventId;
|
||||
|
||||
/// The content of an `m.fully_read` event.
|
||||
///
|
||||
@ -17,12 +17,12 @@ use crate::EventId;
|
||||
#[ruma_event(type = "m.fully_read", kind = RoomAccountData)]
|
||||
pub struct FullyReadEventContent {
|
||||
/// The event the user's read marker is located at in the room.
|
||||
pub event_id: Box<EventId>,
|
||||
pub event_id: OwnedEventId,
|
||||
}
|
||||
|
||||
impl FullyReadEventContent {
|
||||
/// Creates a new `FullyReadEventContent` with the given event ID.
|
||||
pub fn new(event_id: Box<EventId>) -> Self {
|
||||
pub fn new(event_id: OwnedEventId) -> Self {
|
||||
Self { event_id }
|
||||
}
|
||||
}
|
||||
|
@ -12,7 +12,7 @@ use super::{
|
||||
HashAlgorithm, KeyAgreementProtocol, MessageAuthenticationCode, Relation,
|
||||
ShortAuthenticationString,
|
||||
};
|
||||
use crate::{serde::Base64, TransactionId};
|
||||
use crate::{serde::Base64, OwnedTransactionId};
|
||||
|
||||
/// The content of a to-device `m.key.verification.accept` event.
|
||||
///
|
||||
@ -24,7 +24,7 @@ pub struct ToDeviceKeyVerificationAcceptEventContent {
|
||||
/// An opaque identifier for the verification process.
|
||||
///
|
||||
/// Must be the same as the one used for the `m.key.verification.start` message.
|
||||
pub transaction_id: Box<TransactionId>,
|
||||
pub transaction_id: OwnedTransactionId,
|
||||
|
||||
/// The method specific content.
|
||||
#[serde(flatten)]
|
||||
@ -34,7 +34,7 @@ pub struct ToDeviceKeyVerificationAcceptEventContent {
|
||||
impl ToDeviceKeyVerificationAcceptEventContent {
|
||||
/// Creates a new `ToDeviceKeyVerificationAcceptEventContent` with the given transaction ID and
|
||||
/// method-specific content.
|
||||
pub fn new(transaction_id: Box<TransactionId>, method: AcceptMethod) -> Self {
|
||||
pub fn new(transaction_id: OwnedTransactionId, method: AcceptMethod) -> Self {
|
||||
Self { transaction_id, method }
|
||||
}
|
||||
}
|
||||
|
@ -6,7 +6,7 @@ use ruma_macros::EventContent;
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
use super::Relation;
|
||||
use crate::{serde::StringEnum, PrivOwnedStr, TransactionId};
|
||||
use crate::{serde::StringEnum, OwnedTransactionId, PrivOwnedStr};
|
||||
|
||||
/// The content of a to-device `m.key.verification.cancel` event.
|
||||
///
|
||||
@ -16,7 +16,7 @@ use crate::{serde::StringEnum, PrivOwnedStr, TransactionId};
|
||||
#[ruma_event(type = "m.key.verification.cancel", kind = ToDevice)]
|
||||
pub struct ToDeviceKeyVerificationCancelEventContent {
|
||||
/// The opaque identifier for the verification process/request.
|
||||
pub transaction_id: Box<TransactionId>,
|
||||
pub transaction_id: OwnedTransactionId,
|
||||
|
||||
/// A human readable description of the `code`.
|
||||
///
|
||||
@ -30,7 +30,7 @@ pub struct ToDeviceKeyVerificationCancelEventContent {
|
||||
impl ToDeviceKeyVerificationCancelEventContent {
|
||||
/// Creates a new `ToDeviceKeyVerificationCancelEventContent` with the given transaction ID,
|
||||
/// reason and code.
|
||||
pub fn new(transaction_id: Box<TransactionId>, reason: String, code: CancelCode) -> Self {
|
||||
pub fn new(transaction_id: OwnedTransactionId, reason: String, code: CancelCode) -> Self {
|
||||
Self { transaction_id, reason, code }
|
||||
}
|
||||
}
|
||||
|
@ -6,7 +6,7 @@ use ruma_macros::EventContent;
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
use super::Relation;
|
||||
use crate::TransactionId;
|
||||
use crate::OwnedTransactionId;
|
||||
|
||||
/// The content of a to-device `m.m.key.verification.done` event.
|
||||
///
|
||||
@ -18,12 +18,12 @@ pub struct ToDeviceKeyVerificationDoneEventContent {
|
||||
/// An opaque identifier for the verification process.
|
||||
///
|
||||
/// Must be the same as the one used for the `m.key.verification.start` message.
|
||||
pub transaction_id: Box<TransactionId>,
|
||||
pub transaction_id: OwnedTransactionId,
|
||||
}
|
||||
|
||||
impl ToDeviceKeyVerificationDoneEventContent {
|
||||
/// Creates a new `ToDeviceKeyVerificationDoneEventContent` with the given transaction ID.
|
||||
pub fn new(transaction_id: Box<TransactionId>) -> Self {
|
||||
pub fn new(transaction_id: OwnedTransactionId) -> Self {
|
||||
Self { transaction_id }
|
||||
}
|
||||
}
|
||||
|
@ -6,7 +6,7 @@ use ruma_macros::EventContent;
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
use super::Relation;
|
||||
use crate::{serde::Base64, TransactionId};
|
||||
use crate::{serde::Base64, OwnedTransactionId};
|
||||
|
||||
/// The content of a to-device `m.key.verification.key` event.
|
||||
///
|
||||
@ -18,7 +18,7 @@ pub struct ToDeviceKeyVerificationKeyEventContent {
|
||||
/// An opaque identifier for the verification process.
|
||||
///
|
||||
/// Must be the same as the one used for the `m.key.verification.start` message.
|
||||
pub transaction_id: Box<TransactionId>,
|
||||
pub transaction_id: OwnedTransactionId,
|
||||
|
||||
/// The device's ephemeral public key, encoded as unpadded base64.
|
||||
pub key: Base64,
|
||||
@ -27,7 +27,7 @@ pub struct ToDeviceKeyVerificationKeyEventContent {
|
||||
impl ToDeviceKeyVerificationKeyEventContent {
|
||||
/// Creates a new `ToDeviceKeyVerificationKeyEventContent` with the given transaction ID and
|
||||
/// key.
|
||||
pub fn new(transaction_id: Box<TransactionId>, key: Base64) -> Self {
|
||||
pub fn new(transaction_id: OwnedTransactionId, key: Base64) -> Self {
|
||||
Self { transaction_id, key }
|
||||
}
|
||||
}
|
||||
|
@ -8,7 +8,7 @@ use ruma_macros::EventContent;
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
use super::Relation;
|
||||
use crate::{serde::Base64, TransactionId};
|
||||
use crate::{serde::Base64, OwnedTransactionId};
|
||||
|
||||
/// The content of a to-device `m.key.verification.` event.
|
||||
///
|
||||
@ -20,7 +20,7 @@ pub struct ToDeviceKeyVerificationMacEventContent {
|
||||
/// An opaque identifier for the verification process.
|
||||
///
|
||||
/// Must be the same as the one used for the `m.key.verification.start` message.
|
||||
pub transaction_id: Box<TransactionId>,
|
||||
pub transaction_id: OwnedTransactionId,
|
||||
|
||||
/// A map of the key ID to the MAC of the key, using the algorithm in the verification process.
|
||||
///
|
||||
@ -36,7 +36,7 @@ impl ToDeviceKeyVerificationMacEventContent {
|
||||
/// Creates a new `ToDeviceKeyVerificationMacEventContent` with the given transaction ID, key ID
|
||||
/// to MAC map and key MAC.
|
||||
pub fn new(
|
||||
transaction_id: Box<TransactionId>,
|
||||
transaction_id: OwnedTransactionId,
|
||||
mac: BTreeMap<String, Base64>,
|
||||
keys: Base64,
|
||||
) -> Self {
|
||||
|
@ -6,7 +6,7 @@ use ruma_macros::EventContent;
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
use super::{Relation, VerificationMethod};
|
||||
use crate::{DeviceId, TransactionId};
|
||||
use crate::{OwnedDeviceId, OwnedTransactionId};
|
||||
|
||||
/// The content of a to-device `m.m.key.verification.ready` event.
|
||||
///
|
||||
@ -16,7 +16,7 @@ use crate::{DeviceId, TransactionId};
|
||||
#[ruma_event(type = "m.key.verification.ready", kind = ToDevice)]
|
||||
pub struct ToDeviceKeyVerificationReadyEventContent {
|
||||
/// The device ID which is initiating the request.
|
||||
pub from_device: Box<DeviceId>,
|
||||
pub from_device: OwnedDeviceId,
|
||||
|
||||
/// The verification methods supported by the sender.
|
||||
pub methods: Vec<VerificationMethod>,
|
||||
@ -26,16 +26,16 @@ pub struct ToDeviceKeyVerificationReadyEventContent {
|
||||
/// Must be unique with respect to the devices involved. Must be the same as the
|
||||
/// `transaction_id` given in the `m.key.verification.request` from a
|
||||
/// request.
|
||||
pub transaction_id: Box<TransactionId>,
|
||||
pub transaction_id: OwnedTransactionId,
|
||||
}
|
||||
|
||||
impl ToDeviceKeyVerificationReadyEventContent {
|
||||
/// Creates a new `ToDeviceKeyVerificationReadyEventContent` with the given device ID,
|
||||
/// verification methods and transaction ID.
|
||||
pub fn new(
|
||||
from_device: Box<DeviceId>,
|
||||
from_device: OwnedDeviceId,
|
||||
methods: Vec<VerificationMethod>,
|
||||
transaction_id: Box<TransactionId>,
|
||||
transaction_id: OwnedTransactionId,
|
||||
) -> Self {
|
||||
Self { from_device, methods, transaction_id }
|
||||
}
|
||||
@ -49,7 +49,7 @@ impl ToDeviceKeyVerificationReadyEventContent {
|
||||
#[ruma_event(type = "m.key.verification.ready", kind = MessageLike)]
|
||||
pub struct KeyVerificationReadyEventContent {
|
||||
/// The device ID which is initiating the request.
|
||||
pub from_device: Box<DeviceId>,
|
||||
pub from_device: OwnedDeviceId,
|
||||
|
||||
/// The verification methods supported by the sender.
|
||||
pub methods: Vec<VerificationMethod>,
|
||||
@ -64,7 +64,7 @@ impl KeyVerificationReadyEventContent {
|
||||
/// Creates a new `KeyVerificationReadyEventContent` with the given device ID, methods and
|
||||
/// relation.
|
||||
pub fn new(
|
||||
from_device: Box<DeviceId>,
|
||||
from_device: OwnedDeviceId,
|
||||
methods: Vec<VerificationMethod>,
|
||||
relates_to: Relation,
|
||||
) -> Self {
|
||||
@ -74,7 +74,7 @@ impl KeyVerificationReadyEventContent {
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use crate::{event_id, DeviceId};
|
||||
use crate::{event_id, OwnedDeviceId};
|
||||
use matches::assert_matches;
|
||||
use serde_json::{from_value as from_json_value, json, to_value as to_json_value};
|
||||
|
||||
@ -84,7 +84,7 @@ mod tests {
|
||||
#[test]
|
||||
fn serialization() {
|
||||
let event_id = event_id!("$1598361704261elfgc:localhost").to_owned();
|
||||
let device: Box<DeviceId> = "123".into();
|
||||
let device: OwnedDeviceId = "123".into();
|
||||
|
||||
let json_data = json!({
|
||||
"from_device": device,
|
||||
@ -121,7 +121,7 @@ mod tests {
|
||||
#[test]
|
||||
fn deserialization() {
|
||||
let id = event_id!("$1598361704261elfgc:localhost");
|
||||
let device: Box<DeviceId> = "123".into();
|
||||
let device: OwnedDeviceId = "123".into();
|
||||
|
||||
let json_data = json!({
|
||||
"from_device": device,
|
||||
|
@ -6,7 +6,7 @@ use ruma_macros::EventContent;
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
use super::VerificationMethod;
|
||||
use crate::{DeviceId, MilliSecondsSinceUnixEpoch, TransactionId};
|
||||
use crate::{MilliSecondsSinceUnixEpoch, OwnedDeviceId, OwnedTransactionId};
|
||||
|
||||
/// The content of an `m.key.verification.request` event.
|
||||
#[derive(Clone, Debug, Deserialize, Serialize, EventContent)]
|
||||
@ -14,12 +14,12 @@ use crate::{DeviceId, MilliSecondsSinceUnixEpoch, TransactionId};
|
||||
#[ruma_event(type = "m.key.verification.request", kind = ToDevice)]
|
||||
pub struct ToDeviceKeyVerificationRequestEventContent {
|
||||
/// The device ID which is initiating the request.
|
||||
pub from_device: Box<DeviceId>,
|
||||
pub from_device: OwnedDeviceId,
|
||||
|
||||
/// An opaque identifier for the verification request.
|
||||
///
|
||||
/// Must be unique with respect to the devices involved.
|
||||
pub transaction_id: Box<TransactionId>,
|
||||
pub transaction_id: OwnedTransactionId,
|
||||
|
||||
/// The verification methods supported by the sender.
|
||||
pub methods: Vec<VerificationMethod>,
|
||||
@ -35,8 +35,8 @@ impl ToDeviceKeyVerificationRequestEventContent {
|
||||
/// Creates a new `ToDeviceKeyVerificationRequestEventContent` with the given device ID,
|
||||
/// transaction ID, methods and timestamp.
|
||||
pub fn new(
|
||||
from_device: Box<DeviceId>,
|
||||
transaction_id: Box<TransactionId>,
|
||||
from_device: OwnedDeviceId,
|
||||
transaction_id: OwnedTransactionId,
|
||||
methods: Vec<VerificationMethod>,
|
||||
timestamp: MilliSecondsSinceUnixEpoch,
|
||||
) -> Self {
|
||||
|
@ -12,7 +12,7 @@ use super::{
|
||||
HashAlgorithm, KeyAgreementProtocol, MessageAuthenticationCode, Relation,
|
||||
ShortAuthenticationString,
|
||||
};
|
||||
use crate::{serde::Base64, DeviceId, TransactionId};
|
||||
use crate::{serde::Base64, OwnedDeviceId, OwnedTransactionId};
|
||||
|
||||
/// The content of a to-device `m.key.verification.start` event.
|
||||
///
|
||||
@ -22,14 +22,14 @@ use crate::{serde::Base64, DeviceId, TransactionId};
|
||||
#[ruma_event(type = "m.key.verification.start", kind = ToDevice)]
|
||||
pub struct ToDeviceKeyVerificationStartEventContent {
|
||||
/// The device ID which is initiating the process.
|
||||
pub from_device: Box<DeviceId>,
|
||||
pub from_device: OwnedDeviceId,
|
||||
|
||||
/// An opaque identifier for the verification process.
|
||||
///
|
||||
/// Must be unique with respect to the devices involved. Must be the same as the
|
||||
/// `transaction_id` given in the `m.key.verification.request` if this process is originating
|
||||
/// from a request.
|
||||
pub transaction_id: Box<TransactionId>,
|
||||
pub transaction_id: OwnedTransactionId,
|
||||
|
||||
/// Method specific content.
|
||||
#[serde(flatten)]
|
||||
@ -40,8 +40,8 @@ impl ToDeviceKeyVerificationStartEventContent {
|
||||
/// Creates a new `ToDeviceKeyVerificationStartEventContent` with the given device ID,
|
||||
/// transaction ID and method specific content.
|
||||
pub fn new(
|
||||
from_device: Box<DeviceId>,
|
||||
transaction_id: Box<TransactionId>,
|
||||
from_device: OwnedDeviceId,
|
||||
transaction_id: OwnedTransactionId,
|
||||
method: StartMethod,
|
||||
) -> Self {
|
||||
Self { from_device, transaction_id, method }
|
||||
@ -56,7 +56,7 @@ impl ToDeviceKeyVerificationStartEventContent {
|
||||
#[ruma_event(type = "m.key.verification.start", kind = MessageLike)]
|
||||
pub struct KeyVerificationStartEventContent {
|
||||
/// The device ID which is initiating the process.
|
||||
pub from_device: Box<DeviceId>,
|
||||
pub from_device: OwnedDeviceId,
|
||||
|
||||
/// Method specific content.
|
||||
#[serde(flatten)]
|
||||
@ -70,7 +70,7 @@ pub struct KeyVerificationStartEventContent {
|
||||
impl KeyVerificationStartEventContent {
|
||||
/// Creates a new `KeyVerificationStartEventContent` with the given device ID, method and
|
||||
/// relation.
|
||||
pub fn new(from_device: Box<DeviceId>, method: StartMethod, relates_to: Relation) -> Self {
|
||||
pub fn new(from_device: OwnedDeviceId, method: StartMethod, relates_to: Relation) -> Self {
|
||||
Self { from_device, method, relates_to }
|
||||
}
|
||||
}
|
||||
|
@ -3,7 +3,7 @@
|
||||
use ruma_macros::EventContent;
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
use crate::EventId;
|
||||
use crate::OwnedEventId;
|
||||
|
||||
/// The payload for a `m.reaction` event.
|
||||
///
|
||||
@ -38,7 +38,7 @@ impl From<Relation> for ReactionEventContent {
|
||||
#[serde(tag = "rel_type", rename = "m.annotation")]
|
||||
pub struct Relation {
|
||||
/// The event that is being annotated.
|
||||
pub event_id: Box<EventId>,
|
||||
pub event_id: OwnedEventId,
|
||||
|
||||
/// A string that indicates the annotation being applied.
|
||||
///
|
||||
@ -51,7 +51,7 @@ pub struct Relation {
|
||||
|
||||
impl Relation {
|
||||
/// Creates a new `Relation` with the given event ID and key.
|
||||
pub fn new(event_id: Box<EventId>, key: String) -> Self {
|
||||
pub fn new(event_id: OwnedEventId, key: String) -> Self {
|
||||
Self { event_id, key }
|
||||
}
|
||||
}
|
||||
|
@ -6,7 +6,7 @@ use js_int::UInt;
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
use super::AnySyncMessageLikeEvent;
|
||||
use crate::{serde::Raw, EventId, MilliSecondsSinceUnixEpoch, UserId};
|
||||
use crate::{serde::Raw, MilliSecondsSinceUnixEpoch, OwnedEventId, OwnedUserId};
|
||||
|
||||
/// Summary of all reactions with the given key to an event.
|
||||
#[derive(Clone, Debug, Default, Deserialize, PartialEq, Eq, Serialize)]
|
||||
@ -74,10 +74,10 @@ impl AnnotationChunk {
|
||||
#[cfg_attr(not(feature = "unstable-exhaustive-types"), non_exhaustive)]
|
||||
pub struct BundledReplacement {
|
||||
/// The ID of the replacing event.
|
||||
pub event_id: Box<EventId>,
|
||||
pub event_id: OwnedEventId,
|
||||
|
||||
/// The user ID of the sender of the latest replacement.
|
||||
pub sender: Box<UserId>,
|
||||
pub sender: OwnedUserId,
|
||||
|
||||
/// Timestamp in milliseconds on originating homeserver when the latest replacement was sent.
|
||||
#[serde(skip_serializing_if = "Option::is_none")]
|
||||
@ -87,7 +87,7 @@ pub struct BundledReplacement {
|
||||
#[cfg(feature = "unstable-msc2676")]
|
||||
impl BundledReplacement {
|
||||
/// Creates a new `BundledReplacement` with the given event ID and sender.
|
||||
pub fn new(event_id: Box<EventId>, sender: Box<UserId>) -> Self {
|
||||
pub fn new(event_id: OwnedEventId, sender: OwnedUserId) -> Self {
|
||||
Self { event_id, sender, origin_server_ts: None }
|
||||
}
|
||||
}
|
||||
|
@ -5,7 +5,7 @@
|
||||
use ruma_macros::EventContent;
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
use crate::{OwnedRoomAliasId, RoomAliasId};
|
||||
use crate::OwnedRoomAliasId;
|
||||
|
||||
/// The content of an `m.room.canonical_alias` event.
|
||||
///
|
||||
@ -27,7 +27,7 @@ pub struct RoomCanonicalAliasEventContent {
|
||||
|
||||
/// List of alternative aliases to the room.
|
||||
#[serde(default, skip_serializing_if = "Vec::is_empty")]
|
||||
pub alt_aliases: Vec<Box<RoomAliasId>>,
|
||||
pub alt_aliases: Vec<OwnedRoomAliasId>,
|
||||
}
|
||||
|
||||
impl RoomCanonicalAliasEventContent {
|
||||
|
@ -5,7 +5,7 @@
|
||||
use ruma_macros::EventContent;
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
use crate::{room::RoomType, EventId, OwnedUserId, RoomId, RoomVersionId};
|
||||
use crate::{room::RoomType, OwnedEventId, OwnedRoomId, OwnedUserId, RoomVersionId};
|
||||
|
||||
/// The content of an `m.room.create` event.
|
||||
///
|
||||
@ -65,15 +65,15 @@ impl RoomCreateEventContent {
|
||||
#[cfg_attr(not(feature = "unstable-exhaustive-types"), non_exhaustive)]
|
||||
pub struct PreviousRoom {
|
||||
/// The ID of the old room.
|
||||
pub room_id: Box<RoomId>,
|
||||
pub room_id: OwnedRoomId,
|
||||
|
||||
/// The event ID of the last known event in the old room.
|
||||
pub event_id: Box<EventId>,
|
||||
pub event_id: OwnedEventId,
|
||||
}
|
||||
|
||||
impl PreviousRoom {
|
||||
/// Creates a new `PreviousRoom` from the given room and event IDs.
|
||||
pub fn new(room_id: Box<RoomId>, event_id: Box<EventId>) -> Self {
|
||||
pub fn new(room_id: OwnedRoomId, event_id: OwnedEventId) -> Self {
|
||||
Self { room_id, event_id }
|
||||
}
|
||||
}
|
||||
|
@ -9,9 +9,7 @@ use ruma_macros::EventContent;
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
use super::message::{self, InReplyTo};
|
||||
#[cfg(feature = "unstable-msc2677")]
|
||||
use crate::EventId;
|
||||
use crate::{DeviceId, OwnedEventId};
|
||||
use crate::{OwnedDeviceId, OwnedEventId};
|
||||
|
||||
mod relation_serde;
|
||||
|
||||
@ -164,7 +162,7 @@ impl Reference {
|
||||
#[cfg_attr(not(feature = "unstable-exhaustive-types"), non_exhaustive)]
|
||||
pub struct Annotation {
|
||||
/// The event that is being annotated.
|
||||
pub event_id: Box<EventId>,
|
||||
pub event_id: OwnedEventId,
|
||||
|
||||
/// The annotation.
|
||||
pub key: String,
|
||||
@ -173,7 +171,7 @@ pub struct Annotation {
|
||||
#[cfg(feature = "unstable-msc2677")]
|
||||
impl Annotation {
|
||||
/// Creates a new `Annotation` with the given event ID and key.
|
||||
pub fn new(event_id: Box<EventId>, key: String) -> Self {
|
||||
pub fn new(event_id: OwnedEventId, key: String) -> Self {
|
||||
Self { event_id, key }
|
||||
}
|
||||
}
|
||||
@ -269,7 +267,7 @@ pub struct MegolmV1AesSha2Content {
|
||||
pub sender_key: String,
|
||||
|
||||
/// The ID of the sending device.
|
||||
pub device_id: Box<DeviceId>,
|
||||
pub device_id: OwnedDeviceId,
|
||||
|
||||
/// The ID of the session used to encrypt the message.
|
||||
pub session_id: String,
|
||||
@ -289,7 +287,7 @@ pub struct MegolmV1AesSha2ContentInit {
|
||||
pub sender_key: String,
|
||||
|
||||
/// The ID of the sending device.
|
||||
pub device_id: Box<DeviceId>,
|
||||
pub device_id: OwnedDeviceId,
|
||||
|
||||
/// The ID of the session used to encrypt the message.
|
||||
pub session_id: String,
|
||||
|
@ -248,7 +248,7 @@ pub struct SignedContent {
|
||||
/// The invited Matrix user ID.
|
||||
///
|
||||
/// Must be equal to the user_id property of the event.
|
||||
pub mxid: Box<UserId>,
|
||||
pub mxid: OwnedUserId,
|
||||
|
||||
/// A single signature from the verifying server, in the format specified by the Signing Events
|
||||
/// section of the server-server API.
|
||||
@ -261,8 +261,8 @@ pub struct SignedContent {
|
||||
impl SignedContent {
|
||||
/// Creates a new `SignedContent` with the given mxid, signature and token.
|
||||
pub fn new(
|
||||
mxid: Box<UserId>,
|
||||
signatures: BTreeMap<OwnedServerName, BTreeMap<OwnedServerSigningKeyId, String>>,
|
||||
mxid: OwnedUserId,
|
||||
token: String,
|
||||
) -> Self {
|
||||
Self { mxid, signatures, token }
|
||||
|
@ -29,7 +29,7 @@ use crate::events::{
|
||||
use crate::{
|
||||
events::key::verification::VerificationMethod,
|
||||
serde::{JsonObject, StringEnum},
|
||||
DeviceId, OwnedEventId, OwnedMxcUri, OwnedUserId, PrivOwnedStr,
|
||||
OwnedDeviceId, OwnedEventId, OwnedMxcUri, OwnedUserId, PrivOwnedStr,
|
||||
};
|
||||
#[cfg(feature = "unstable-msc3488")]
|
||||
use crate::{
|
||||
@ -1906,7 +1906,7 @@ pub struct KeyVerificationRequestEventContent {
|
||||
pub methods: Vec<VerificationMethod>,
|
||||
|
||||
/// The device ID which is initiating the request.
|
||||
pub from_device: Box<DeviceId>,
|
||||
pub from_device: OwnedDeviceId,
|
||||
|
||||
/// The user ID which should receive the request.
|
||||
///
|
||||
@ -1922,7 +1922,7 @@ impl KeyVerificationRequestEventContent {
|
||||
pub fn new(
|
||||
body: String,
|
||||
methods: Vec<VerificationMethod>,
|
||||
from_device: Box<DeviceId>,
|
||||
from_device: OwnedDeviceId,
|
||||
to: OwnedUserId,
|
||||
) -> Self {
|
||||
Self { body, methods, from_device, to }
|
||||
|
@ -5,7 +5,7 @@
|
||||
use ruma_macros::EventContent;
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
use crate::{serde::StringEnum, EventId, PrivOwnedStr};
|
||||
use crate::{serde::StringEnum, OwnedEventId, PrivOwnedStr};
|
||||
|
||||
/// The content of an `m.room.message.feedback` event.
|
||||
///
|
||||
@ -18,7 +18,7 @@ use crate::{serde::StringEnum, EventId, PrivOwnedStr};
|
||||
#[ruma_event(type = "m.room.message.feedback", kind = MessageLike)]
|
||||
pub struct RoomMessageFeedbackEventContent {
|
||||
/// The event that this feedback is related to.
|
||||
pub target_event_id: Box<EventId>,
|
||||
pub target_event_id: OwnedEventId,
|
||||
|
||||
/// The type of feedback.
|
||||
#[serde(rename = "type")]
|
||||
@ -27,7 +27,7 @@ pub struct RoomMessageFeedbackEventContent {
|
||||
|
||||
impl RoomMessageFeedbackEventContent {
|
||||
/// Create a `RoomMessageFeedbackEventContent` from the given target event id and feedback type.
|
||||
pub fn new(target_event_id: Box<EventId>, feedback_type: FeedbackType) -> Self {
|
||||
pub fn new(target_event_id: OwnedEventId, feedback_type: FeedbackType) -> Self {
|
||||
Self { target_event_id, feedback_type }
|
||||
}
|
||||
}
|
||||
|
@ -5,7 +5,7 @@
|
||||
use ruma_macros::EventContent;
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
use crate::RoomId;
|
||||
use crate::OwnedRoomId;
|
||||
|
||||
/// The content of an `m.room.tombstone` event.
|
||||
///
|
||||
@ -23,12 +23,12 @@ pub struct RoomTombstoneEventContent {
|
||||
pub body: String,
|
||||
|
||||
/// The new room the client should be visiting.
|
||||
pub replacement_room: Box<RoomId>,
|
||||
pub replacement_room: OwnedRoomId,
|
||||
}
|
||||
|
||||
impl RoomTombstoneEventContent {
|
||||
/// Creates a new `RoomTombstoneEventContent` with the given body and replacement room ID.
|
||||
pub fn new(body: String, replacement_room: Box<RoomId>) -> Self {
|
||||
pub fn new(body: String, replacement_room: OwnedRoomId) -> Self {
|
||||
Self { body, replacement_room }
|
||||
}
|
||||
}
|
||||
|
@ -6,7 +6,8 @@ use ruma_macros::EventContent;
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
use crate::{
|
||||
serde::StringEnum, DeviceId, EventEncryptionAlgorithm, PrivOwnedStr, RoomId, TransactionId,
|
||||
serde::StringEnum, EventEncryptionAlgorithm, OwnedDeviceId, OwnedRoomId, OwnedTransactionId,
|
||||
PrivOwnedStr,
|
||||
};
|
||||
|
||||
/// The content of an `m.room_key_request` event.
|
||||
@ -23,13 +24,13 @@ pub struct ToDeviceRoomKeyRequestEventContent {
|
||||
pub body: Option<RequestedKeyInfo>,
|
||||
|
||||
/// ID of the device requesting the key.
|
||||
pub requesting_device_id: Box<DeviceId>,
|
||||
pub requesting_device_id: OwnedDeviceId,
|
||||
|
||||
/// A random string uniquely identifying the request for a key.
|
||||
///
|
||||
/// If the key is requested multiple times, it should be reused. It should also reused
|
||||
/// in order to cancel a request.
|
||||
pub request_id: Box<TransactionId>,
|
||||
pub request_id: OwnedTransactionId,
|
||||
}
|
||||
|
||||
impl ToDeviceRoomKeyRequestEventContent {
|
||||
@ -38,8 +39,8 @@ impl ToDeviceRoomKeyRequestEventContent {
|
||||
pub fn new(
|
||||
action: Action,
|
||||
body: Option<RequestedKeyInfo>,
|
||||
requesting_device_id: Box<DeviceId>,
|
||||
request_id: Box<TransactionId>,
|
||||
requesting_device_id: OwnedDeviceId,
|
||||
request_id: OwnedTransactionId,
|
||||
) -> Self {
|
||||
Self { action, body, requesting_device_id, request_id }
|
||||
}
|
||||
@ -77,7 +78,7 @@ pub struct RequestedKeyInfo {
|
||||
pub algorithm: EventEncryptionAlgorithm,
|
||||
|
||||
/// The room where the key is used.
|
||||
pub room_id: Box<RoomId>,
|
||||
pub room_id: OwnedRoomId,
|
||||
|
||||
/// The Curve25519 key of the device which initiated the session originally.
|
||||
pub sender_key: String,
|
||||
@ -91,7 +92,7 @@ impl RequestedKeyInfo {
|
||||
/// ID.
|
||||
pub fn new(
|
||||
algorithm: EventEncryptionAlgorithm,
|
||||
room_id: Box<RoomId>,
|
||||
room_id: OwnedRoomId,
|
||||
sender_key: String,
|
||||
session_id: String,
|
||||
) -> Self {
|
||||
|
@ -7,7 +7,7 @@ use std::convert::TryFrom;
|
||||
use ruma_macros::EventContent;
|
||||
use serde::{ser::SerializeStruct, Deserialize, Serialize};
|
||||
|
||||
use crate::{serde::StringEnum, DeviceId, PrivOwnedStr, TransactionId};
|
||||
use crate::{serde::StringEnum, OwnedDeviceId, OwnedTransactionId, PrivOwnedStr};
|
||||
|
||||
/// The content of an `m.secret.request` event.
|
||||
///
|
||||
@ -23,14 +23,14 @@ pub struct ToDeviceSecretRequestEventContent {
|
||||
pub action: RequestAction,
|
||||
|
||||
/// The ID of the device requesting the event.
|
||||
pub requesting_device_id: Box<DeviceId>,
|
||||
pub requesting_device_id: OwnedDeviceId,
|
||||
|
||||
/// A random string uniquely identifying (with respect to the requester and the target) the
|
||||
/// target for a secret.
|
||||
///
|
||||
/// If the secret is requested from multiple devices at the same time, the same ID may be used
|
||||
/// for every target. The same ID is also used in order to cancel a previous request.
|
||||
pub request_id: Box<TransactionId>,
|
||||
pub request_id: OwnedTransactionId,
|
||||
}
|
||||
|
||||
impl ToDeviceSecretRequestEventContent {
|
||||
@ -38,8 +38,8 @@ impl ToDeviceSecretRequestEventContent {
|
||||
/// request ID.
|
||||
pub fn new(
|
||||
action: RequestAction,
|
||||
requesting_device_id: Box<DeviceId>,
|
||||
request_id: Box<TransactionId>,
|
||||
requesting_device_id: OwnedDeviceId,
|
||||
request_id: OwnedTransactionId,
|
||||
) -> Self {
|
||||
Self { action, requesting_device_id, request_id }
|
||||
}
|
||||
|
@ -5,7 +5,7 @@
|
||||
use ruma_macros::EventContent;
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
use crate::TransactionId;
|
||||
use crate::OwnedTransactionId;
|
||||
|
||||
/// The content of an `m.secret.send` event.
|
||||
///
|
||||
@ -18,7 +18,7 @@ use crate::TransactionId;
|
||||
#[ruma_event(type = "m.secret.send", kind = ToDevice)]
|
||||
pub struct ToDeviceSecretSendEventContent {
|
||||
/// The ID of the request that this is a response to.
|
||||
pub request_id: Box<TransactionId>,
|
||||
pub request_id: OwnedTransactionId,
|
||||
|
||||
/// The contents of the secret.
|
||||
pub secret: String,
|
||||
@ -26,7 +26,7 @@ pub struct ToDeviceSecretSendEventContent {
|
||||
|
||||
impl ToDeviceSecretSendEventContent {
|
||||
/// Creates a new `SecretSendEventContent` with the given request ID and secret.
|
||||
pub fn new(request_id: Box<TransactionId>, secret: String) -> Self {
|
||||
pub fn new(request_id: OwnedTransactionId, secret: String) -> Self {
|
||||
Self { request_id, secret }
|
||||
}
|
||||
}
|
||||
|
@ -5,7 +5,7 @@ use serde_json::{from_str as from_json_str, value::RawValue as RawJsonValue};
|
||||
#[cfg(feature = "unstable-msc2675")]
|
||||
use super::relation::Relations;
|
||||
use super::{room::redaction::SyncRoomRedactionEvent, StateEventContent};
|
||||
use crate::{serde::Raw, TransactionId};
|
||||
use crate::{serde::Raw, OwnedTransactionId};
|
||||
|
||||
/// Extra information about a message event that is not incorporated into the event's hash.
|
||||
#[derive(Clone, Debug, Default, Deserialize, Serialize)]
|
||||
@ -22,7 +22,7 @@ pub struct MessageLikeUnsigned {
|
||||
/// The client-supplied transaction ID, if the client being given the event is the same one
|
||||
/// which sent it.
|
||||
#[serde(skip_serializing_if = "Option::is_none")]
|
||||
pub transaction_id: Option<Box<TransactionId>>,
|
||||
pub transaction_id: Option<OwnedTransactionId>,
|
||||
|
||||
/// Server-compiled information from other events relating to this event.
|
||||
#[cfg(feature = "unstable-msc2675")]
|
||||
@ -69,7 +69,7 @@ pub struct StateUnsigned<C: StateEventContent> {
|
||||
/// The client-supplied transaction ID, if the client being given the event is the same one
|
||||
/// which sent it.
|
||||
#[serde(skip_serializing_if = "Option::is_none")]
|
||||
pub transaction_id: Option<Box<TransactionId>>,
|
||||
pub transaction_id: Option<OwnedTransactionId>,
|
||||
|
||||
/// Optional previous content of the event.
|
||||
#[serde(skip_serializing_if = "Option::is_none")]
|
||||
@ -126,7 +126,7 @@ impl<C: StateEventContent> StateUnsigned<C> {
|
||||
#[serde(skip_serializing_if = "Option::is_none")]
|
||||
age: Option<Int>,
|
||||
#[serde(skip_serializing_if = "Option::is_none")]
|
||||
transaction_id: Option<Box<TransactionId>>,
|
||||
transaction_id: Option<OwnedTransactionId>,
|
||||
prev_content: Option<Raw<C>>,
|
||||
#[cfg(feature = "unstable-msc2675")]
|
||||
#[serde(rename = "m.relations", skip_serializing_if = "Option::is_none")]
|
||||
|
@ -21,7 +21,7 @@ use ruma_common::{
|
||||
},
|
||||
MessageLikeUnsigned,
|
||||
},
|
||||
mxc_uri, room_id, user_id, DeviceId, MilliSecondsSinceUnixEpoch,
|
||||
mxc_uri, room_id, user_id, MilliSecondsSinceUnixEpoch, OwnedDeviceId,
|
||||
};
|
||||
use serde_json::{from_value as from_json_value, json, to_value as to_json_value};
|
||||
|
||||
@ -414,7 +414,7 @@ fn edit_deserialization_future() {
|
||||
#[test]
|
||||
fn verification_request_deserialization() {
|
||||
let user_id = user_id!("@example2:localhost");
|
||||
let device_id: Box<DeviceId> = "XOWLHHFSWM".into();
|
||||
let device_id: OwnedDeviceId = "XOWLHHFSWM".into();
|
||||
|
||||
let json_data = json!({
|
||||
"body": "@example:localhost is requesting to verify your key, ...",
|
||||
@ -449,7 +449,7 @@ fn verification_request_deserialization() {
|
||||
#[test]
|
||||
fn verification_request_serialization() {
|
||||
let user_id = user_id!("@example2:localhost").to_owned();
|
||||
let device_id: Box<DeviceId> = "XOWLHHFSWM".into();
|
||||
let device_id: OwnedDeviceId = "XOWLHHFSWM".into();
|
||||
let body = "@example:localhost is requesting to verify your key, ...".to_owned();
|
||||
|
||||
let methods =
|
||||
|
Loading…
x
Reference in New Issue
Block a user