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,
§impl<T> CompatExt for T
impl<T> CompatExt for T
Source§impl<T> FutureExt for T
impl<T> FutureExt for T
Source§fn with_context(self, otel_cx: Context) -> WithContext<Self>
fn with_context(self, otel_cx: Context) -> WithContext<Self>
Source§fn with_current_context(self) -> WithContext<Self>
fn with_current_context(self) -> WithContext<Self>
Source§impl<T, UT> HandleAlloc<UT> for T
impl<T, UT> HandleAlloc<UT> for T
Source§fn consume_handle(handle: Handle) -> Arc<T>
fn consume_handle(handle: Handle) -> Arc<T>
Arc<>
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,
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§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