pub struct RawStateEventWithKeys<T: AnyStateEventEnum> {
pub raw: Raw<T>,
pub event_type: StateEventType,
pub state_key: String,
/* private fields */
}Expand description
A raw state event and its (type, state_key) tuple that identifies it
in the state map of the room.
This type can also cache the deserialized event lazily when using
RawStateEventWithKeys::deserialize_as().
Fields§
§raw: Raw<T>The raw state event.
event_type: StateEventTypeThe type of the state event.
state_key: StringThe state key of the state event.
Implementations§
Source§impl<T: AnyStateEventEnum> RawStateEventWithKeys<T>
impl<T: AnyStateEventEnum> RawStateEventWithKeys<T>
Sourcepub fn try_from_raw_state_event(raw: Raw<T>) -> Option<Self>
pub fn try_from_raw_state_event(raw: Raw<T>) -> Option<Self>
Try to construct a RawStateEventWithKeys from the given raw state
event.
Returns None if extracting the type or state_key fails.
Sourcepub fn deserialize(&mut self) -> Option<&T>
pub fn deserialize(&mut self) -> Option<&T>
Try to deserialize the raw event.
The result of the event deserialization is cached for future calls to this method.
Returns None if the deserialization failed.
Sourcepub fn deserialize_as_minimal_event<F, C>(
&mut self,
as_variant_fn: F,
) -> Option<MinimalStateEvent<C>>where
F: FnOnce(AnyPossiblyRedactedStateEventContent) -> Option<C>,
C: StaticEventContent + PossiblyRedactedStateEventContent + RedactContent,
pub fn deserialize_as_minimal_event<F, C>(
&mut self,
as_variant_fn: F,
) -> Option<MinimalStateEvent<C>>where
F: FnOnce(AnyPossiblyRedactedStateEventContent) -> Option<C>,
C: StaticEventContent + PossiblyRedactedStateEventContent + RedactContent,
Try to deserialize the raw event and return it as a
MinimalStateEvent using the selected variant of
AnyPossiblyRedactedStateEventContent.
This method should only be called if the variant is already known. It is
considered a developer error for as_variant_fn to return None, but
this API was chosen to simplify closures that use the
as_variant! macro.
The result of the event deserialization is cached for future calls to this method.
Returns None if the deserialization failed or if as_variant_fn
returns None.
Source§impl RawStateEventWithKeys<AnySyncStateEvent>
impl RawStateEventWithKeys<AnySyncStateEvent>
Sourcepub fn try_from_raw_timeline_event(
raw: &Raw<AnySyncTimelineEvent>,
) -> Option<Self>
pub fn try_from_raw_timeline_event( raw: &Raw<AnySyncTimelineEvent>, ) -> Option<Self>
Try to construct a RawStateEventWithKeys from the given raw
timeline event.
Returns None if deserializing the type or state_key fails, or if
the event is not a state event.
Sourcepub fn deserialize_as<F, C>(
&mut self,
as_variant_fn: F,
) -> Option<&SyncStateEvent<C>>where
F: FnOnce(&AnySyncStateEvent) -> Option<&SyncStateEvent<C>>,
C: StaticEventContent + StaticStateEventContent + RedactContent,
C::Redacted: RedactedStateEventContent,
pub fn deserialize_as<F, C>(
&mut self,
as_variant_fn: F,
) -> Option<&SyncStateEvent<C>>where
F: FnOnce(&AnySyncStateEvent) -> Option<&SyncStateEvent<C>>,
C: StaticEventContent + StaticStateEventContent + RedactContent,
C::Redacted: RedactedStateEventContent,
Try to deserialize the raw event and return the selected variant of
AnySyncStateEvent.
This method should only be called if the variant is already known. It is
considered a developer error for as_variant_fn to return None, but
this API was chosen to simplify closures that use the
as_variant! macro.
The result of the event deserialization is cached for future calls to this method.
Returns None if the deserialization failed or if as_variant_fn
returns None.
Source§impl RawStateEventWithKeys<AnyStrippedStateEvent>
impl RawStateEventWithKeys<AnyStrippedStateEvent>
Sourcepub fn deserialize_as<F, C>(
&mut self,
as_variant_fn: F,
) -> Option<&StrippedStateEvent<C>>where
F: FnOnce(&AnyStrippedStateEvent) -> Option<&StrippedStateEvent<C>>,
C: StaticEventContent + PossiblyRedactedStateEventContent,
pub fn deserialize_as<F, C>(
&mut self,
as_variant_fn: F,
) -> Option<&StrippedStateEvent<C>>where
F: FnOnce(&AnyStrippedStateEvent) -> Option<&StrippedStateEvent<C>>,
C: StaticEventContent + PossiblyRedactedStateEventContent,
Try to deserialize the raw event and return the selected variant of
AnyStrippedStateEvent.
This method should only be called if the variant is already known. It is
considered a developer error for as_variant_fn to return None, but
this API was chosen to simplify closures that use the
as_variant! macro.
The result of the event deserialization is cached for future calls to this method.
Returns None if the deserialization failed or if as_variant_fn
returns None.
Trait Implementations§
Source§impl<T: Clone + AnyStateEventEnum> Clone for RawStateEventWithKeys<T>
impl<T: Clone + AnyStateEventEnum> Clone for RawStateEventWithKeys<T>
Source§fn clone(&self) -> RawStateEventWithKeys<T>
fn clone(&self) -> RawStateEventWithKeys<T>
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreAuto Trait Implementations§
impl<T> Freeze for RawStateEventWithKeys<T>where
T: Freeze,
impl<T> RefUnwindSafe for RawStateEventWithKeys<T>where
T: RefUnwindSafe,
impl<T> Send for RawStateEventWithKeys<T>where
T: Send,
impl<T> Sync for RawStateEventWithKeys<T>where
T: Sync,
impl<T> Unpin for RawStateEventWithKeys<T>where
T: Unpin,
impl<T> UnsafeUnpin for RawStateEventWithKeys<T>where
T: UnsafeUnpin,
impl<T> UnwindSafe for RawStateEventWithKeys<T>where
T: UnwindSafe,
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, UT> HandleAlloc<UT> for T
impl<T, UT> HandleAlloc<UT> for T
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