diff --git a/ruma-events/src/room/encrypted.rs b/ruma-events/src/room/encrypted.rs index 5020db53..dd746046 100644 --- a/ruma-events/src/room/encrypted.rs +++ b/ruma-events/src/room/encrypted.rs @@ -67,6 +67,9 @@ impl CiphertextInfo { } /// The payload for `EncryptedEvent` using the *m.megolm.v1.aes-sha2* algorithm. +/// +/// To createn an instance of this type, first create a `MegolmV1AesSh2ContentInit` and convert it +/// via `MegolmV1AesSha2Content::from` / `.into()`. #[derive(Clone, Debug, Serialize, Deserialize)] #[non_exhaustive] pub struct MegolmV1AesSha2Content { @@ -83,14 +86,6 @@ pub struct MegolmV1AesSha2Content { pub session_id: String, } -impl MegolmV1AesSha2Content { - /// Creates a new `MegolmV1AesSha2Content` from the given init struct. - pub fn new(init: MegolmV1AesSha2ContentInit) -> Self { - let MegolmV1AesSha2ContentInit { ciphertext, sender_key, device_id, session_id } = init; - Self { ciphertext, sender_key, device_id, session_id } - } -} - /// Mandatory initial set of fields of `MegolmV1AesSha2Content`. /// /// This struct will not be updated even if additional fields are added to `MegolmV1AesSha2Content` @@ -110,6 +105,14 @@ pub struct MegolmV1AesSha2ContentInit { pub session_id: String, } +impl From for MegolmV1AesSha2Content { + /// Creates a new `MegolmV1AesSha2Content` from the given init struct. + fn from(init: MegolmV1AesSha2ContentInit) -> Self { + let MegolmV1AesSha2ContentInit { ciphertext, sender_key, device_id, session_id } = init; + Self { ciphertext, sender_key, device_id, session_id } + } +} + #[cfg(test)] mod tests { use matches::assert_matches;