Struct matrix_sdk::room::Common [−][src]
pub struct Common { /* fields omitted */ }
Expand description
A struct containing methods that are common for Joined, Invited and Left Rooms
Implementations
Create a new room::Common
Arguments
-
client
- The client used to make requests. -
room
- The underlying room.
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).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);
}
Sends a request to /_matrix/client/r0/rooms/{room_id}/messages
and
returns a get_message_events::Response
that contains a chunk of
room and state events (AnyRoomEvent
and AnyStateEvent
).
Arguments
request
- The easiest way to create this request is using theget_message_events::Request
itself.
Examples
use matrix_sdk::Client;
let room_id = room_id!("!roomid:example.com");
let request = MessagesRequest::backward(&room_id, "t47429-4392820_219380_26003_2265");
let mut client = Client::new(homeserver).unwrap();
assert!(room.messages(request).await.is_ok());
Sends a request to /_matrix/client/r0/rooms/{roomId}/event/{eventId}
and returns a get_room_event::Response
that contains a event
(AnyRoomEvent
).
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
.
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.
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() if you want to ensure to always get the full member list.
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.
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.
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.
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.
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.
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.
pub async fn get_state_events(
&self,
event_type: EventType
) -> Result<Vec<Raw<AnySyncStateEvent>>>
pub async fn get_state_events(
&self,
event_type: EventType
) -> Result<Vec<Raw<AnySyncStateEvent>>>
Get all state events of a given type in this room.
pub async fn get_state_event(
&self,
event_type: EventType,
state_key: &str
) -> Result<Option<Raw<AnySyncStateEvent>>>
pub async fn get_state_event(
&self,
event_type: EventType,
state_key: &str
) -> Result<Option<Raw<AnySyncStateEvent>>>
Get a specific state event in this room.
This is supported on encryption
only.
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.
Methods from Deref<Target = BaseRoom>
Get our own user id.
Get the unread notification counts.
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.
Get the prev_batch
token that was received from the last sync. May be
None
if the last sync contained the full room history.
Get the avatar url of this room.
Get the canonical alias of this room.
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.
If this room is a direct message, get the member that we’re sharing the room with.
Note: The member list might have been modified in the meantime and the target might not even be in the room anymore. This setting should only be considered as guidance.
Is the room encrypted.
Get the m.room.encryption
content that enabled end to end encryption
in the room.
Get the guest access policy of this room.
Get the history visibility policy of this room.
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.
Has the room been tombstoned.
Get the m.room.tombstone
content of this room if there is one.
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.
Get the list of users ids that are considered to be joined members of this room.
Get the all RoomMember
s of this room that are known to the store.
Get the list of RoomMember
s that are considered to be joined members
of this room.
Get the list of RoomMember
s that are considered to be joined or
invited members of this room.
pub 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.
pub async fn user_read_receipt(
&'_ self,
user_id: &'_ UserId
) -> Result<Option<(EventId, Receipt)>, StoreError>
pub async fn user_read_receipt(
&'_ self,
user_id: &'_ UserId
) -> Result<Option<(EventId, Receipt)>, StoreError>
Get the read receipt as a EventId
and Receipt
tuple for the given
user_id
in this room.
pub async fn event_read_receipts(
&'_ self,
event_id: &'_ EventId
) -> Result<Vec<(UserId, Receipt), Global>, StoreError>
pub async fn event_read_receipts(
&'_ self,
event_id: &'_ EventId
) -> Result<Vec<(UserId, 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 Common
impl !UnwindSafe for Common
Blanket Implementations
Mutably borrows from an owned value. Read more
Instruments this type with the provided Span
, returning an
Instrumented
wrapper. Read more