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 } + } +}