Struct matrix_sdk_base::Room
source · pub struct Room {
pub latest_encrypted_events: Arc<RwLock<RingBuffer<Raw<AnySyncTimelineEvent>>>>,
/* 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>>>>
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.
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<OwnedUserId>
pub fn direct_targets(&self) -> HashSet<OwnedUserId>
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) -> HistoryVisibility
pub fn history_visibility(&self) -> HistoryVisibility
Get the history visibility policy of this room.
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<DisplayName>
pub async fn compute_display_name(&self) -> StoreResult<DisplayName>
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<DisplayName>
pub fn cached_display_name(&self) -> Option<DisplayName>
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>
pub fn latest_event(&self) -> Option<LatestEvent>
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>
pub fn recency_stamp(&self) -> Option<u64>
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) -> Vec<OwnedEventId>
pub fn pinned_event_ids(&self) -> Vec<OwnedEventId>
Returns the current pinned event ids for this room.
Trait Implementations§
impl Send for Room
impl Sync for Room
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,
source§default unsafe fn clone_to_uninit(&self, dst: *mut T)
default unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)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,
source§impl<T> Instrument for T
impl<T> Instrument for T
source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
source§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