pub struct SlidingSync { /* private fields */ }
experimental-sliding-sync
only.Expand description
The Sliding Sync instance.
It is OK to clone this type as much as you need: cloning it is cheap.
Implementations§
Source§impl SlidingSync
impl SlidingSync
Sourcepub fn builder(id: String, client: Client) -> Result<SlidingSyncBuilder, Error>
pub fn builder(id: String, client: Client) -> Result<SlidingSyncBuilder, Error>
Create a new SlidingSyncBuilder
.
Sourcepub fn subscribe_to_rooms(
&self,
room_ids: &[&RoomId],
settings: Option<RoomSubscription>,
cancel_in_flight_request: bool,
)
pub fn subscribe_to_rooms( &self, room_ids: &[&RoomId], settings: Option<RoomSubscription>, cancel_in_flight_request: bool, )
Subscribe to many rooms.
If the associated Room
s exist, it will be marked as
members are missing, so that it ensures to re-fetch all members.
A subscription to an already subscribed room is ignored.
Sourcepub async fn get_room(&self, room_id: &RoomId) -> Option<SlidingSyncRoom>
pub async fn get_room(&self, room_id: &RoomId) -> Option<SlidingSyncRoom>
Lookup a specific room
Sourcepub fn get_number_of_rooms(&self) -> usize
pub fn get_number_of_rooms(&self) -> usize
Check the number of rooms.
Sourcepub async fn on_list<Function, FunctionOutput, R>(
&self,
list_name: &str,
function: Function,
) -> Option<R>
pub async fn on_list<Function, FunctionOutput, R>( &self, list_name: &str, function: Function, ) -> Option<R>
Find a list by its name, and do something on it if it exists.
Sourcepub async fn add_list(
&self,
list_builder: SlidingSyncListBuilder,
) -> Result<Option<SlidingSyncList>>
pub async fn add_list( &self, list_builder: SlidingSyncListBuilder, ) -> Result<Option<SlidingSyncList>>
Add the list to the list of lists.
As lists need to have a unique .name
, if a list with the same name
is found the new list will replace the old one and the return it or
None
.
Sourcepub async fn add_cached_list(
&self,
list_builder: SlidingSyncListBuilder,
) -> Result<Option<SlidingSyncList>>
pub async fn add_cached_list( &self, list_builder: SlidingSyncListBuilder, ) -> Result<Option<SlidingSyncList>>
Add a list that will be cached and reloaded from the cache.
This will raise an error if a storage key was not set, or if there was a I/O error reading from the cache.
The rest of the semantics is the same as Self::add_list
.
Sourcepub async fn get_rooms<I: Iterator<Item = OwnedRoomId>>(
&self,
room_ids: I,
) -> Vec<Option<SlidingSyncRoom>>
pub async fn get_rooms<I: Iterator<Item = OwnedRoomId>>( &self, room_ids: I, ) -> Vec<Option<SlidingSyncRoom>>
Lookup a set of rooms
Sourcepub async fn get_all_rooms(&self) -> Vec<SlidingSyncRoom>
pub async fn get_all_rooms(&self) -> Vec<SlidingSyncRoom>
Get all rooms.
Sourcepub fn sync(&self) -> impl Stream<Item = Result<UpdateSummary, Error>> + '_
pub fn sync(&self) -> impl Stream<Item = Result<UpdateSummary, Error>> + '_
Create a new Sliding Sync sync loop.
This method returns a Stream
, which will send requests and will handle
responses automatically. Lists and rooms are updated automatically.
This function returns Ok(…)
if everything went well, otherwise it will
return Err(…)
. An Err
will always lead to the Stream
termination.
Sourcepub fn stop_sync(&self) -> Result<()>
pub fn stop_sync(&self) -> Result<()>
Force to stop the sync loop (Self::sync
) if it’s running.
Usually, dropping the Stream
returned by Self::sync
should be
enough to “stop” it, but depending of how this Stream
is used, it
might not be obvious to drop it immediately (thinking of using this API
over FFI; the foreign-language might not be able to drop a value
immediately). Thus, calling this method will ensure that the sync loop
stops gracefully and as soon as it returns.
Trait Implementations§
Source§impl Clone for SlidingSync
impl Clone for SlidingSync
Source§fn clone(&self) -> SlidingSync
fn clone(&self) -> SlidingSync
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 SlidingSync
impl !RefUnwindSafe for SlidingSync
impl Send for SlidingSync
impl Sync for SlidingSync
impl Unpin for SlidingSync
impl !UnwindSafe for SlidingSync
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