diff --git a/crates/ruma-common/src/events/enums.rs b/crates/ruma-common/src/events/enums.rs index 31711791..ef93349a 100644 --- a/crates/ruma-common/src/events/enums.rs +++ b/crates/ruma-common/src/events/enums.rs @@ -180,6 +180,14 @@ impl AnyTimelineEvent { /// Returns this event's `relations` from inside `unsigned`. pub fn relations(&self) -> &BundledRelations; } + + /// Returns this event's `type`. + pub fn event_type(&self) -> TimelineEventType { + match self { + Self::MessageLike(e) => e.event_type().into(), + Self::State(e) => e.event_type().into(), + } + } } /// Any sync room event. @@ -213,6 +221,14 @@ impl AnySyncTimelineEvent { pub fn relations(&self) -> &BundledRelations; } + /// Returns this event's `type`. + pub fn event_type(&self) -> TimelineEventType { + match self { + Self::MessageLike(e) => e.event_type().into(), + Self::State(e) => e.event_type().into(), + } + } + /// Converts `self` to an `AnyTimelineEvent` by adding the given a room ID. pub fn into_full_event(self, room_id: OwnedRoomId) -> AnyTimelineEvent { match self {