Struct matrix_sdk::room::Left
source · [−]pub struct Left { /* private fields */ }
Expand description
A room in the left state.
This struct contains all methods specific to a Room
with type
RoomType::Left
. Operations may fail once the underlying Room
changes
RoomType
.
Implementations
Methods from Deref<Target = Common>
sourcepub async fn avatar(&self, format: MediaFormat) -> Result<Option<Vec<u8>>>
pub async fn avatar(&self, format: MediaFormat) -> Result<Option<Vec<u8>>>
Gets the avatar of this room, if set.
Returns the avatar. If a thumbnail is requested no guarantee on the size of the image is given.
Arguments
format
- The desired format of the avatar.
Example
let client = Client::new(homeserver).await.unwrap();
client.login(user, "password", None, None).await.unwrap();
let room_id = room_id!("!roomid:example.com");
let room = client
.get_joined_room(&room_id)
.unwrap();
if let Some(avatar) = room.avatar(MediaFormat::File).await.unwrap() {
std::fs::write("avatar.png", avatar);
}
sourcepub async fn messages(&self, options: MessagesOptions<'_>) -> Result<Messages>
pub async fn messages(&self, options: MessagesOptions<'_>) -> Result<Messages>
Sends a request to /_matrix/client/r0/rooms/{room_id}/messages
and
returns a Messages
struct that contains a chunk of room and state
events (RoomEvent
and AnyStateEvent
).
With the encryption feature, messages are decrypted if possible. If decryption fails for an individual message, that message is returned undecrypted.
Examples
use matrix_sdk::{room::MessagesOptions, Client};
let request = MessagesOptions::backward("t47429-4392820_219380_26003_2265");
let mut client = Client::new(homeserver).await.unwrap();
let room = client
.get_joined_room(room_id!("!roomid:example.com"))
.unwrap();
assert!(room.messages(request).await.is_ok());
sourcepub async fn event(&self, event_id: &EventId) -> Result<RoomEvent>
pub async fn event(&self, event_id: &EventId) -> Result<RoomEvent>
Fetch the event with the given EventId
in this room.
sourcepub async fn sync_members(&self) -> Result<Option<MembersResponse>>
pub async fn sync_members(&self) -> Result<Option<MembersResponse>>
Sync the member list with the server.
This method will de-duplicate requests if it is called multiple times in
quick succession, in that case the return value will be None
.
sourcepub async fn active_members(&self) -> Result<Vec<RoomMember>>
pub async fn active_members(&self) -> Result<Vec<RoomMember>>
Get active members for this room, includes invited, joined members.
Note: This method will fetch the members from the homeserver if the member list isn’t synchronized due to member lazy loading. Because of that, it might panic if it isn’t run on a tokio thread.
Use active_members_no_sync() if you want a method that doesn’t do any requests.
sourcepub async fn active_members_no_sync(&self) -> Result<Vec<RoomMember>>
pub async fn active_members_no_sync(&self) -> Result<Vec<RoomMember>>
Get active members for this room, includes invited, joined members.
Note: This method will not fetch the members from the homeserver if the member list isn’t synchronized due to member lazy loading. Thus, members could be missing from the list.
Use active_members() if you want to ensure to always get the full member list.
sourcepub async fn joined_members(&self) -> Result<Vec<RoomMember>>
pub async fn joined_members(&self) -> Result<Vec<RoomMember>>
Get all the joined members of this room.
Note: This method will fetch the members from the homeserver if the member list isn’t synchronized due to member lazy loading. Because of that it might panic if it isn’t run on a tokio thread.
Use joined_members_no_sync() if you want a method that doesn’t do any requests.
sourcepub async fn joined_members_no_sync(&self) -> Result<Vec<RoomMember>>
pub async fn joined_members_no_sync(&self) -> Result<Vec<RoomMember>>
Get all the joined members of this room.
Note: This method will not fetch the members from the homeserver if the member list isn’t synchronized due to member lazy loading. Thus, members could be missing from the list.
Use joined_members() if you want to ensure to always get the full member list.
sourcepub async fn get_member(&self, user_id: &UserId) -> Result<Option<RoomMember>>
pub async fn get_member(&self, user_id: &UserId) -> Result<Option<RoomMember>>
Get a specific member of this room.
Note: This method will fetch the members from the homeserver if the member list isn’t synchronized due to member lazy loading. Because of that it might panic if it isn’t run on a tokio thread.
Use get_member_no_sync() if you want a method that doesn’t do any requests.
Arguments
user_id
- The ID of the user that should be fetched out of the store.
sourcepub async fn get_member_no_sync(
&self,
user_id: &UserId
) -> Result<Option<RoomMember>>
pub async fn get_member_no_sync(
&self,
user_id: &UserId
) -> Result<Option<RoomMember>>
Get a specific member of this room.
Note: This method will not fetch the members from the homeserver if the member list isn’t synchronized due to member lazy loading. Thus, members could be missing.
Use get_member() if you want to ensure to always have the full member list to chose from.
Arguments
user_id
- The ID of the user that should be fetched out of the store.
sourcepub async fn members(&self) -> Result<Vec<RoomMember>>
pub async fn members(&self) -> Result<Vec<RoomMember>>
Get all members for this room, includes invited, joined and left members.
Note: This method will fetch the members from the homeserver if the member list isn’t synchronized due to member lazy loading. Because of that it might panic if it isn’t run on a tokio thread.
Use members_no_sync() if you want a method that doesn’t do any requests.
sourcepub async fn members_no_sync(&self) -> Result<Vec<RoomMember>>
pub async fn members_no_sync(&self) -> Result<Vec<RoomMember>>
Get all members for this room, includes invited, joined and left members.
Note: This method will not fetch the members from the homeserver if the member list isn’t synchronized due to member lazy loading. Thus, members could be missing.
Use members() if you want to ensure to always get the full member list.
sourcepub async fn get_state_events(
&self,
event_type: StateEventType
) -> Result<Vec<Raw<AnySyncStateEvent>>>
pub async fn get_state_events(
&self,
event_type: StateEventType
) -> Result<Vec<Raw<AnySyncStateEvent>>>
Get all state events of a given type in this room.
sourcepub async fn get_state_events_static<C>(
&self
) -> Result<Vec<Raw<SyncStateEvent<C>>>> where
C: StaticEventContent + StateEventContent + RedactContent,
C::Redacted: StateEventContent + RedactedEventContent,
pub async fn get_state_events_static<C>(
&self
) -> Result<Vec<Raw<SyncStateEvent<C>>>> where
C: StaticEventContent + StateEventContent + RedactContent,
C::Redacted: StateEventContent + RedactedEventContent,
Get all state events of a given statically-known type in this room.
Example
use matrix_sdk::ruma::{events::room::member::SyncRoomMemberEvent, serde::Raw};
let room_members: Vec<Raw<SyncRoomMemberEvent>> = room.get_state_events_static().await?;
sourcepub async fn get_state_event(
&self,
event_type: StateEventType,
state_key: &str
) -> Result<Option<Raw<AnySyncStateEvent>>>
pub async fn get_state_event(
&self,
event_type: StateEventType,
state_key: &str
) -> Result<Option<Raw<AnySyncStateEvent>>>
Get a specific state event in this room.
sourcepub async fn get_state_event_static<C>(
&self,
state_key: &str
) -> Result<Option<Raw<SyncStateEvent<C>>>> where
C: StaticEventContent + StateEventContent + RedactContent,
C::Redacted: StateEventContent + RedactedEventContent,
pub async fn get_state_event_static<C>(
&self,
state_key: &str
) -> Result<Option<Raw<SyncStateEvent<C>>>> where
C: StaticEventContent + StateEventContent + RedactContent,
C::Redacted: StateEventContent + RedactedEventContent,
Get a specific state event of statically-known type in this room.
Example
use matrix_sdk::ruma::events::room::power_levels::SyncRoomPowerLevelsEvent;
let power_levels: SyncRoomPowerLevelsEvent = room
.get_state_event_static("").await?
.expect("every room has a power_levels event")
.deserialize()?;
sourcepub async fn account_data(
&self,
data_type: RoomAccountDataEventType
) -> Result<Option<Raw<AnyRoomAccountDataEvent>>>
pub async fn account_data(
&self,
data_type: RoomAccountDataEventType
) -> Result<Option<Raw<AnyRoomAccountDataEvent>>>
Get account data in this room.
sourcepub async fn account_data_static<C>(
&self
) -> Result<Option<Raw<RoomAccountDataEvent<C>>>> where
C: StaticEventContent + RoomAccountDataEventContent,
pub async fn account_data_static<C>(
&self
) -> Result<Option<Raw<RoomAccountDataEvent<C>>>> where
C: StaticEventContent + RoomAccountDataEventContent,
Get account data of statically-known type in this room.
Example
use matrix_sdk::ruma::events::fully_read::FullyReadEventContent;
match room.account_data_static::<FullyReadEventContent>().await? {
Some(fully_read) => println!("Found read marker: {:?}", fully_read.deserialize()?),
None => println!("No read marker for this room"),
}
sourcepub async fn contains_only_verified_devices(&self) -> Result<bool>
Available on crate feature e2e-encryption
only.
pub async fn contains_only_verified_devices(&self) -> Result<bool>
e2e-encryption
only.Check if all members of this room are verified and all their devices are verified.
Returns true if all devices in the room are verified, otherwise false.
sourcepub async fn set_tag(
&self,
tag: TagName,
tag_info: TagInfo
) -> HttpResult<Response>
pub async fn set_tag(
&self,
tag: TagName,
tag_info: TagInfo
) -> HttpResult<Response>
Adds a tag to the room, or updates it if it already exists.
Returns the [create_tag::v3::Response
] from the server.
Arguments
-
tag
- The tag to add or update. -
tag_info
- Information about the tag, generally containing theorder
parameter.
Example
use matrix_sdk::ruma::events::tag::TagInfo;
if let Some(room) = client.get_joined_room(&room_id) {
let mut tag_info = TagInfo::new();
tag_info.order = Some(0.9);
let user_tag = UserTagName::from_str("u.work")?;
room.set_tag(TagName::User(user_tag), tag_info ).await?;
}
sourcepub async fn remove_tag(&self, tag: TagName) -> HttpResult<Response>
pub async fn remove_tag(&self, tag: TagName) -> HttpResult<Response>
Removes a tag from the room.
Returns the [delete_tag::v3::Response
] from the server.
Arguments
tag
- The tag to remove.
sourcepub async fn set_is_direct(&self, is_direct: bool) -> Result<()>
pub async fn set_is_direct(&self, is_direct: bool) -> Result<()>
Sets whether this room is a DM.
When setting this room as DM, it will be marked as DM for all active members of the room. When unsetting this room as DM, it will be unmarked as DM for all users, not just the members.
Arguments
is_direct
- Whether to mark this room as direct.
sourcepub async fn decrypt_event(
&self,
event: &OriginalSyncRoomEncryptedEvent
) -> Result<RoomEvent>
Available on crate feature e2e-encryption
only.
pub async fn decrypt_event(
&self,
event: &OriginalSyncRoomEncryptedEvent
) -> Result<RoomEvent>
e2e-encryption
only.Tries to decrypt a room event.
Arguments
event
- The room event to be decrypted.
Returns the decrypted event.
Methods from Deref<Target = BaseRoom>
sourcepub fn own_user_id(&self) -> &UserId
pub fn own_user_id(&self) -> &UserId
Get our own user id.
sourcepub fn unread_notification_counts(&self) -> UnreadNotificationsCount
pub fn unread_notification_counts(&self) -> UnreadNotificationsCount
Get the unread notification counts.
sourcepub fn are_members_synced(&self) -> bool
pub fn are_members_synced(&self) -> bool
Check if the room has it’s 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 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 canonical_alias(&self) -> Option<OwnedRoomAliasId>
pub fn canonical_alias(&self) -> Option<OwnedRoomAliasId>
Get the canonical alias of this room.
sourcepub fn create_content(&self) -> Option<RoomCreateEventContent>
pub fn create_content(&self) -> Option<RoomCreateEventContent>
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.
It can also be redacted in current room versions, leaving only the
creator
field.
sourcepub fn direct_targets(&self) -> HashSet<OwnedUserId, RandomState>
pub fn direct_targets(&self) -> HashSet<OwnedUserId, RandomState>
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.
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 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 async fn display_name(&'_ self) -> Result<DisplayName, StoreError>
pub async fn display_name(&'_ self) -> Result<DisplayName, StoreError>
Calculate the canonical display name of the room, taking into account its name, aliases and members.
The display name is calculated according to this algorithm.
sourcepub async fn joined_user_ids(
&'_ self
) -> Result<Vec<OwnedUserId, Global>, StoreError>
pub async fn joined_user_ids(
&'_ self
) -> Result<Vec<OwnedUserId, Global>, StoreError>
Get the list of users ids that are considered to be joined members of this room.
sourcepub async fn members(&'_ self) -> Result<Vec<RoomMember, Global>, StoreError>
pub async fn members(&'_ self) -> Result<Vec<RoomMember, Global>, StoreError>
Get the all RoomMember
s of this room that are known to the store.
sourcepub async fn joined_members(
&'_ self
) -> Result<Vec<RoomMember, Global>, StoreError>
pub async fn joined_members(
&'_ self
) -> Result<Vec<RoomMember, Global>, StoreError>
Get the list of RoomMember
s that are considered to be joined members
of this room.
sourcepub async fn active_members(
&'_ self
) -> Result<Vec<RoomMember, Global>, StoreError>
pub async fn active_members(
&'_ self
) -> Result<Vec<RoomMember, Global>, StoreError>
Get the list of RoomMember
s that are considered to be joined or
invited members of this room.
sourcepub fn clone_info(&self) -> RoomInfo
pub fn clone_info(&self) -> RoomInfo
Clone the inner RoomInfo
sourcepub fn update_summary(&self, summary: RoomInfo)
pub fn update_summary(&self, summary: RoomInfo)
Update the summary with given RoomInfo
sourcepub async fn get_member(
&'_ self,
user_id: &'_ UserId
) -> Result<Option<RoomMember>, StoreError>
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.
Get the Tags
for this room.
sourcepub async fn user_read_receipt(
&'_ self,
user_id: &'_ UserId
) -> Result<Option<(OwnedEventId, Receipt)>, StoreError>
pub async fn user_read_receipt(
&'_ self,
user_id: &'_ UserId
) -> Result<Option<(OwnedEventId, Receipt)>, StoreError>
Get the read receipt as a EventId
and Receipt
tuple for the given
user_id
in this room.
sourcepub async fn event_read_receipts(
&'_ self,
event_id: &'_ EventId
) -> Result<Vec<(OwnedUserId, Receipt), Global>, StoreError>
pub async fn event_read_receipts(
&'_ self,
event_id: &'_ EventId
) -> Result<Vec<(OwnedUserId, Receipt), Global>, StoreError>
Get the read receipts as a list of UserId
and Receipt
tuples for the
given event_id
in this room.
Trait Implementations
Auto Trait Implementations
impl !RefUnwindSafe for Left
impl Send for Left
impl Sync for Left
impl Unpin for Left
impl !UnwindSafe for Left
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<T> Instrument for T
impl<T> Instrument for T
sourcefn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
sourcefn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
impl<T> Pointable for T
impl<T> Pointable for T
sourceimpl<T> ToOwned for T where
T: Clone,
impl<T> ToOwned for T where
T: Clone,
type Owned = T
type Owned = T
The resulting type after obtaining ownership.
sourcefn clone_into(&self, target: &mut T)
fn clone_into(&self, target: &mut T)
toowned_clone_into
)Uses borrowed data to replace owned data, usually by cloning. Read more
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
fn vzip(self) -> V
sourceimpl<T> WithSubscriber for T
impl<T> WithSubscriber for T
sourcefn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> where
S: Into<Dispatch>,
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
sourcefn with_current_subscriber(self) -> WithDispatch<Self>
fn with_current_subscriber(self) -> WithDispatch<Self>
Attaches the current default Subscriber
to this type, returning a
WithDispatch
wrapper. Read more