pub enum RelatesTo {
Annotation {
event_id: EventId,
key: String,
},
Replace {
event_id: EventId,
},
Thread {
event_id: EventId,
is_falling_back: bool,
in_reply_to: Option<InReplyTo>,
},
InReplyTo(InReplyTo),
Unknown(Value),
}Expand description
One event’s m.relates_to field, parsed into the shape its rel_type
(or, for the legacy reply pointer, the absence of one) implies. Never
fails to parse: an m.relates_to value that matches none of the shapes
below becomes RelatesTo::Unknown, carrying the raw value.
Variants§
Annotation
m.annotation (reactions): key is the reaction’s own content
(e.g. an emoji), event_id the event being reacted to.
Fields
Replace
m.replace (edits, MSC2676): event_id is the event being
replaced. The replacement content itself lives at the top level of
the edit event’s own content, under m.new_content — not part of
this type, since that key sits alongside m.relates_to, not inside
it.
Thread
m.thread (MSC3440).
Fields
InReplyTo(InReplyTo)
The legacy rich-reply pointer (m.in_reply_to with no rel_type
alongside it) — still sent for backward compatibility even when an
event carries a “real” relation.
Unknown(Value)
An m.relates_to value present but not matching any shape above —
kept verbatim rather than rejected (module doc).
Implementations§
Source§impl RelatesTo
impl RelatesTo
Sourcepub fn from_content(content: &Value) -> Option<Self>
pub fn from_content(content: &Value) -> Option<Self>
Extracts and parses content["m.relates_to"], if present. Returns
None only when the field itself is absent — most events don’t
relate to anything. See this type’s own doc for what happens when
the field is present but unrecognized.