pub struct RoomClient<'a, 'b: 'a, 'c, T: 'c> {
pub room: &'a Room<'b>,
pub cli: &'c mut T,
}Expand description
A Room with a MatrixRequestable type, which you can use to call endpoints relating
to rooms.
Fields§
§room: &'a Room<'b>A reference to a room.
cli: &'c mut TA reference to a MatrixRequestable type.
Implementations§
Source§impl<'a, 'b, 'c, R> RoomClient<'a, 'b, 'c, R>where
R: MatrixRequestable,
impl<'a, 'b, 'c, R> RoomClient<'a, 'b, 'c, R>where
R: MatrixRequestable,
Sourcepub fn send(
&mut self,
msg: Message,
) -> impl Future<Item = SendReply, Error = MatrixError>
pub fn send( &mut self, msg: Message, ) -> impl Future<Item = SendReply, Error = MatrixError>
Sends a message to this room.
Sourcepub fn send_simple<T: Into<String>>(
&mut self,
msg: T,
) -> impl Future<Item = SendReply, Error = MatrixError>
pub fn send_simple<T: Into<String>>( &mut self, msg: T, ) -> impl Future<Item = SendReply, Error = MatrixError>
Wrapper function that sends a Message::Notice with the specified unformatted text
to this room. Provided for convenience purposes.
Sourcepub fn send_html<T, U>(
&mut self,
msg: T,
unformatted: U,
) -> impl Future<Item = SendReply, Error = MatrixError>
pub fn send_html<T, U>( &mut self, msg: T, unformatted: U, ) -> impl Future<Item = SendReply, Error = MatrixError>
Wrapper function that sends a Message::Notice with the specified HTML-formatted text
(and accompanying unformatted text, if given) to this room.
Sourcepub fn read_receipt(
&mut self,
eventid: &str,
) -> impl Future<Item = (), Error = MatrixError>
pub fn read_receipt( &mut self, eventid: &str, ) -> impl Future<Item = (), Error = MatrixError>
Send a read receipt for a given event ID.
Sourcepub fn get_typed_state<T: DeserializeOwned + 'static>(
&mut self,
ev_type: &str,
key: Option<&str>,
) -> impl Future<Item = T, Error = MatrixError>
pub fn get_typed_state<T: DeserializeOwned + 'static>( &mut self, ev_type: &str, key: Option<&str>, ) -> impl Future<Item = T, Error = MatrixError>
Looks up the contents of a state event with type ev_type and state key
key in a room. If the user is joined to the room then the state is
taken from the current state of the room. If the user has left the room
then the state is taken from the state of the room when they left.
The return value here can be any object that implements Deserialize,
allowing you to use the state API to store arbitrary objects. Common
state events, such as m.room.name, can be found in the content
module (content::room::Name for m.room.name).
If the event was not found, an error will be thrown of type
HttpCode(http::StatusCode::NotFound).
pub fn get_typed_state_opt<T: DeserializeOwned + 'static>( &mut self, ev_type: &str, key: Option<&str>, ) -> impl Future<Item = Option<T>, Error = MatrixError>
Sourcepub fn set_typed_state<T: Serialize>(
&mut self,
ev_type: &str,
key: Option<&str>,
val: T,
) -> impl Future<Item = SetStateReply, Error = MatrixError>
pub fn set_typed_state<T: Serialize>( &mut self, ev_type: &str, key: Option<&str>, val: T, ) -> impl Future<Item = SetStateReply, Error = MatrixError>
State events can be sent using this endpoint. These events will be
overwritten if the ev_type) and key) all
match.
Like get_state, the value here can be any object that implements
Serialize, allowing you to use the state API to store arbitrary
objects. See the get_state docs for more.
Sourcepub fn get_all_state(
&mut self,
) -> impl Future<Item = Vec<Event>, Error = MatrixError>
pub fn get_all_state( &mut self, ) -> impl Future<Item = Vec<Event>, Error = MatrixError>
Get the state events for the current state of a room.
Sourcepub fn get_event(
&mut self,
id: &str,
) -> impl Future<Item = Event, Error = MatrixError>
pub fn get_event( &mut self, id: &str, ) -> impl Future<Item = Event, Error = MatrixError>
Get a single event for this room, based on event_id.
You must have permission to retrieve this event (e.g. by being a member of the room for this event)
Sourcepub fn get_members(
&mut self,
) -> impl Future<Item = ChunkReply, Error = MatrixError>
pub fn get_members( &mut self, ) -> impl Future<Item = ChunkReply, Error = MatrixError>
Get the list of member events for this room.
Sourcepub fn get_joined_members(
&mut self,
) -> impl Future<Item = JoinedMembersReply, Error = MatrixError>
pub fn get_joined_members( &mut self, ) -> impl Future<Item = JoinedMembersReply, Error = MatrixError>
Get the list of joined members in this room.
The current user must be in the room for it to work, unless it is an Application Service, in which case any of the AS’s users must be in the room.
This API is primarily for Application Services and should be faster to
respond than get_members(), as it can be implemented more efficiently
on the server.
Sourcepub fn get_messages(
&mut self,
from: &str,
to: Option<&str>,
backward: bool,
limit: Option<u32>,
) -> impl Future<Item = MessagesReply, Error = MatrixError>
pub fn get_messages( &mut self, from: &str, to: Option<&str>, backward: bool, limit: Option<u32>, ) -> impl Future<Item = MessagesReply, Error = MatrixError>
This API returns a list of message and state events for a room. It uses pagination query parameters to paginate history in the room.
§Parameters
from: The token to start returning events from. This token can be obtained from aprev_batchtoken returned for each room by the sync API, or from astartorendtoken returned by a previous request to this endpoint.to: The token to stop returning events at. This token can be obtained from a prev_batch token returned for each room by the sync endpoint, or from a start or end token returned by a previous request to this endpoint.backward: Whether to paginate backward, or forward; true = back-pagination.limit: The maximum number of events to return. (default: 10)
Sourcepub fn redact(
&mut self,
eventid: &str,
reason: Option<&str>,
) -> impl Future<Item = (), Error = MatrixError>
pub fn redact( &mut self, eventid: &str, reason: Option<&str>, ) -> impl Future<Item = (), Error = MatrixError>
Strips all information out of an event which isn’t critical to the integrity of the server-side representation of the room.
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.
Sourcepub fn typing(
&mut self,
typing: bool,
timeout: Option<usize>,
) -> impl Future<Item = (), Error = MatrixError>
pub fn typing( &mut self, typing: bool, timeout: Option<usize>, ) -> impl Future<Item = (), Error = MatrixError>
This tells the server that the user is typing for the next N milliseconds where N is the value specified in the timeout key. Alternatively, if typing is false, it tells the server that the user has stopped typing.
Sourcepub fn join(&mut self) -> impl Future<Item = (), Error = MatrixError>
pub fn join(&mut self) -> impl Future<Item = (), Error = MatrixError>
This API starts a user participating in a particular room, if that user is allowed to participate in that room. After this call, the client is allowed to see all current state events in the room, and all subsequent events associated with the room until the user leaves the room.
After a user has joined a room, the room will appear as an entry in the
values in the SyncStream.
Sourcepub fn leave(&mut self) -> impl Future<Item = (), Error = MatrixError>
pub fn leave(&mut self) -> impl Future<Item = (), Error = MatrixError>
This API stops a user participating in a particular room.
If the user was already in the room, they will no longer be able to see new events in the room. If the room requires an invite to join, they will need to be re-invited before they can re-join.
If the user was invited to the room, but had not joined, this call serves to reject the invite.
The user will still be allowed to retrieve history from the room which they were previously allowed to see.
Sourcepub fn forget(&mut self) -> impl Future<Item = (), Error = MatrixError>
pub fn forget(&mut self) -> impl Future<Item = (), Error = MatrixError>
This API stops a user remembering about a particular room.
In general, history is a first class citizen in Matrix. After this API is called, however, a user will no longer be able to retrieve history for this room. If all users on a homeserver forget a room, the room is eligible for deletion from that homeserver.
If the user is currently joined to the room, they will implicitly leave the room as part of this API call.
Sourcepub fn kick_user(
&mut self,
user_id: &str,
reason: Option<&str>,
) -> impl Future<Item = (), Error = MatrixError>
pub fn kick_user( &mut self, user_id: &str, reason: Option<&str>, ) -> impl Future<Item = (), Error = MatrixError>
Kick a user from the room.
The caller must have the required power level in order to perform this operation.
Sourcepub fn ban_user(
&mut self,
user_id: &str,
reason: Option<&str>,
) -> impl Future<Item = (), Error = MatrixError>
pub fn ban_user( &mut self, user_id: &str, reason: Option<&str>, ) -> impl Future<Item = (), Error = MatrixError>
Ban a user in the room. If the user is currently in the room, also kick them.
When a user is banned from a room, they may not join it or be invited to it until they are unbanned.
The caller must have the required power level in order to perform this operation.
Sourcepub fn unban_user(
&mut self,
user_id: &str,
) -> impl Future<Item = (), Error = MatrixError>
pub fn unban_user( &mut self, user_id: &str, ) -> impl Future<Item = (), Error = MatrixError>
Unban a user from the room. This allows them to be invited to the room, and join if they would otherwise be allowed to join according to its join rules.
The caller must have the required power level in order to perform this operation.
Sourcepub fn invite_user(
&mut self,
user_id: &str,
) -> impl Future<Item = (), Error = MatrixError>
pub fn invite_user( &mut self, user_id: &str, ) -> impl Future<Item = (), Error = MatrixError>
This API invites a user to participate in a particular room. They do not start participating in the room until they actually join the room.
Only users currently in a particular room can invite other users to join that room.
If the user was invited to the room, the homeserver will append a m.room.member event to the room.
Note that there are two forms of this API, which are documented separately. This version of the API requires that the inviter knows the Matrix identifier of the invitee. The other is documented in the third party invites section of the Matrix spec, and is not implemented in Glitch in the Matrix (yet!)
Sourcepub fn get_user_power_level(
&mut self,
user_id: String,
) -> impl Future<Item = u32, Error = MatrixError>
pub fn get_user_power_level( &mut self, user_id: String, ) -> impl Future<Item = u32, Error = MatrixError>
Get a user’s power level, falling back on the default value for the room if not present.
The user_id is a String here, not a &str, because it is stored in
a future that outlives this function.
Auto Trait Implementations§
impl<'a, 'b, 'c, T> Freeze for RoomClient<'a, 'b, 'c, T>
impl<'a, 'b, 'c, T> RefUnwindSafe for RoomClient<'a, 'b, 'c, T>where
T: RefUnwindSafe,
impl<'a, 'b, 'c, T> Send for RoomClient<'a, 'b, 'c, T>where
T: Send,
impl<'a, 'b, 'c, T> Sync for RoomClient<'a, 'b, 'c, T>where
T: Sync,
impl<'a, 'b, 'c, T> Unpin for RoomClient<'a, 'b, 'c, T>
impl<'a, 'b, 'c, T> !UnwindSafe for RoomClient<'a, 'b, 'c, T>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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