Skip to content

Commit f91ffb4

Browse files
committed
feat: Add a method to get the event type of a TimelineEventKind
1 parent 301ca5e commit f91ffb4

1 file changed

Lines changed: 8 additions & 0 deletions

File tree

crates/matrix-sdk-common/src/deserialized_responses.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -949,6 +949,14 @@ impl TimelineEventKind {
949949
TimelineEventKind::PlainText { .. } => None,
950950
}
951951
}
952+
953+
/// Get the event type of this event.
954+
///
955+
/// Returns `None` if there isn't an event type or if the event failed to be
956+
/// deserialized.
957+
pub fn event_type(&self) -> Option<String> {
958+
self.raw().get_field("type").ok().flatten()
959+
}
952960
}
953961

954962
#[cfg(not(tarpaulin_include))]

0 commit comments

Comments
 (0)