Struct matrix_sdk::room::Joined[][src]

pub struct Joined { /* fields omitted */ }
Expand description

A room in the joined state.

The JoinedRoom contains all methods specific to a Room with type RoomType::Joined. Operations may fail once the underlying Room changes RoomType.

Implementations

Create a new room::Joined if the underlying BaseRoom has type RoomType::Joined.

Arguments

  • client - The client used to make requests.

  • room - The underlying room.

Leave this room.

Ban the user with UserId from this room.

Arguments

  • user_id - The user to ban with UserId.

  • reason - The reason for banning this user.

Kick a user out of this room.

Arguments

  • user_id - The UserId of the user that should be kicked out of the room.

  • reason - Optional reason why the room member is being kicked out.

Invite the specified user by UserId to this room.

Arguments

  • user_id - The UserId of the user to invite to the room.

Invite the specified user by third party id to this room.

Arguments

  • invite_id - A third party id of a user to invite to the room.

Activate typing notice for this room.

The typing notice remains active for 4s. It can be deactivate at any point by setting typing to false. If this method is called while the typing notice is active nothing will happen. This method can be called on every key stroke, since it will do nothing while typing is active.

Arguments

  • typing - Whether the user is typing or has stopped typing.

Examples

use std::time::Duration;
use matrix_sdk::ruma::api::client::r0::typing::create_typing_event::Typing;

room
    .typing_notice(true)
    .await
    .expect("Can't get devices from server");

Send a request to notify this room that the user has read specific event.

Arguments

  • event_id - The EventId specifies the event to set the read receipt on.

Send a request to notify this room that the user has read up to specific event.

Arguments

  • fully_read - The EventId of the event the user has read to.

  • read_receipt - An EventId to specify the event to set the read receipt on.

Send a room message to this room.

Returns the parsed response from the server.

If the encryption feature is enabled this method will transparently encrypt the room message if this room is encrypted.

Arguments

  • content - The content of the message event.

  • txn_id - A unique Uuid that can be attached to a MessageEvent held in its unsigned field as transaction_id. If not given one is created for the message.

Example

use matrix_sdk::ruma::events::{
    AnyMessageEventContent,
    room::message::{MessageEventContent, TextMessageEventContent},
};
use matrix_sdk_common::uuid::Uuid;

let content = AnyMessageEventContent::RoomMessage(
    MessageEventContent::text_plain("Hello world")
);

let txn_id = Uuid::new_v4();
room.send(content, Some(txn_id)).await.unwrap();

Send an attachment to this room.

This will upload the given data that the reader produces using the upload() method and post an event to the given room. If the room is encrypted and the encryption feature is enabled the upload will be encrypted.

This is a convenience method that calls the Client::upload() and afterwards the send().

Arguments

  • body - A textual representation of the media that is going to be uploaded. Usually the file name.

  • content_type - The type of the media, this will be used as the content-type header.

  • reader - A Reader that will be used to fetch the raw bytes of the media.

  • txn_id - A unique Uuid that can be attached to a MessageEvent held in its unsigned field as transaction_id. If not given one is created for the message.

Examples

let path = PathBuf::from("/home/example/my-cat.jpg");
let mut image = File::open(path).unwrap();

room.send_attachment("My favorite cat", &mime::IMAGE_JPEG, &mut image, None)
    .await
    .expect("Can't upload my cat.");

Send a room state event to the homeserver.

Returns the parsed response from the server.

Arguments

  • room_id - The id of the room that should receive the message.

  • content - The content of the state event.

  • state_key - A unique key which defines the overwriting semantics for this piece of room state. This value is often a zero-length string.

Example

use matrix_sdk::ruma::{
    events::{
        AnyStateEventContent,
        room::member::{MemberEventContent, MembershipState},
    },
    assign, mxc_uri,
};

let avatar_url = mxc_uri!("mxc://example.org/avatar");
let member_event = assign!(MemberEventContent::new(MembershipState::Join), {
   avatar_url: Some(avatar_url),
});

let content = AnyStateEventContent::RoomMember(member_event);
room.send_state_event(content, "").await.unwrap();

Strips all information out of an event of the room.

Returns the [redact_event::Response] from the server.

This cannot be undone. Users may redact their own events, and any user with a power level greater than or equal to the redact power level of the room may redact events there.

Arguments

  • event_id - The ID of the event to redact

  • reason - The reason for the event being redacted.

  • txn_id - A unique Uuid that can be attached to this event as its transaction ID. If not given one is created for the message.

Example

let event_id = matrix_sdk::ruma::event_id!("$xxxxxx:example.org");
let reason = Some("Indecent material");
room.redact(&event_id, reason, None).await.unwrap();

Adds a tag to the room, or updates it if it already exists.

Returns the [create_tag::Response] from the server.

Arguments

  • tag - The tag to add or update.

  • tag_info - Information about the tag, generally containing the order parameter.

Example

let mut tag_info = TagInfo::new();
tag_info.order = Some(0.9);
room.set_tag("u.work", tag_info );

Removes a tag from the room.

Returns the [delete_tag::Response] from the server.

Arguments

  • tag - The tag to remove.

Methods from Deref<Target = Common>

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

Get all state events of a given type in this room.

Get a specific state event in this room.

This is supported on 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.

Trait Implementations

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Formats the value using the given formatter. Read more

The resulting type after dereferencing.

Dereferences the value.

Performs the conversion.

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Performs the conversion.

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

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

Performs the conversion.

The alignment of pointer.

The type for initializers.

Initializes a with the given initializer. Read more

Dereferences the given pointer. Read more

Mutably dereferences the given pointer. Read more

Drops the object pointed to by the given pointer. Read more

Should always be Self

The resulting type after obtaining ownership.

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

🔬 This is a nightly-only experimental API. (toowned_clone_into)

recently added

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

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.