Struct matrix_sdk_base::latest_event::LatestEvent
source · pub struct LatestEvent { /* private fields */ }
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 moresource§impl Debug for LatestEvent
impl Debug for LatestEvent
source§impl<'de> Deserialize<'de> for LatestEvent
impl<'de> Deserialize<'de> for LatestEvent
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>,
Auto Trait Implementations§
impl Freeze for LatestEvent
impl RefUnwindSafe for LatestEvent
impl Send for LatestEvent
impl Sync for LatestEvent
impl Unpin for LatestEvent
impl UnwindSafe for LatestEvent
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