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
impl EventTimelineItem
sourcepub async fn from_latest_event(
client: Client,
room_id: &RoomId,
latest_event: LatestEvent,
) -> Option<EventTimelineItem>
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.
sourcepub fn is_local_echo(&self) -> bool
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
.
sourcepub fn is_remote_event(&self) -> bool
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
.
sourcepub fn send_state(&self) -> Option<&EventSendState>
pub fn send_state(&self) -> Option<&EventSendState>
Get the event’s send state of a local echo.
sourcepub fn identifier(&self) -> TimelineEventItemId
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.
sourcepub fn transaction_id(&self) -> Option<&TransactionId>
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.
sourcepub fn event_id(&self) -> Option<&EventId>
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.
sourcepub fn sender_profile(&self) -> &TimelineDetails<Profile>
pub fn sender_profile(&self) -> &TimelineDetails<Profile>
Get the profile of the sender.
sourcepub fn content(&self) -> &TimelineItemContent
pub fn content(&self) -> &TimelineItemContent
Get the content of this item.
sourcepub fn reactions(&self) -> &ReactionsByKeyBySender
pub fn reactions(&self) -> &ReactionsByKeyBySender
Get the reactions of this item.
sourcepub fn read_receipts(&self) -> &IndexMap<OwnedUserId, Receipt>
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.
sourcepub fn timestamp(&self) -> MilliSecondsSinceUnixEpoch
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.
sourcepub fn is_own(&self) -> bool
pub fn is_own(&self) -> bool
Whether this timeline item was sent by the logged-in user themselves.
sourcepub fn is_editable(&self) -> bool
pub fn is_editable(&self) -> bool
Flag indicating this timeline item can be edited by the current user.
sourcepub fn is_highlighted(&self) -> bool
pub fn is_highlighted(&self) -> bool
Whether the event should be highlighted in the timeline.
sourcepub fn encryption_info(&self) -> Option<&EncryptionInfo>
pub fn encryption_info(&self) -> Option<&EncryptionInfo>
Get the encryption information for the event, if any.
sourcepub fn get_shield(&self, strict: bool) -> Option<ShieldState>
pub fn get_shield(&self, strict: bool) -> Option<ShieldState>
Gets the ShieldState
which can be used to decorate messages in the
recommended way.
sourcepub fn can_be_replied_to(&self) -> bool
pub fn can_be_replied_to(&self) -> bool
Check whether this item can be replied to.
sourcepub fn original_json(&self) -> Option<&Raw<AnySyncTimelineEvent>>
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.
sourcepub fn latest_edit_json(&self) -> Option<&Raw<AnySyncTimelineEvent>>
pub fn latest_edit_json(&self) -> Option<&Raw<AnySyncTimelineEvent>>
Get the raw JSON representation of the latest edit, if any.
sourcepub fn latest_json(&self) -> Option<&Raw<AnySyncTimelineEvent>>
pub fn latest_json(&self) -> Option<&Raw<AnySyncTimelineEvent>>
Shorthand for
item.latest_edit_json().or_else(|| item.original_json())
.
sourcepub fn origin(&self) -> Option<EventItemOrigin>
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.
sourcepub fn with_reactions(&self, reactions: ReactionsByKeyBySender) -> Self
pub fn with_reactions(&self, reactions: ReactionsByKeyBySender) -> Self
Clone the current event item, and update its reactions
.
sourcepub fn replied_to_info(&self) -> Result<RepliedToInfo, UnsupportedReplyItem>
pub fn replied_to_info(&self) -> Result<RepliedToInfo, UnsupportedReplyItem>
Gives the information needed to reply to the event of the item.
sourcepub fn local_echo_send_handle(&self) -> Option<SendHandle>
pub fn local_echo_send_handle(&self) -> Option<SendHandle>
For local echoes, return the associated send handle.
Trait Implementations§
source§impl Clone for EventTimelineItem
impl Clone for EventTimelineItem
source§fn clone(&self) -> EventTimelineItem
fn clone(&self) -> EventTimelineItem
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moresource§impl Debug for EventTimelineItem
impl Debug for EventTimelineItem
source§impl From<EventTimelineItem> for TimelineItemKind
impl From<EventTimelineItem> for TimelineItemKind
source§fn from(item: EventTimelineItem) -> Self
fn from(item: EventTimelineItem) -> Self
Auto Trait Implementations§
impl Freeze for EventTimelineItem
impl !RefUnwindSafe for EventTimelineItem
impl Send for EventTimelineItem
impl Sync for EventTimelineItem
impl Unpin for EventTimelineItem
impl !UnwindSafe for EventTimelineItem
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> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§default unsafe fn clone_to_uninit(&self, dst: *mut T)
default unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)source§impl<T, W> HasTypeWitness<W> for Twhere
W: MakeTypeWitness<Arg = T>,
T: ?Sized,
impl<T, W> HasTypeWitness<W> for Twhere
W: MakeTypeWitness<Arg = T>,
T: ?Sized,
source§impl<T> Identity for Twhere
T: ?Sized,
impl<T> Identity for Twhere
T: ?Sized,
source§impl<T> Instrument for T
impl<T> Instrument for T
source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
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