matrix_sdk::room

Struct RoomMember

Source
pub struct RoomMember { /* private fields */ }
Expand description

The high-level RoomMember representation

Implementations§

Source§

impl RoomMember

Source

pub async fn avatar(&self, format: MediaFormat) -> Result<Option<Vec<u8>>>

Gets the avatar of this member, 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.
§Examples
use matrix_sdk::{
    media::MediaFormat, room::RoomMember, ruma::room_id, Client,
    RoomMemberships,
};
let client = Client::new(homeserver).await.unwrap();
client.matrix_auth().login_username(user, "password").send().await.unwrap();
let room_id = room_id!("!roomid:example.com");
let room = client.get_room(&room_id).unwrap();
let members = room.members(RoomMemberships::empty()).await.unwrap();
let member = members.first().unwrap();
if let Some(avatar) = member.avatar(MediaFormat::File).await.unwrap() {
    std::fs::write("avatar.png", avatar);
}
Source

pub async fn ignore(&self) -> Result<()>

Adds the room member to the current account data’s ignore list which will ignore the user across all rooms.

Source

pub async fn unignore(&self) -> Result<()>

Removes the room member from the current account data’s ignore list which will unignore the user across all rooms.

Source

pub fn is_account_user(&self) -> bool

Returns true if the member of the room is the user of the account

Source

pub fn suggested_role_for_power_level(&self) -> RoomMemberRole

Get the suggested role of this member based on their power level.

Methods from Deref<Target = BaseRoomMember>§

Source

pub fn user_id(&self) -> &UserId

Get the unique user id of this member.

Source

pub fn event(&self) -> &Arc<SyncOrStrippedState<RoomMemberEventContent>>

Get the original member event

Source

pub fn display_name(&self) -> Option<&str>

Get the display name of the member if there is one.

Source

pub fn name(&self) -> &str

Get the name of the member.

This returns either the display name or the local part of the user id if the member didn’t set a display name.

Source

pub fn avatar_url(&self) -> Option<&MxcUri>

Get the avatar url of the member, if there is one.

Source

pub fn normalized_power_level(&self) -> i64

Get the normalized power level of this member.

The normalized power level depends on the maximum power level that can be found in a certain room, positive values are always in the range of 0-100.

Source

pub fn power_level(&self) -> i64

Get the power level of this member.

Source

pub fn can_ban(&self) -> bool

Whether this user can ban other users based on the power levels.

Same as member.can_do(PowerLevelAction::Ban).

Source

pub fn can_invite(&self) -> bool

Whether this user can invite other users based on the power levels.

Same as member.can_do(PowerLevelAction::Invite).

Source

pub fn can_kick(&self) -> bool

Whether this user can kick other users based on the power levels.

Same as member.can_do(PowerLevelAction::Kick).

Source

pub fn can_redact_own(&self) -> bool

Whether this user can redact their own events based on the power levels.

Same as member.can_do(PowerLevelAction::RedactOwn).

Source

pub fn can_redact_other(&self) -> bool

Whether this user can redact events of other users based on the power levels.

Same as member.can_do(PowerLevelAction::RedactOther).

Source

pub fn can_send_message(&self, msg_type: MessageLikeEventType) -> bool

Whether this user can send message events based on the power levels.

Same as member.can_do(PowerLevelAction::SendMessage(msg_type)).

Source

pub fn can_send_state(&self, state_type: StateEventType) -> bool

Whether this user can send state events based on the power levels.

Same as member.can_do(PowerLevelAction::SendState(state_type)).

Source

pub fn can_pin_or_unpin_event(&self) -> bool

Whether this user can pin or unpin events based on the power levels.

Source

pub fn can_trigger_room_notification(&self) -> bool

Whether this user can notify everybody in the room by writing @room in a message.

Same as member. can_do(PowerLevelAction::TriggerNotification(NotificationPowerLevelType::Room)).

Source

pub fn can_do(&self, action: PowerLevelAction) -> bool

Whether this user can do the given action based on the power levels.

Source

pub fn name_ambiguous(&self) -> bool

Is the name that the member uses ambiguous in the room.

A name is considered to be ambiguous if at least one other member shares the same name.

Source

pub fn membership(&self) -> &MembershipState

Get the membership state of this member.

Source

pub fn is_ignored(&self) -> bool

Is the room member ignored by the current account user

Trait Implementations§

Source§

impl Clone for RoomMember

Source§

fn clone(&self) -> RoomMember

Returns a copy of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for RoomMember

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Deref for RoomMember

Source§

type Target = RoomMember

The resulting type after dereferencing.
Source§

fn deref(&self) -> &Self::Target

Dereferences the value.

Auto Trait Implementations§

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dst: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, W> HasTypeWitness<W> for T
where W: MakeTypeWitness<Arg = T>, T: ?Sized,

Source§

const WITNESS: W = W::MAKE

A constant of the type witness
Source§

impl<T> Identity for T
where T: ?Sized,

Source§

const TYPE_EQ: TypeEq<T, <T as Identity>::Type> = TypeEq::NEW

Proof that Self is the same type as Self::Type, provides methods for casting between Self and Self::Type.
Source§

type Type = T

The same type as Self, used to emulate type equality bounds (T == U) with associated type equality constraints (T: Identity<Type = U>).
Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

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

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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<P, T> Receiver for P
where P: Deref<Target = T> + ?Sized, T: ?Sized,

Source§

type Target = T

🔬This is a nightly-only experimental API. (arbitrary_self_types)
The target type on which the method may be called.
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

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

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. 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.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

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

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

impl<T> Any for T
where T: Any,

Source§

impl<T> AsyncTraitDeps for T

Source§

impl<T> CloneAny for T
where T: Any + Clone,

Source§

impl<T> CloneAnySend for T
where T: Any + Send + Clone,

Source§

impl<T> CloneAnySendSync for T
where T: Any + Send + Sync + Clone,

Source§

impl<T> CloneAnySync for T
where T: Any + Sync + Clone,

Source§

impl<T> ErasedDestructor for T
where T: 'static,

Source§

impl<T> MaybeSendSync for T

Source§

impl<T> SendOutsideWasm for T
where T: Send,

Source§

impl<T> SyncOutsideWasm for T
where T: Sync,