Skip to main content

ruma_state_res/
utils.rs

1//! Helper types.
2
3use ruma_common::{EventId, IdParseError, OwnedEventId, RoomId};
4
5pub mod event_id_map;
6pub mod event_id_set;
7
8/// Convenience extension trait for [`RoomId`].
9pub(crate) trait RoomIdExt {
10    /// Get the event ID of the `m.room.create` event of the room from a PDU, for room versions
11    /// using it as the room ID.
12    fn room_create_event_id(&self) -> Result<OwnedEventId, IdParseError>;
13}
14
15impl<T> RoomIdExt for T
16where
17    T: AsRef<RoomId>,
18{
19    fn room_create_event_id(&self) -> Result<OwnedEventId, IdParseError> {
20        EventId::parse(format!("${}", self.as_ref().strip_sigil()))
21    }
22}