Struct RoomClient

Source
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 T

A reference to a MatrixRequestable type.

Implementations§

Source§

impl<'a, 'b, 'c, R> RoomClient<'a, 'b, 'c, R>

Source

pub fn send( &mut self, msg: Message, ) -> impl Future<Item = SendReply, Error = MatrixError>

Sends a message to this room.

Source

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.

Source

pub fn send_html<T, U>( &mut self, msg: T, unformatted: U, ) -> impl Future<Item = SendReply, Error = MatrixError>
where T: Into<String>, U: Into<Option<String>>,

Wrapper function that sends a Message::Notice with the specified HTML-formatted text (and accompanying unformatted text, if given) to this room.

Source

pub fn read_receipt( &mut self, eventid: &str, ) -> impl Future<Item = (), Error = MatrixError>

Send a read receipt for a given event ID.

Source

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

Source

pub fn get_typed_state_opt<T: DeserializeOwned + 'static>( &mut self, ev_type: &str, key: Option<&str>, ) -> impl Future<Item = Option<T>, Error = MatrixError>

Source

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.

Source

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.

Source

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)

Source

pub fn get_members( &mut self, ) -> impl Future<Item = ChunkReply, Error = MatrixError>

Get the list of member events for this room.

Source

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.

Source

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 a prev_batch token returned for each room by the sync API, or from a start or end token 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)
Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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!)

Source

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> 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
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

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.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

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>,

Source§

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.