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

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<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.

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) -> HistoryVisibility

Get the history visibility policy of this room.

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>

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>

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.

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

source§

impl Sync for Room

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§

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

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

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

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,

§

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>).
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§

impl<T> Instrument for T

source§

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

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

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

§

type Output = T

Should always be Self
source§

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

§

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>,

§

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>,

§

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

source§

impl<T> WithSubscriber for T

source§

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
source§

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> SendOutsideWasm for T
where T: Send,

source§

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