Implement Serialize for EncryptedEventContent.
This commit is contained in:
parent
3e58ad7a8f
commit
5c2e0e62a9
@ -161,6 +161,21 @@ impl<'a> TryFrom<&'a str> for EncryptedEventContent {
|
||||
}
|
||||
}
|
||||
|
||||
impl Serialize for EncryptedEventContent {
|
||||
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
|
||||
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<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
|
||||
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<D>(deserializer: D) -> Result<Self, D::Error>
|
||||
where
|
||||
@ -312,21 +310,6 @@ pub struct MegolmV1AesSha2Content {
|
||||
pub session_id: String,
|
||||
}
|
||||
|
||||
impl Serialize for EncryptedEventContent {
|
||||
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
|
||||
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;
|
||||
|
Loading…
x
Reference in New Issue
Block a user