Struct matrix_sdk::sliding_sync::SlidingSync
source · 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_room(
&self,
room_id: OwnedRoomId,
settings: Option<RoomSubscription>
)
pub fn subscribe_to_room( &self, room_id: OwnedRoomId, settings: Option<RoomSubscription> )
Subscribe to a given room.
If the associated Room
exists, it will be marked as
members are missing, so that it ensures to re-fetch all members.
sourcepub fn unsubscribe_from_room(&self, room_id: OwnedRoomId)
pub fn unsubscribe_from_room(&self, room_id: OwnedRoomId)
Unsubscribe from a given room.
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 !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
§impl<T> CompatExt for T
impl<T> CompatExt for T
§impl<T> FutureExt for T
impl<T> FutureExt for T
§fn with_context(self, otel_cx: Context) -> WithContext<Self>
fn with_context(self, otel_cx: Context) -> WithContext<Self>
§fn with_current_context(self) -> WithContext<Self>
fn with_current_context(self) -> WithContext<Self>
§impl<T, UT> HandleAlloc<UT> for T
impl<T, UT> HandleAlloc<UT> for T
§fn new_handle(value: Arc<T>) -> Handle
fn new_handle(value: Arc<T>) -> Handle
§fn clone_handle(handle: Handle) -> Handle
fn clone_handle(handle: Handle) -> Handle
§fn consume_handle(handle: Handle) -> Arc<T>
fn consume_handle(handle: Handle) -> Arc<T>
Arc<>