events: Split EncryptedEventContent in two

This commit is contained in:
Jonas Platte 2021-08-11 18:54:25 +02:00
parent 31bed8be9a
commit b2b8265ded
No known key found for this signature in database
GPG Key ID: CC154DE0E30B7C67
2 changed files with 15 additions and 5 deletions

View File

@ -9,6 +9,9 @@ Breaking changes:
validation validation
* Remove unused `FromStrError` * Remove unused `FromStrError`
* Remove deprecated method `room::name::NameEventContent::name` * Remove deprecated method `room::name::NameEventContent::name`
* Make `encrypted::EncryptedToDeviceEventContent` its own type instead of a type
alias for `EncryptedEventContent`
* It doesn't have the `relates_to` field `EncryptedEventContent` has
* Upgrade dependencies * Upgrade dependencies
# 0.24.0 # 0.24.0

View File

@ -26,7 +26,7 @@ pub type EncryptedEvent = MessageEvent<EncryptedEventContent>;
#[cfg_attr(not(feature = "unstable-exhaustive-types"), non_exhaustive)] #[cfg_attr(not(feature = "unstable-exhaustive-types"), non_exhaustive)]
#[ruma_event(type = "m.room.encrypted", kind = Message, kind = ToDevice)] #[ruma_event(type = "m.room.encrypted", kind = Message, kind = ToDevice)]
pub struct EncryptedEventContent { pub struct EncryptedEventContent {
/// Encrypted event content /// Algorithm-specific fields.
#[serde(flatten)] #[serde(flatten)]
pub scheme: EncryptedEventScheme, pub scheme: EncryptedEventScheme,
@ -37,9 +37,6 @@ pub struct EncryptedEventContent {
pub relates_to: Option<Relation>, pub relates_to: Option<Relation>,
} }
/// The to-device version of the payload for the `EncryptedEvent`.
pub type EncryptedToDeviceEventContent = EncryptedEventContent;
impl EncryptedEventContent { impl EncryptedEventContent {
/// Creates a new `EncryptedEventContent` with the given scheme and relation. /// Creates a new `EncryptedEventContent` with the given scheme and relation.
pub fn new(scheme: EncryptedEventScheme, relates_to: Option<Relation>) -> Self { pub fn new(scheme: EncryptedEventScheme, relates_to: Option<Relation>) -> Self {
@ -53,7 +50,17 @@ impl From<EncryptedEventScheme> for EncryptedEventContent {
} }
} }
/// The encryption scheme for `EncryptedEventContent` /// The to-device content payload for `m.encrypted` events.
#[derive(Clone, Debug, Deserialize, Serialize, EventContent)]
#[cfg_attr(not(feature = "unstable-exhaustive-types"), non_exhaustive)]
#[ruma_event(type = "m.room.encrypted", kind = ToDevice)]
pub struct EncryptedToDeviceEventContent {
/// Algorithm-specific fields.
#[serde(flatten)]
pub scheme: EncryptedEventScheme,
}
/// The encryption scheme for `EncryptedEventContent`.
#[derive(Clone, Debug, Deserialize, Serialize)] #[derive(Clone, Debug, Deserialize, Serialize)]
#[cfg_attr(not(feature = "unstable-exhaustive-types"), non_exhaustive)] #[cfg_attr(not(feature = "unstable-exhaustive-types"), non_exhaustive)]
#[serde(tag = "algorithm")] #[serde(tag = "algorithm")]