events: Add type accessors to Any{Sync}TimelineEvent
@@ -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 {
