pub struct EventCache { /* private fields */ }
Expand description
An event cache, providing lots of useful functionality for clients.
Cloning is shallow, and thus is cheap to do.
See also the module-level comment.
Implementations§
Source§impl EventCache
impl EventCache
Sourcepub fn enable_storage(&self) -> Result<()>
pub fn enable_storage(&self) -> Result<()>
Enable storing updates to storage, and reload events from storage.
Has an effect only the first time it’s called. It’s safe to call it multiple times.
Sourcepub fn has_storage(&self) -> bool
pub fn has_storage(&self) -> bool
Check whether the storage is enabled or not.
Sourcepub fn subscribe(&self) -> Result<()>
pub fn subscribe(&self) -> Result<()>
Starts subscribing the EventCache
to sync responses, if not done
before.
Re-running this has no effect if we already subscribed before, and is cheap.
Sourcepub async fn event(&self, event_id: &EventId) -> Option<TimelineEvent>
pub async fn event(&self, event_id: &EventId) -> Option<TimelineEvent>
Try to find an event by its ID in all the rooms.
Sourcepub async fn empty_immutable_cache(&self)
Available on crate feature testing
only.
pub async fn empty_immutable_cache(&self)
testing
only.Clear all the events from the immutable event cache.
This keeps all the rooms along with their internal events linked chunks, but it clears the side immutable cache for events.
As such, it doesn’t emit any RoomEventCacheUpdate
, and it’s expected
to be only useful in testing contexts.
Sourcepub async fn add_initial_events(
&self,
room_id: &RoomId,
events: Vec<TimelineEvent>,
prev_batch: Option<String>,
) -> Result<()>
pub async fn add_initial_events( &self, room_id: &RoomId, events: Vec<TimelineEvent>, prev_batch: Option<String>, ) -> Result<()>
Add an initial set of events to the event cache, reloaded from a cache.
TODO: temporary for API compat, as the event cache should take care of its own store.
Trait Implementations§
Source§impl Clone for EventCache
impl Clone for EventCache
Source§fn clone(&self) -> EventCache
fn clone(&self) -> EventCache
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moreAuto Trait Implementations§
impl Freeze for EventCache
impl !RefUnwindSafe for EventCache
impl Send for EventCache
impl Sync for EventCache
impl Unpin for EventCache
impl !UnwindSafe for EventCache
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> FutureExt for T
impl<T> FutureExt for T
Source§fn with_context(self, otel_cx: Context) -> WithContext<Self>
fn with_context(self, otel_cx: Context) -> WithContext<Self>
Source§fn with_current_context(self) -> WithContext<Self>
fn with_current_context(self) -> WithContext<Self>
Source§impl<T, UT> HandleAlloc<UT> for T
impl<T, UT> HandleAlloc<UT> for T
Source§fn consume_handle(handle: Handle) -> Arc<T>
fn consume_handle(handle: Handle) -> Arc<T>
Arc<>
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