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§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