Function matrix_sdk::ruma::events::room::message::deserialize_relation

source ·
pub fn deserialize_relation<'de, D, C>(
    deserializer: D,
) -> Result<Option<Relation<C>>, <D as Deserializer<'de>>::Error>
where D: Deserializer<'de>, C: Deserialize<'de>,
Expand description

Deserialize an event’s relates_to field.

Use it like this:

use ruma_events::room::message::{deserialize_relation, MessageType, Relation};

#[derive(Deserialize, Serialize)]
struct MyEventContent {
    #[serde(
        flatten,
        skip_serializing_if = "Option::is_none",
        deserialize_with = "deserialize_relation"
    )]
    relates_to: Option<Relation<MessageType>>,
}