Struct matrix_sdk::sliding_sync::SlidingSync
source · pub struct SlidingSync { /* private fields */ }
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>,
)
pub fn subscribe_to_rooms( &self, room_ids: &[&RoomId], settings: Option<RoomSubscription>, )
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,
source§default unsafe fn clone_to_uninit(&self, dst: *mut T)
default unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)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