pub struct TimelineEvent {
pub kind: TimelineEventKind,
pub timestamp: Option<MilliSecondsSinceUnixEpoch>,
/* private fields */
}Expand description
Represents a matrix room event that has been returned from a Matrix
client-server API endpoint such as /sync or /messages, after initial
processing.
The “initial processing” includes an attempt to decrypt encrypted events, so
the main thing this adds over AnyTimelineEvent is information on
encryption.
Fields§
§kind: TimelineEventKindThe event itself, together with any information on decryption.
timestamp: Option<MilliSecondsSinceUnixEpoch>The timestamp of the event. It’s the origin_server_ts value (if any),
corrected if detected as malicious.
It can be None if the event has been serialised before the addition of
this field, or if parsing the origin_server_ts value failed.
Implementations§
Source§impl TimelineEvent
impl TimelineEvent
Sourcepub fn from_plaintext(event: Raw<AnySyncTimelineEvent>) -> Self
pub fn from_plaintext(event: Raw<AnySyncTimelineEvent>) -> Self
Create a new TimelineEvent from the given raw event.
This is a convenience constructor for a plaintext event when you don’t
need to set push_action, for example inside a test.
Sourcepub fn from_plaintext_with_max_timestamp(
event: Raw<AnySyncTimelineEvent>,
max_timestamp: MilliSecondsSinceUnixEpoch,
) -> Self
pub fn from_plaintext_with_max_timestamp( event: Raw<AnySyncTimelineEvent>, max_timestamp: MilliSecondsSinceUnixEpoch, ) -> Self
Like TimelineEvent::from_plaintext but with a given max_timestamp.
Sourcepub fn from_decrypted(
decrypted: DecryptedRoomEvent,
push_actions: Option<Vec<Action>>,
) -> Self
pub fn from_decrypted( decrypted: DecryptedRoomEvent, push_actions: Option<Vec<Action>>, ) -> Self
Create a new TimelineEvent from a decrypted event.
Sourcepub fn from_decrypted_with_max_timestamp(
decrypted: DecryptedRoomEvent,
push_actions: Option<Vec<Action>>,
max_timestamp: MilliSecondsSinceUnixEpoch,
) -> Self
pub fn from_decrypted_with_max_timestamp( decrypted: DecryptedRoomEvent, push_actions: Option<Vec<Action>>, max_timestamp: MilliSecondsSinceUnixEpoch, ) -> Self
Like TimelineEvent::from_decrypted but with a given max_timestamp.
Sourcepub fn from_utd(
event: Raw<AnySyncTimelineEvent>,
utd_info: UnableToDecryptInfo,
) -> Self
pub fn from_utd( event: Raw<AnySyncTimelineEvent>, utd_info: UnableToDecryptInfo, ) -> Self
Create a new TimelineEvent to represent the given decryption
failure.
Sourcepub fn from_utd_with_max_timestamp(
event: Raw<AnySyncTimelineEvent>,
utd_info: UnableToDecryptInfo,
max_timestamp: MilliSecondsSinceUnixEpoch,
) -> Self
pub fn from_utd_with_max_timestamp( event: Raw<AnySyncTimelineEvent>, utd_info: UnableToDecryptInfo, max_timestamp: MilliSecondsSinceUnixEpoch, ) -> Self
Like TimelineEvent::from_utd but with a given max_timestamp.
Sourcepub fn to_decrypted(
&self,
decrypted: DecryptedRoomEvent,
push_actions: Option<Vec<Action>>,
) -> Self
pub fn to_decrypted( &self, decrypted: DecryptedRoomEvent, push_actions: Option<Vec<Action>>, ) -> Self
Transform this TimelineEvent into another TimelineEvent with the
TimelineEventKind::Decrypted kind.
§Panics
It panics (on debug builds only) if the kind already is
TimelineEventKind::Decrypted.
Sourcepub fn to_utd(&self, utd_info: UnableToDecryptInfo) -> Self
pub fn to_utd(&self, utd_info: UnableToDecryptInfo) -> Self
Transform this TimelineEvent into another TimelineEvent with the
TimelineEventKind::Decrypted kind.
§Panics
It panics (on debug builds only) if the kind already is
TimelineEventKind::Decrypted.
Sourcepub fn push_actions(&self) -> Option<&[Action]>
pub fn push_actions(&self) -> Option<&[Action]>
Read the current push actions.
Returns None if they were never computed, or if they could not be
computed.
Sourcepub fn set_push_actions(&mut self, push_actions: Vec<Action>)
pub fn set_push_actions(&mut self, push_actions: Vec<Action>)
Set the push actions for this event.
Sourcepub fn event_id(&self) -> Option<&EventId>
pub fn event_id(&self) -> Option<&EventId>
Get the (cached) event ID of this TimelineEvent if the event has any
valid ID.
Sourcepub fn sender(&self) -> Option<OwnedUserId>
pub fn sender(&self) -> Option<OwnedUserId>
Get the sender of this TimelineEvent if the event has one.
Sourcepub fn raw(&self) -> &Raw<AnySyncTimelineEvent>
pub fn raw(&self) -> &Raw<AnySyncTimelineEvent>
Returns a reference to the (potentially decrypted) Matrix event inside
this TimelineEvent.
Sourcepub fn replace_raw(&mut self, replacement: Raw<AnyTimelineEvent>)
pub fn replace_raw(&mut self, replacement: Raw<AnyTimelineEvent>)
Replace the raw event included in this item by another one.
Sourcepub fn timestamp(&self) -> Option<MilliSecondsSinceUnixEpoch>
pub fn timestamp(&self) -> Option<MilliSecondsSinceUnixEpoch>
Get the timestamp.
If the timestamp is missing (most likely because the event has been
created before the addition of the TimelineEvent::timestamp field),
this method will try to extract it from the origin_server_ts value. If
the origin_server_ts value is malicious, it will be capped to
MilliSecondsSinceUnixEpoch::now. It means that the returned value
might not be constant.
Sourcepub fn timestamp_raw(&self) -> Option<MilliSecondsSinceUnixEpoch>
pub fn timestamp_raw(&self) -> Option<MilliSecondsSinceUnixEpoch>
Get the timestamp value, without trying to backfill it if None.
Sourcepub fn encryption_info(&self) -> Option<&Arc<EncryptionInfo>>
pub fn encryption_info(&self) -> Option<&Arc<EncryptionInfo>>
If the event was a decrypted event that was successfully decrypted, get
its encryption info. Otherwise, None.
Sourcepub fn into_raw(self) -> Raw<AnySyncTimelineEvent>
pub fn into_raw(self) -> Raw<AnySyncTimelineEvent>
Takes ownership of this TimelineEvent, returning the (potentially
decrypted) Matrix event within.
Sourcepub fn is_thread_root(&self) -> bool
pub fn is_thread_root(&self) -> bool
Checks whether this event is a thread root, i.e. in-thread events are attached to it.
Sourcepub fn thread_summary(&self) -> Option<ThreadSummary>
pub fn thread_summary(&self) -> Option<ThreadSummary>
If this event is a thread root, find, parse, and create the
ThreadSummary of the thread.
Note that this value is NEVER updated. An event is immutable in
Matrix. However, the thread summary is updated dynamically in the SDK,
see matrix_sdk_base::event_cache::thread::ThreadInfo.
Sourcepub fn bundled_latest_thread_event(&self) -> Option<Self>
pub fn bundled_latest_thread_event(&self) -> Option<Self>
If this event is a thread root, find, parse, and create the latest event of the thread.
The latest event comes bundled with this event, if it was provided in the unsigned relations of this event.
Note that this value is NEVER updated. An event is immutable in
Matrix. However, the thread summary is updated dynamically in the SDK,
see matrix_sdk_base::event_cache::thread::ThreadInfo.
Sourcepub fn thread_summary_with_latest_event(&self) -> Option<(ThreadSummary, Self)>
pub fn thread_summary_with_latest_event(&self) -> Option<(ThreadSummary, Self)>
Combo of Self::thread_summary and
Self::bundled_latest_thread_event: if this event is a thread root, find,
parse once, and create the ThreadSummary and the
TimelineEvent representing the latest event of the thread.
Note that this value is NEVER updated. An event is immutable in
Matrix. However, the thread summary is updated dynamically in the SDK,
see matrix_sdk_base::event_cache::thread::ThreadInfo.
Trait Implementations§
Source§impl Clone for TimelineEvent
impl Clone for TimelineEvent
Source§impl Debug for TimelineEvent
impl Debug for TimelineEvent
Source§impl<'de> Deserialize<'de> for TimelineEvent
impl<'de> Deserialize<'de> for TimelineEvent
Source§fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>where
D: Deserializer<'de>,
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>where
D: Deserializer<'de>,
Custom deserializer for TimelineEvent, to support older formats.
Ideally we might use an untagged enum and then convert from that; however, that doesn’t work due to a serde bug.
Instead, we first deserialize into an unstructured JSON map, and then inspect the json to figure out which format we have.
Source§impl IndexableItem for TimelineEvent
impl IndexableItem for TimelineEvent
impl Send for TimelineEvent
test-send-sync only.Source§impl Serialize for TimelineEvent
impl Serialize for TimelineEvent
impl Sync for TimelineEvent
test-send-sync only.