Struct matrix_sdk::BaseRoom

source ·
pub struct BaseRoom {
    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>>>>
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.

Implementations§

source§

impl Room

source

pub fn room_id(&self) -> &RoomId

Get the unique room id of the room.

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 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_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 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) -> Result<bool, StoreError>

Is this room considered a direct message.

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 fn name(&self) -> Option<String>

Get the m.room.name of this room.

The returned string is guaranteed not to be empty.

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.

matrix_rtc 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 display_name(&self) -> Result<DisplayName, StoreError>

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.

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) -> Result<Vec<OwnedUserId>, StoreError>

Get the list of users ids that are considered to be joined members of this room.

source

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

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

source

pub async fn joined_members(&self) -> Result<Vec<RoomMember>, StoreError>

👎Deprecated: Use members with RoomMemberships::JOIN instead

Get the list of RoomMembers that are considered to be joined members of this room.

source

pub async fn active_members(&self) -> Result<Vec<RoomMember>, StoreError>

👎Deprecated: Use members with RoomMemberships::ACTIVE instead

Get the list of RoomMembers that are considered to be joined or invited members of 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, trigger_room_list_update: bool)

Update the summary with given RoomInfo.

This also triggers an update for room info observers if trigger_room_list_update is true.

source

pub async fn get_member( &self, user_id: &UserId ) -> Result<Option<RoomMember>, StoreError>

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, invited, left, banned state.

source

pub async fn tags( &self ) -> Result<Option<BTreeMap<TagName, TagInfo>>, StoreError>

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 ) -> Result<Option<(OwnedEventId, Receipt)>, StoreError>

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 ) -> Result<Vec<(OwnedUserId, Receipt)>, StoreError>

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

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<(), Error>

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl !RefUnwindSafe for Room

§

impl Send for Room

§

impl Sync 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
§

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> DynClone for T
where T: Clone,

source§

fn __clone_box(&self, _: Private) -> *mut ()

source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> FutureExt for T

§

fn with_context(self, otel_cx: Context) -> WithContext<Self>

Attaches the provided Context to this type, returning a WithContext wrapper. Read more
§

fn with_current_context(self) -> WithContext<Self>

Attaches the current Context to this type, returning a WithContext wrapper. Read more
§

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

§

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

Create a new handle for an Arc value Read more
§

fn clone_handle(handle: Handle) -> Handle

Clone a handle Read more
§

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

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

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

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

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

§

const WITNESS: W = W::MAKE

A constant of the type witness
§

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

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.

§

impl<T> IntoResult<T> for T

§

type Err = Infallible

§

fn into_result(self) -> Result<T, <T as IntoResult<T>>::Err>

§

impl<T> Pointable for T

§

const ALIGN: usize = _

The alignment of pointer.
§

type Init = T

The type for initializers.
§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. 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.
§

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

§

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

source§

impl<T> AsyncTraitDeps for T

source§

impl<T> CloneAny for T
where T: Any + Clone,

source§

impl<T> CloneAnySend for T
where T: Any + Send + Clone,

source§

impl<T> CloneAnySendSync for T
where T: Any + Send + Sync + Clone,

source§

impl<T> CloneAnySync for T
where T: Any + Sync + Clone,

source§

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

source§

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