Struct matrix_sdk_base::latest_event::LatestEvent
source · pub struct LatestEvent { /* private fields */ }
experimental-sliding-sync
only.Expand description
Represent all information required to represent a latest event in an efficient way.
Implementation details
Serialization and deserialization should be a breeze, but we introduced a
change in the format without realizing, and without a migration. Ideally,
this would be handled with a serde(untagged)
enum that would be used to
deserialize in either the older format, or to the new format. Unfortunately,
untagged enums don’t play nicely with serde_json::value::RawValue
,
so we did have to implement a custom Deserialize
for LatestEvent
, that
first deserializes the thing as a raw JSON value, and then deserializes the
JSON string as one variant or the other.
Because of that, LatestEvent
should only be (de)serialized using
serde_json.
Whenever you introduce new fields to LatestEvent
make sure to add them to
SerializedLatestEvent
too.
Implementations§
source§impl LatestEvent
impl LatestEvent
sourcepub fn new(event: SyncTimelineEvent) -> Self
pub fn new(event: SyncTimelineEvent) -> Self
Create a new LatestEvent
without the sender’s profile.
sourcepub fn new_with_sender_details(
event: SyncTimelineEvent,
sender_profile: Option<MinimalRoomMemberEvent>,
sender_name_is_ambiguous: Option<bool>
) -> Self
pub fn new_with_sender_details( event: SyncTimelineEvent, sender_profile: Option<MinimalRoomMemberEvent>, sender_name_is_ambiguous: Option<bool> ) -> Self
Create a new LatestEvent
with maybe the sender’s profile.
sourcepub fn into_event(self) -> SyncTimelineEvent
pub fn into_event(self) -> SyncTimelineEvent
Transform Self
into an event.
sourcepub fn event(&self) -> &SyncTimelineEvent
pub fn event(&self) -> &SyncTimelineEvent
Get a reference to the event.
sourcepub fn event_mut(&mut self) -> &mut SyncTimelineEvent
pub fn event_mut(&mut self) -> &mut SyncTimelineEvent
Get a mutable reference to the event.
sourcepub fn event_id(&self) -> Option<OwnedEventId>
pub fn event_id(&self) -> Option<OwnedEventId>
Get the event ID.
sourcepub fn has_sender_profile(&self) -> bool
pub fn has_sender_profile(&self) -> bool
Check whether Self
has a sender profile.
sourcepub fn sender_display_name(&self) -> Option<&str>
pub fn sender_display_name(&self) -> Option<&str>
Return the sender’s display name if it was known at the time Self
was built.
sourcepub fn sender_name_ambiguous(&self) -> Option<bool>
pub fn sender_name_ambiguous(&self) -> Option<bool>
Return Some(true)
if the sender’s name is ambiguous, Some(false)
if
it isn’t, None
if ambiguity detection wasn’t possible at the time
Self
was built.
sourcepub fn sender_avatar_url(&self) -> Option<&MxcUri>
pub fn sender_avatar_url(&self) -> Option<&MxcUri>
Return the sender’s avatar URL if it was known at the time Self
was
built.
Trait Implementations§
source§impl Clone for LatestEvent
impl Clone for LatestEvent
source§fn clone(&self) -> LatestEvent
fn clone(&self) -> LatestEvent
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read more