pub struct Room {
pub latest_encrypted_events: Arc<RwLock<RingBuffer<Raw<AnySyncTimelineEvent>>>>,
pub seen_knock_request_ids_map: SharedObservable<Option<BTreeMap<OwnedEventId, OwnedUserId>>, AsyncLock>,
/* private fields */
}
Expand description
The underlying room data structure collecting state for joined, left and invited rooms.
Fields§
§latest_encrypted_events: Arc<RwLock<RingBuffer<Raw<AnySyncTimelineEvent>>>>
e2e-encryption
and experimental-sliding-sync
only.The most recent few encrypted events. When the keys come through to
decrypt these, the most recent relevant one will replace
latest_event
. (We can’t tell which one is relevant until
they are decrypted.)
Currently, these are held in Room rather than RoomInfo, because we were not sure whether holding too many of them might make the cache too slow to load on startup. Keeping them here means they are not cached to disk but held in memory.
seen_knock_request_ids_map: SharedObservable<Option<BTreeMap<OwnedEventId, OwnedUserId>>, AsyncLock>
A map for ids of room membership events in the knocking state linked to the user id of the user affected by the member event, that the current user has marked as seen so they can be ignored.
Implementations§
Source§impl Room
impl Room
Sourcepub fn creator(&self) -> Option<OwnedUserId>
pub fn creator(&self) -> Option<OwnedUserId>
Get a copy of the room creator.
Sourcepub fn own_user_id(&self) -> &UserId
pub fn own_user_id(&self) -> &UserId
Get our own user id.
Sourcepub fn prev_state(&self) -> Option<RoomState>
pub fn prev_state(&self) -> Option<RoomState>
Get the previous state of the room, if it had any.
Sourcepub fn room_type(&self) -> Option<RoomType>
pub fn room_type(&self) -> Option<RoomType>
Returns the room’s type as defined in its creation event
(m.room.create
).
Sourcepub fn unread_notification_counts(&self) -> UnreadNotificationsCount
pub fn unread_notification_counts(&self) -> UnreadNotificationsCount
Get the unread notification counts.
Sourcepub fn num_unread_messages(&self) -> u64
pub fn num_unread_messages(&self) -> u64
Get the number of unread messages (computed client-side).
This might be more precise than Self::unread_notification_counts
for
encrypted rooms.
Sourcepub fn read_receipts(&self) -> RoomReadReceipts
pub fn read_receipts(&self) -> RoomReadReceipts
Get the detailed information about read receipts for the room.
Sourcepub fn num_unread_notifications(&self) -> u64
pub fn num_unread_notifications(&self) -> u64
Get the number of unread notifications (computed client-side).
This might be more precise than Self::unread_notification_counts
for
encrypted rooms.
Sourcepub fn num_unread_mentions(&self) -> u64
pub fn num_unread_mentions(&self) -> u64
Get the number of unread mentions (computed client-side), that is, messages causing a highlight in a room.
This might be more precise than Self::unread_notification_counts
for
encrypted rooms.
Sourcepub fn are_members_synced(&self) -> bool
pub fn are_members_synced(&self) -> bool
Check if the room has its members fully synced.
Members might be missing if lazy member loading was enabled for the sync.
Returns true if no members are missing, false otherwise.
Sourcepub fn mark_members_missing(&self)
pub fn mark_members_missing(&self)
Mark this Room as still missing member information.
Sourcepub fn is_state_fully_synced(&self) -> bool
pub fn is_state_fully_synced(&self) -> bool
Check if the room states have been synced
States might be missing if we have only seen the room_id of this Room
so far, for example as the response for a create_room
request without
being synced yet.
Returns true if the state is fully synced, false otherwise.
Sourcepub fn is_state_partially_or_fully_synced(&self) -> bool
pub fn is_state_partially_or_fully_synced(&self) -> bool
Check if the room state has been at least partially synced.
See Room::is_state_fully_synced
for more info.
Sourcepub fn is_encryption_state_synced(&self) -> bool
pub fn is_encryption_state_synced(&self) -> bool
Check if the room has its encryption event synced.
The encryption event can be missing when the room hasn’t appeared in sync yet.
Returns true if the encryption state is synced, false otherwise.
Sourcepub fn last_prev_batch(&self) -> Option<String>
pub fn last_prev_batch(&self) -> Option<String>
Get the prev_batch
token that was received from the last sync. May be
None
if the last sync contained the full room history.
Sourcepub fn avatar_url(&self) -> Option<OwnedMxcUri>
pub fn avatar_url(&self) -> Option<OwnedMxcUri>
Get the avatar url of this room.
Sourcepub fn avatar_info(&self) -> Option<ImageInfo>
pub fn avatar_info(&self) -> Option<ImageInfo>
Get information about the avatar of this room.
Sourcepub fn canonical_alias(&self) -> Option<OwnedRoomAliasId>
pub fn canonical_alias(&self) -> Option<OwnedRoomAliasId>
Get the canonical alias of this room.
Sourcepub fn alt_aliases(&self) -> Vec<OwnedRoomAliasId>
pub fn alt_aliases(&self) -> Vec<OwnedRoomAliasId>
Get the canonical alias of this room.
Sourcepub fn create_content(&self) -> Option<RoomCreateWithCreatorEventContent>
pub fn create_content(&self) -> Option<RoomCreateWithCreatorEventContent>
Get the m.room.create
content of this room.
This usually isn’t optional but some servers might not send an
m.room.create
event as the first event for a given room, thus this can
be optional.
For room versions earlier than room version 11, if the event is
redacted, all fields except creator
will be set to their default
value.
Sourcepub async fn is_direct(&self) -> StoreResult<bool>
pub async fn is_direct(&self) -> StoreResult<bool>
Is this room considered a direct message.
Async because it can read room info from storage.
Sourcepub fn direct_targets(&self) -> HashSet<OwnedDirectUserIdentifier>
pub fn direct_targets(&self) -> HashSet<OwnedDirectUserIdentifier>
If this room is a direct message, get the members that we’re sharing the room with.
Note: The member list might have been modified in the meantime and the targets might not even be in the room anymore. This setting should only be considered as guidance. We leave members in this list to allow us to re-find a DM with a user even if they have left, since we may want to re-invite them.
Sourcepub fn direct_targets_length(&self) -> usize
pub fn direct_targets_length(&self) -> usize
If this room is a direct message, returns the number of members that we’re sharing the room with.
Sourcepub fn is_encrypted(&self) -> bool
pub fn is_encrypted(&self) -> bool
Is the room encrypted.
Sourcepub fn encryption_settings(&self) -> Option<RoomEncryptionEventContent>
pub fn encryption_settings(&self) -> Option<RoomEncryptionEventContent>
Get the m.room.encryption
content that enabled end to end encryption
in the room.
Sourcepub fn guest_access(&self) -> GuestAccess
pub fn guest_access(&self) -> GuestAccess
Get the guest access policy of this room.
Sourcepub fn history_visibility(&self) -> Option<HistoryVisibility>
pub fn history_visibility(&self) -> Option<HistoryVisibility>
Get the history visibility policy of this room.
Sourcepub fn history_visibility_or_default(&self) -> HistoryVisibility
pub fn history_visibility_or_default(&self) -> HistoryVisibility
Get the history visibility policy of this room, or a sensible default if the event is missing.
Sourcepub fn max_power_level(&self) -> i64
pub fn max_power_level(&self) -> i64
Get the maximum power level that this room contains.
This is useful if one wishes to normalize the power levels, e.g. from 0-100 where 100 would be the max power level.
Sourcepub async fn power_levels(&self) -> Result<RoomPowerLevels, Error>
pub async fn power_levels(&self) -> Result<RoomPowerLevels, Error>
Get the current power levels of this room.
Sourcepub fn name(&self) -> Option<String>
pub fn name(&self) -> Option<String>
Get the m.room.name
of this room.
The returned string may be empty if the event has been redacted, or it’s missing from storage.
Sourcepub fn is_tombstoned(&self) -> bool
pub fn is_tombstoned(&self) -> bool
Has the room been tombstoned.
Sourcepub fn tombstone(&self) -> Option<RoomTombstoneEventContent>
pub fn tombstone(&self) -> Option<RoomTombstoneEventContent>
Get the m.room.tombstone
content of this room if there is one.
Sourcepub fn has_active_room_call(&self) -> bool
pub fn has_active_room_call(&self) -> bool
Is there a non expired membership with application “m.call” and scope “m.room” in this room
Sourcepub fn active_room_call_participants(&self) -> Vec<OwnedUserId>
pub fn active_room_call_participants(&self) -> Vec<OwnedUserId>
Returns a Vec of userId’s that participate in the room call.
MatrixRTC memberships with application “m.call” and scope “m.room” are considered. A user can occur twice if they join with two devices. convert to a set depending if the different users are required or the amount of sessions.
The vector is ordered by oldest membership user to newest.
Sourcepub async fn compute_display_name(&self) -> StoreResult<RoomDisplayName>
pub async fn compute_display_name(&self) -> StoreResult<RoomDisplayName>
Return the cached display name of the room if it was provided via sync, or otherwise calculate it, taking into account its name, aliases and members.
The display name is calculated according to this algorithm.
This is automatically recomputed on every successful sync, and the
cached result can be retrieved in
Self::cached_display_name
.
Sourcepub fn cached_display_name(&self) -> Option<RoomDisplayName>
pub fn cached_display_name(&self) -> Option<RoomDisplayName>
Returns the cached computed display name, if available.
This cache is refilled every time we call
Self::compute_display_name
.
Sourcepub fn update_cached_user_defined_notification_mode(
&self,
mode: RoomNotificationMode,
)
pub fn update_cached_user_defined_notification_mode( &self, mode: RoomNotificationMode, )
Update the cached user defined notification mode.
This is automatically recomputed on every successful sync, and the
cached result can be retrieved in
Self::cached_user_defined_notification_mode
.
Sourcepub fn cached_user_defined_notification_mode(
&self,
) -> Option<RoomNotificationMode>
pub fn cached_user_defined_notification_mode( &self, ) -> Option<RoomNotificationMode>
Returns the cached user defined notification mode, if available.
This cache is refilled every time we call
Self::update_cached_user_defined_notification_mode
.
Sourcepub fn latest_event(&self) -> Option<LatestEvent>
Available on crate feature experimental-sliding-sync
only.
pub fn latest_event(&self) -> Option<LatestEvent>
experimental-sliding-sync
only.Return the last event in this room, if one has been cached during sliding sync.
Sourcepub async fn joined_user_ids(&self) -> StoreResult<Vec<OwnedUserId>>
pub async fn joined_user_ids(&self) -> StoreResult<Vec<OwnedUserId>>
Get the list of users ids that are considered to be joined members of this room.
Sourcepub async fn members(
&self,
memberships: RoomMemberships,
) -> StoreResult<Vec<RoomMember>>
pub async fn members( &self, memberships: RoomMemberships, ) -> StoreResult<Vec<RoomMember>>
Get the RoomMember
s of this room that are known to the store, with the
given memberships.
Sourcepub fn active_members_count(&self) -> u64
pub fn active_members_count(&self) -> u64
Returns the number of members who have joined or been invited to the room.
Sourcepub fn invited_members_count(&self) -> u64
pub fn invited_members_count(&self) -> u64
Returns the number of members who have been invited to the room.
Sourcepub fn joined_members_count(&self) -> u64
pub fn joined_members_count(&self) -> u64
Returns the number of members who have joined the room.
Sourcepub fn subscribe_info(&self) -> Subscriber<RoomInfo>
pub fn subscribe_info(&self) -> Subscriber<RoomInfo>
Subscribe to the inner RoomInfo
.
Sourcepub fn clone_info(&self) -> RoomInfo
pub fn clone_info(&self) -> RoomInfo
Clone the inner RoomInfo
.
Sourcepub fn set_room_info(
&self,
room_info: RoomInfo,
room_info_notable_update_reasons: RoomInfoNotableUpdateReasons,
)
pub fn set_room_info( &self, room_info: RoomInfo, room_info_notable_update_reasons: RoomInfoNotableUpdateReasons, )
Update the summary with given RoomInfo.
Sourcepub async fn get_member(
&self,
user_id: &UserId,
) -> StoreResult<Option<RoomMember>>
pub async fn get_member( &self, user_id: &UserId, ) -> StoreResult<Option<RoomMember>>
Get the RoomMember
with the given user_id
.
Returns None
if the member was never part of this room, otherwise
return a RoomMember
that can be in a joined, RoomState::Invited, left,
banned state.
Async because it can read from storage.
Get the Tags
for this room.
Sourcepub fn is_favourite(&self) -> bool
pub fn is_favourite(&self) -> bool
Check whether the room is marked as favourite.
A room is considered favourite if it has received the m.favourite
tag.
Sourcepub fn is_low_priority(&self) -> bool
pub fn is_low_priority(&self) -> bool
Check whether the room is marked as low priority.
A room is considered low priority if it has received the m.lowpriority
tag.
Sourcepub async fn load_user_receipt(
&self,
receipt_type: ReceiptType,
thread: ReceiptThread,
user_id: &UserId,
) -> StoreResult<Option<(OwnedEventId, Receipt)>>
pub async fn load_user_receipt( &self, receipt_type: ReceiptType, thread: ReceiptThread, user_id: &UserId, ) -> StoreResult<Option<(OwnedEventId, Receipt)>>
Get the receipt as an OwnedEventId
and Receipt
tuple for the given
receipt_type
, thread
and user_id
in this room.
Sourcepub async fn load_event_receipts(
&self,
receipt_type: ReceiptType,
thread: ReceiptThread,
event_id: &EventId,
) -> StoreResult<Vec<(OwnedUserId, Receipt)>>
pub async fn load_event_receipts( &self, receipt_type: ReceiptType, thread: ReceiptThread, event_id: &EventId, ) -> StoreResult<Vec<(OwnedUserId, Receipt)>>
Load from storage the receipts as a list of OwnedUserId
and Receipt
tuples for the given receipt_type
, thread
and event_id
in this
room.
Sourcepub fn is_marked_unread(&self) -> bool
pub fn is_marked_unread(&self) -> bool
Returns a boolean indicating if this room has been manually marked as unread
Sourcepub fn recency_stamp(&self) -> Option<u64>
Available on crate feature experimental-sliding-sync
only.
pub fn recency_stamp(&self) -> Option<u64>
experimental-sliding-sync
only.Returns the recency stamp of the room.
Please read RoomInfo::recency_stamp
to learn more.
Sourcepub fn pinned_event_ids_stream(&self) -> impl Stream<Item = Vec<OwnedEventId>>
pub fn pinned_event_ids_stream(&self) -> impl Stream<Item = Vec<OwnedEventId>>
Get a Stream
of loaded pinned events for this room.
If no pinned events are found a single empty Vec
will be returned.
Sourcepub fn pinned_event_ids(&self) -> Option<Vec<OwnedEventId>>
pub fn pinned_event_ids(&self) -> Option<Vec<OwnedEventId>>
Returns the current pinned event ids for this room.
Sourcepub async fn mark_knock_requests_as_seen(
&self,
user_ids: &[OwnedUserId],
) -> StoreResult<()>
pub async fn mark_knock_requests_as_seen( &self, user_ids: &[OwnedUserId], ) -> StoreResult<()>
Mark a list of requests to join the room as seen, given their state event ids.
Sourcepub async fn get_seen_knock_request_ids(
&self,
) -> Result<BTreeMap<OwnedEventId, OwnedUserId>, StoreError>
pub async fn get_seen_knock_request_ids( &self, ) -> Result<BTreeMap<OwnedEventId, OwnedUserId>, StoreError>
Get the list of seen knock request event ids in this room.
Trait Implementations§
impl Send for Room
test-send-sync
only.impl Sync for Room
test-send-sync
only.Auto Trait Implementations§
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<T> CompatExt for T
impl<T> CompatExt for T
Source§impl<T, UT> HandleAlloc<UT> for T
impl<T, UT> HandleAlloc<UT> for T
Source§fn consume_handle(handle: Handle) -> Arc<T>
fn consume_handle(handle: Handle) -> Arc<T>
Arc<>
Source§impl<T, W> HasTypeWitness<W> for Twhere
W: MakeTypeWitness<Arg = T>,
T: ?Sized,
impl<T, W> HasTypeWitness<W> for Twhere
W: MakeTypeWitness<Arg = T>,
T: ?Sized,
Source§impl<T> Identity for Twhere
T: ?Sized,
impl<T> Identity for Twhere
T: ?Sized,
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more