pub struct RoomEventCache { /* private fields */ }
Expand description
A subset of an event cache, for a room.
Cloning is shallow, and thus is cheap to do.
Implementations§
Source§impl RoomEventCache
impl RoomEventCache
Sourcepub async fn events(&self) -> Vec<Event> ⓘ
pub async fn events(&self) -> Vec<Event> ⓘ
Read all current events.
Use RoomEventCache::subscribe
to get all current events, plus a
subscriber.
Sourcepub async fn subscribe(&self) -> (Vec<Event>, RoomEventCacheSubscriber)
pub async fn subscribe(&self) -> (Vec<Event>, RoomEventCacheSubscriber)
Subscribe to this room updates, after getting the initial list of events.
Use RoomEventCache::events
to get all current events without the
subscriber. Creating, and especially dropping, a
RoomEventCacheSubscriber
isn’t free, as it triggers side-effects.
Sourcepub async fn subscribe_to_thread(
&self,
thread_root: OwnedEventId,
) -> (Vec<Event>, Receiver<ThreadEventCacheUpdate>)
pub async fn subscribe_to_thread( &self, thread_root: OwnedEventId, ) -> (Vec<Event>, Receiver<ThreadEventCacheUpdate>)
Subscribe to thread for a given root event, and get a (maybe empty) initially known list of events for that thread.
Sourcepub async fn paginate_thread_backwards(
&self,
thread_root: OwnedEventId,
num_events: u16,
) -> Result<bool>
pub async fn paginate_thread_backwards( &self, thread_root: OwnedEventId, num_events: u16, ) -> Result<bool>
Paginate backwards in a thread, given its root event ID.
Returns whether we’ve hit the start of the thread, in which case the root event will be prepended to the thread.
Sourcepub fn pagination(&self) -> RoomPagination
pub fn pagination(&self) -> RoomPagination
Return a RoomPagination
API object useful for running
back-pagination queries in the current room.
Sourcepub async fn rfind_map_event_in_memory_by<O, P>(
&self,
predicate: P,
) -> Option<O>
pub async fn rfind_map_event_in_memory_by<O, P>( &self, predicate: P, ) -> Option<O>
Try to find a single event in this room, starting from the most recent event.
Warning! It looks into the loaded events from the in-memory linked chunk only. It doesn’t look inside the storage.
Sourcepub async fn find_event(&self, event_id: &EventId) -> Option<Event>
pub async fn find_event(&self, event_id: &EventId) -> Option<Event>
Try to find an event by ID in this room.
It starts by looking into loaded events before looking inside the storage.
Sourcepub async fn find_event_with_relations(
&self,
event_id: &EventId,
filter: Option<Vec<RelationType>>,
) -> Option<(Event, Vec<Event>)>
pub async fn find_event_with_relations( &self, event_id: &EventId, filter: Option<Vec<RelationType>>, ) -> Option<(Event, Vec<Event>)>
Try to find an event by ID in this room, along with its related events.
You can filter which types of related events to retrieve using
filter
. None
will retrieve related events of any type.
The related events are sorted like this:
- events saved out-of-band (with
RoomEventCache::save_events
) will be located at the beginning of the array. - events present in the linked chunk (be it in memory or in the storage) will be sorted according to their ordering in the linked chunk.
Sourcepub async fn clear(&self) -> Result<()>
pub async fn clear(&self) -> Result<()>
Clear all the storage for this RoomEventCache
.
This will get rid of all the events from the linked chunk and persisted storage.
Sourcepub async fn debug_string(&self) -> Vec<String>
pub async fn debug_string(&self) -> Vec<String>
Return a nice debug string (a vector of lines) for the linked chunk of events for this room.
Trait Implementations§
Source§impl Clone for RoomEventCache
impl Clone for RoomEventCache
Source§fn clone(&self) -> RoomEventCache
fn clone(&self) -> RoomEventCache
1.0.0 · Source§const fn clone_from(&mut self, source: &Self)
const fn clone_from(&mut self, source: &Self)
source
. Read moreAuto Trait Implementations§
impl Freeze for RoomEventCache
impl !RefUnwindSafe for RoomEventCache
impl Send for RoomEventCache
impl Sync for RoomEventCache
impl Unpin for RoomEventCache
impl !UnwindSafe for RoomEventCache
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§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