diff --git a/src/room/encrypted.rs b/src/room/encrypted.rs index 9d18e16f..f65720eb 100644 --- a/src/room/encrypted.rs +++ b/src/room/encrypted.rs @@ -161,6 +161,21 @@ impl<'a> TryFrom<&'a str> for EncryptedEventContent { } } +impl Serialize for EncryptedEventContent { + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + match *self { + EncryptedEventContent::OlmV1Curve25519AesSha2(ref content) => { + content.serialize(serializer) + } + EncryptedEventContent::MegolmV1AesSha2(ref content) => content.serialize(serializer), + _ => panic!("Attempted to serialize __Nonexhaustive variant."), + } + } +} + mod raw { use super::*; @@ -205,23 +220,6 @@ mod raw { __Nonexhaustive, } - impl Serialize for EncryptedEventContent { - fn serialize(&self, serializer: S) -> Result - where - S: Serializer, - { - match *self { - EncryptedEventContent::OlmV1Curve25519AesSha2(ref content) => { - content.serialize(serializer) - } - EncryptedEventContent::MegolmV1AesSha2(ref content) => { - content.serialize(serializer) - } - _ => panic!("Attempted to serialize __Nonexhaustive variant."), - } - } - } - impl<'de> Deserialize<'de> for EncryptedEventContent { fn deserialize(deserializer: D) -> Result where @@ -312,21 +310,6 @@ pub struct MegolmV1AesSha2Content { pub session_id: String, } -impl Serialize for EncryptedEventContent { - fn serialize(&self, serializer: S) -> Result - where - S: Serializer, - { - match *self { - EncryptedEventContent::OlmV1Curve25519AesSha2(ref content) => { - content.serialize(serializer) - } - EncryptedEventContent::MegolmV1AesSha2(ref content) => content.serialize(serializer), - _ => panic!("Attempted to serialize __Nonexhaustive variant."), - } - } -} - #[cfg(test)] mod tests { use serde_json::to_string;