Skip to main content

RoomMember

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::{
    Client, RoomMemberships, media::MediaFormat, room::RoomMember,
    ruma::room_id,
};
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 status(&self) -> Option<&StatusProfileField>

Available on crate feature unstable-msc4426 only.

Get the user’s status, if any.

This is the user-set status (emoji + text) taken from the user’s global profile.

Global profiles are only populated when syncing via sliding sync with the profiles extension enabled; this is always None under sync v2.

Source

pub fn call(&self) -> Option<&CallProfileField>

Available on crate feature unstable-msc4426 only.

Get the user’s call indicator, if any.

This indicates the user is currently in a call (and optionally how long they’ve been in it). It is taken from the user’s global profile.

Global profiles are only populated when syncing via sliding sync with the profiles extension enabled; this is always None under sync v2.

Source

pub fn normalized_power_level(&self) -> UserPowerLevel

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 that are not Infinite are always in the range of 0-100.

Source

pub fn power_level(&self) -> UserPowerLevel

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

Source

pub fn is_service_member(&self) -> bool

Is the room member a service member.

Trait Implementations§

Source§

impl Clone for RoomMember

Source§

fn clone(&self) -> RoomMember

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · 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> Any for T
where T: Any,

Source§

impl<T> AsyncTraitDeps for T

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

Source§

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

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

impl<T> CompatExt for T

§

fn compat(self) -> Compat<T>
where T: Sized,

Applies the [Compat] adapter by value. Read more
§

fn compat_ref(&self) -> Compat<&T>

Applies the [Compat] adapter by shared reference. Read more
§

fn compat_mut(&mut self) -> Compat<&mut T>

Applies the [Compat] adapter by mutable reference. Read more
Source§

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

Source§

fn into_any(self: Box<T>) -> Box<dyn Any>

Converts Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>, which can then be downcast into Box<dyn ConcreteType> where ConcreteType implements Trait.
Source§

fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>

Converts Rc<Trait> (where Trait: Downcast) to Rc<Any>, which can then be further downcast into Rc<ConcreteType> where ConcreteType implements Trait.
Source§

fn as_any(&self) -> &(dyn Any + 'static)

Converts &Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &Any’s vtable from &Trait’s.
Source§

fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)

Converts &mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &mut Any’s vtable from &mut Trait’s.
Source§

impl<T> DowncastSend for T
where T: Any + Send,

Source§

fn into_any_send(self: Box<T>) -> Box<dyn Any + Send>

Converts Box<Trait> (where Trait: DowncastSend) to Box<dyn Any + Send>, which can then be downcast into Box<ConcreteType> where ConcreteType implements Trait.
Source§

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

Source§

fn into_any_sync(self: Box<T>) -> Box<dyn Any + Sync + Send>

Converts Box<Trait> (where Trait: DowncastSync) to Box<dyn Any + Send + Sync>, which can then be downcast into Box<ConcreteType> where ConcreteType implements Trait.
Source§

fn into_any_arc(self: Arc<T>) -> Arc<dyn Any + Sync + Send>

Converts Arc<Trait> (where Trait: DowncastSync) to Arc<Any>, which can then be downcast into Arc<ConcreteType> where ConcreteType implements Trait.
Source§

impl<T> DropFlavorWrapper<T> for T

Source§

type Flavor = MayDrop

The DropFlavor that wraps T into Self
Source§

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

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

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

Source§

fn from_ref(input: &T) -> T

Converts to this type from a reference to the input type.
Source§

impl<T> Fruit for T
where T: Send + Downcast,

§

impl<T, UT> HandleAlloc<UT> for T
where T: Send + Sync,

§

fn new_handle(value: Arc<T>) -> Handle

Create a new handle for an Arc value Read more
§

unsafe fn clone_handle(handle: Handle) -> Handle

Clone a handle Read more
§

unsafe fn consume_handle(handle: Handle) -> Arc<T>

Consume a handle, getting back the initial Arc<> Read more
§

unsafe fn get_arc(handle: Handle) -> Arc<Self>

Get a clone of the Arc<> using a “borrowed” handle. Read more
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>).
§

impl<T> Instrument for T

§

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

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

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
§

impl<T> JsonCastable<CanonicalJsonValue> for T

§

impl<T> JsonCastable<Value> for T

Source§

impl<T> MaybeSendSync for T

Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

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

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

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. 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> SendOutsideWasm for T
where T: Send,

Source§

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

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<S, T> Upcast<T> for S
where T: UpcastFrom<S> + ?Sized, S: ?Sized,

Source§

fn upcast(&self) -> &T
where Self: ErasableGeneric, T: Sized + ErasableGeneric<Repr = Self::Repr>,

Perform a zero-cost type-safe upcast to a wider ref type within the Wasm bindgen generics type system. Read more
Source§

fn upcast_into(self) -> T
where Self: Sized + ErasableGeneric, T: Sized + ErasableGeneric<Repr = Self::Repr>,

Perform a zero-cost type-safe upcast to a wider type within the Wasm bindgen generics type system. Read more
Source§

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

Source§

fn vzip(self) -> V

§

impl<T> WithSubscriber for T

§

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
§

fn with_current_subscriber(self) -> WithDispatch<Self>

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