matrix_sdk_base

Struct Room

Source
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>>>>
Available on crate features 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

Source

pub fn room_id(&self) -> &RoomId

Get the unique room id of the room.

Source

pub fn creator(&self) -> Option<OwnedUserId>

Get a copy of the room creator.

Source

pub fn own_user_id(&self) -> &UserId

Get our own user id.

Source

pub fn state(&self) -> RoomState

Get the state of the room.

Source

pub fn prev_state(&self) -> Option<RoomState>

Get the previous state of the room, if it had any.

Source

pub fn is_space(&self) -> bool

Whether this room’s RoomType is m.space.

Source

pub fn room_type(&self) -> Option<RoomType>

Returns the room’s type as defined in its creation event (m.room.create).

Source

pub fn unread_notification_counts(&self) -> UnreadNotificationsCount

Get the unread notification counts.

Source

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.

Source

pub fn read_receipts(&self) -> RoomReadReceipts

Get the detailed information about read receipts for the room.

Source

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.

Source

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.

Source

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.

Source

pub fn mark_members_missing(&self)

Mark this Room as still missing member information.

Source

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.

Source

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.

Source

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.

Source

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.

Source

pub fn avatar_url(&self) -> Option<OwnedMxcUri>

Get the avatar url of this room.

Source

pub fn avatar_info(&self) -> Option<ImageInfo>

Get information about the avatar of this room.

Source

pub fn canonical_alias(&self) -> Option<OwnedRoomAliasId>

Get the canonical alias of this room.

Source

pub fn alt_aliases(&self) -> Vec<OwnedRoomAliasId>

Get the canonical alias of this room.

Source

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.

Source

pub async fn is_direct(&self) -> StoreResult<bool>

Is this room considered a direct message.

Async because it can read room info from storage.

Source

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.

Source

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.

Source

pub fn is_encrypted(&self) -> bool

Is the room encrypted.

Source

pub fn encryption_settings(&self) -> Option<RoomEncryptionEventContent>

Get the m.room.encryption content that enabled end to end encryption in the room.

Source

pub fn guest_access(&self) -> GuestAccess

Get the guest access policy of this room.

Source

pub fn history_visibility(&self) -> Option<HistoryVisibility>

Get the history visibility policy of this room.

Source

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.

Source

pub fn is_public(&self) -> bool

Is the room considered to be public.

Source

pub fn join_rule(&self) -> JoinRule

Get the join rule policy of this room.

Source

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.

Source

pub async fn power_levels(&self) -> Result<RoomPowerLevels, Error>

Get the current power levels of this room.

Source

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.

Source

pub fn is_tombstoned(&self) -> bool

Has the room been tombstoned.

Source

pub fn tombstone(&self) -> Option<RoomTombstoneEventContent>

Get the m.room.tombstone content of this room if there is one.

Source

pub fn topic(&self) -> Option<String>

Get the topic of the room.

Source

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

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

pub fn latest_event(&self) -> Option<LatestEvent>

Available on crate feature experimental-sliding-sync only.

Return the last event in this room, if one has been cached during sliding sync.

Source

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.

Source

pub async fn members( &self, memberships: RoomMemberships, ) -> StoreResult<Vec<RoomMember>>

Get the RoomMembers of this room that are known to the store, with the given memberships.

Source

pub fn heroes(&self) -> Vec<RoomHero>

Get the heroes for this room.

Source

pub fn active_members_count(&self) -> u64

Returns the number of members who have joined or been invited to the room.

Source

pub fn invited_members_count(&self) -> u64

Returns the number of members who have been invited to the room.

Source

pub fn joined_members_count(&self) -> u64

Returns the number of members who have joined the room.

Source

pub fn subscribe_info(&self) -> Subscriber<RoomInfo>

Subscribe to the inner RoomInfo.

Source

pub fn clone_info(&self) -> RoomInfo

Clone the inner RoomInfo.

Source

pub fn set_room_info( &self, room_info: RoomInfo, room_info_notable_update_reasons: RoomInfoNotableUpdateReasons, )

Update the summary with given RoomInfo.

Source

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.

Source

pub async fn tags(&self) -> StoreResult<Option<Tags>>

Get the Tags for this room.

Source

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.

Source

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.

Source

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.

Source

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.

Source

pub fn is_marked_unread(&self) -> bool

Returns a boolean indicating if this room has been manually marked as unread

Source

pub fn recency_stamp(&self) -> Option<u64>

Available on crate feature experimental-sliding-sync only.

Returns the recency stamp of the room.

Please read RoomInfo::recency_stamp to learn more.

Source

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.

Source

pub fn pinned_event_ids(&self) -> Option<Vec<OwnedEventId>>

Returns the current pinned event ids for this room.

Source

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.

Source

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§

Source§

impl Clone for Room

Source§

fn clone(&self) -> Room

Returns a copy of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Room

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Send for Room

Available on non-crate feature test-send-sync only.
Source§

impl Sync for Room

Available on non-crate feature test-send-sync only.

Auto Trait Implementations§

§

impl Freeze for Room

§

impl !RefUnwindSafe for Room

§

impl Unpin for Room

§

impl !UnwindSafe for Room

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dst: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. Read more
§

impl<T> CompatExt for T

§

fn compat(self) -> Compat<T>

Applies the [Compat] adapter by value. Read more
§

fn compat_ref(&self) -> Compat<&T>

Applies the [Compat] adapter by shared reference. Read more
§

fn compat_mut(&mut self) -> Compat<&mut T>

Applies the [Compat] adapter by mutable reference. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, UT> HandleAlloc<UT> for T
where T: Send + Sync,

Source§

fn new_handle(value: Arc<T>) -> Handle

Create a new handle for an Arc value Read more
Source§

fn clone_handle(handle: Handle) -> Handle

Clone a handle Read more
Source§

fn consume_handle(handle: Handle) -> Arc<T>

Consume a handle, getting back the initial Arc<>
Source§

fn get_arc(handle: Handle) -> Arc<Self>

Get a clone of the Arc<> using a “borrowed” handle. Read more
Source§

impl<T, W> HasTypeWitness<W> for T
where W: MakeTypeWitness<Arg = T>, T: ?Sized,

Source§

const WITNESS: W = W::MAKE

A constant of the type witness
Source§

impl<T> Identity for T
where T: ?Sized,

Source§

const TYPE_EQ: TypeEq<T, <T as Identity>::Type> = TypeEq::NEW

Proof that Self is the same type as Self::Type, provides methods for casting between Self and Self::Type.
Source§

type Type = T

The same type as Self, used to emulate type equality bounds (T == U) with associated type equality constraints (T: Identity<Type = U>).
§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more
Source§

impl<T> AsyncTraitDeps for T

Source§

impl<T> ErasedDestructor for T
where T: 'static,

Source§

impl<T> MaybeSendSync for T

Source§

impl<T> SendOutsideWasm for T
where T: Send,

Source§

impl<T> SyncOutsideWasm for T
where T: Sync,