Struct matrix_sdk_ui::timeline::EventTimelineItem

source ·
pub struct EventTimelineItem { /* private fields */ }
Expand description

An item in the timeline that represents at least one event.

There is always one main event that gives the EventTimelineItem its identity but in many cases, additional events like reactions and edits are also part of the item.

Implementations§

source§

impl EventTimelineItem

source

pub async fn from_latest_event( client: Client, room_id: &RoomId, latest_event: LatestEvent, ) -> Option<EventTimelineItem>

If the supplied low-level SyncTimelineEvent is suitable for use as the latest_event in a message preview, wrap it as an EventTimelineItem.

Note: Timeline items created via this constructor do not produce the correct ShieldState when calling get_shield. This is because they are intended for display in the room list which a) is unlikely to show shields and b) would incur a significant performance overhead.

source

pub fn is_local_echo(&self) -> bool

Check whether this item is a local echo.

This returns true for events created locally, until the server echoes back the full event as part of a sync response.

This is the opposite of Self::is_remote_event.

source

pub fn is_remote_event(&self) -> bool

Check whether this item is a remote event.

This returns true only for events that have been echoed back from the homeserver. A local echo sent but not echoed back yet will return false here.

This is the opposite of Self::is_local_echo.

source

pub fn send_state(&self) -> Option<&EventSendState>

Get the event’s send state of a local echo.

source

pub fn identifier(&self) -> TimelineEventItemId

Get the unique identifier of this item.

Returns the transaction ID for a local echo item that has not been sent and the event ID for a local echo item that has been sent or a remote item.

source

pub fn transaction_id(&self) -> Option<&TransactionId>

Get the transaction ID of a local echo item.

The transaction ID is currently only kept until the remote echo for a local event is received.

source

pub fn event_id(&self) -> Option<&EventId>

Get the event ID of this item.

If this returns Some(_), the event was successfully created by the server.

Even if this is a local event, this can be Some(_) as the event ID can be known not just from the remote echo via sync_events, but also from the response of the send request that created the event.

source

pub fn sender(&self) -> &UserId

Get the sender of this item.

source

pub fn sender_profile(&self) -> &TimelineDetails<Profile>

Get the profile of the sender.

source

pub fn content(&self) -> &TimelineItemContent

Get the content of this item.

source

pub fn reactions(&self) -> &ReactionsByKeyBySender

Get the reactions of this item.

source

pub fn read_receipts(&self) -> &IndexMap<OwnedUserId, Receipt>

Get the read receipts of this item.

The key is the ID of a room member and the value are details about the read receipt.

Note that currently this ignores threads.

source

pub fn timestamp(&self) -> MilliSecondsSinceUnixEpoch

Get the timestamp of this item.

If this event hasn’t been echoed back by the server yet, returns the time the local event was created. Otherwise, returns the origin server timestamp.

source

pub fn is_own(&self) -> bool

Whether this timeline item was sent by the logged-in user themselves.

source

pub fn is_editable(&self) -> bool

Flag indicating this timeline item can be edited by the current user.

source

pub fn is_highlighted(&self) -> bool

Whether the event should be highlighted in the timeline.

source

pub fn encryption_info(&self) -> Option<&EncryptionInfo>

Get the encryption information for the event, if any.

source

pub fn get_shield(&self, strict: bool) -> Option<ShieldState>

Gets the ShieldState which can be used to decorate messages in the recommended way.

source

pub fn can_be_replied_to(&self) -> bool

Check whether this item can be replied to.

source

pub fn original_json(&self) -> Option<&Raw<AnySyncTimelineEvent>>

Get the raw JSON representation of the initial event (the one that caused this timeline item to be created).

Returns None if this event hasn’t been echoed back by the server yet.

source

pub fn latest_edit_json(&self) -> Option<&Raw<AnySyncTimelineEvent>>

Get the raw JSON representation of the latest edit, if any.

source

pub fn latest_json(&self) -> Option<&Raw<AnySyncTimelineEvent>>

Shorthand for item.latest_edit_json().or_else(|| item.original_json()).

source

pub fn origin(&self) -> Option<EventItemOrigin>

Get the origin of the event, i.e. where it came from.

May return None in some edge cases that are subject to change.

source

pub fn with_reactions(&self, reactions: ReactionsByKeyBySender) -> Self

Clone the current event item, and update its reactions.

source

pub fn replied_to_info(&self) -> Result<RepliedToInfo, UnsupportedReplyItem>

Gives the information needed to reply to the event of the item.

source

pub fn local_echo_send_handle(&self) -> Option<SendHandle>

For local echoes, return the associated send handle.

Trait Implementations§

source§

impl Clone for EventTimelineItem

source§

fn clone(&self) -> EventTimelineItem

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 EventTimelineItem

source§

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

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

impl From<EventTimelineItem> for TimelineItemKind

source§

fn from(item: EventTimelineItem) -> Self

Converts to this type from the input type.

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§

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

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

§

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§

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§

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<T> Same for T

§

type Output = T

Should always be Self
source§

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

§

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

§

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

§

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> SendOutsideWasm for T
where T: Send,

source§

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