#[non_exhaustive]pub enum Relation<C> {
Reply {
in_reply_to: InReplyTo,
},
Replacement(Replacement<C>),
Thread(Thread),
}
Expand description
Message event relationship.
Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
Non-exhaustive enums could have additional variants added in future. Therefore, when matching against variants of non-exhaustive enums, an extra wildcard arm must be added to account for any future variants.
Reply
An m.in_reply_to
relation indicating that the event is a reply to another event.
Replacement(Replacement<C>)
An event that replaces another event.
Thread(Thread)
An event that belongs to a thread.
Implementations§
source§impl<C> Relation<C>
impl<C> Relation<C>
sourcepub fn rel_type(&self) -> Option<RelationType>
pub fn rel_type(&self) -> Option<RelationType>
The type of this Relation
.
Returns an Option
because the Reply
relation does not have arel_type
field.
sourcepub fn data(&self) -> Cow<'_, Map<String, Value>>where
C: Clone,
pub fn data(&self) -> Cow<'_, Map<String, Value>>where
C: Clone,
The associated data.
The returned JSON object holds the contents of m.relates_to
, including rel_type
and
event_id
if present, but not things like m.new_content
for m.replace
relations that
live next to m.relates_to
.
Prefer to use the public variants of Relation
where possible; this method is meant to
be used for custom relations only.
Trait Implementations§
source§impl<C> Serialize for Relation<C>
impl<C> Serialize for Relation<C>
source§fn serialize<S>(
&self,
serializer: S,
) -> Result<<S as Serializer>::Ok, <S as Serializer>::Error>where
S: Serializer,
fn serialize<S>(
&self,
serializer: S,
) -> Result<<S as Serializer>::Ok, <S as Serializer>::Error>where
S: Serializer,
Serialize this value into the given Serde serializer. Read more
source§impl<C> TryFrom<Relation<C>> for RelationWithoutReplacement
impl<C> TryFrom<Relation<C>> for RelationWithoutReplacement
§type Error = Replacement<C>
type Error = Replacement<C>
The type returned in the event of a conversion error.
source§fn try_from(
value: Relation<C>,
) -> Result<RelationWithoutReplacement, <RelationWithoutReplacement as TryFrom<Relation<C>>>::Error>
fn try_from( value: Relation<C>, ) -> Result<RelationWithoutReplacement, <RelationWithoutReplacement as TryFrom<Relation<C>>>::Error>
Performs the conversion.
Auto Trait Implementations§
impl<C> Freeze for Relation<C>where
C: Freeze,
impl<C> RefUnwindSafe for Relation<C>where
C: RefUnwindSafe,
impl<C> Send for Relation<C>where
C: Send,
impl<C> Sync for Relation<C>where
C: Sync,
impl<C> Unpin for Relation<C>where
C: Unpin,
impl<C> UnwindSafe for Relation<C>where
C: UnwindSafe,
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§default unsafe fn clone_to_uninit(&self, dst: *mut T)
default unsafe fn clone_to_uninit(&self, dst: *mut T)
🔬This is a nightly-only experimental API. (
clone_to_uninit
)