From b31a6eac658d33c651cc1a8f89eb53ec43031b1c Mon Sep 17 00:00:00 2001 From: Jonas Platte Date: Fri, 17 Jul 2020 01:20:41 +0200 Subject: [PATCH] Mark EncryptionEventContent as non_exhaustive --- ruma-events/src/room/encryption.rs | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/ruma-events/src/room/encryption.rs b/ruma-events/src/room/encryption.rs index 2f0ef329..2de42ecc 100644 --- a/ruma-events/src/room/encryption.rs +++ b/ruma-events/src/room/encryption.rs @@ -11,6 +11,7 @@ pub type EncryptionEvent = StateEvent; /// The payload for `EncryptionEvent`. #[derive(Clone, Debug, Deserialize, Serialize, StateEventContent)] +#[non_exhaustive] #[ruma_event(type = "m.room.encryption")] pub struct EncryptionEventContent { /// The encryption algorithm to be used to encrypt messages sent in this room. @@ -30,3 +31,10 @@ pub struct EncryptionEventContent { #[serde(skip_serializing_if = "Option::is_none")] pub rotation_period_msgs: Option, } + +impl EncryptionEventContent { + /// Creates a new `EncryptionEventContent` with the given algorithm. + pub fn new(algorithm: Algorithm) -> Self { + Self { algorithm, rotation_period_ms: None, rotation_period_msgs: None } + } +}