Struct matrix_sdk_base::BaseClient
source · pub struct BaseClient { /* private fields */ }
Expand description
A no IO Client implementation.
This Client is a state machine that receives responses and events and accordingly updates its state.
Implementations§
source§impl BaseClient
impl BaseClient
sourcepub fn with_store_config(config: StoreConfig) -> Self
pub fn with_store_config(config: StoreConfig) -> Self
Create a new client.
Arguments
config
- An optional session if the user already has one from a previous login call.
sourcepub fn clone_with_in_memory_state_store(&self) -> Self
pub fn clone_with_in_memory_state_store(&self) -> Self
Clones the current base client to use the same crypto store but a different, in-memory store config, and resets transient state.
sourcepub fn session_meta(&self) -> Option<&SessionMeta>
pub fn session_meta(&self) -> Option<&SessionMeta>
Get the session meta information.
If the client is currently logged in, this will return a
SessionMeta
object which contains the user ID and device ID.
Otherwise it returns None
.
sourcepub fn get_rooms_filtered(&self, filter: RoomStateFilter) -> Vec<Room>
pub fn get_rooms_filtered(&self, filter: RoomStateFilter) -> Vec<Room>
Get all the rooms this client knows about, filtered by room state.
sourcepub fn get_or_create_room(
&self,
room_id: &RoomId,
room_state: RoomState
) -> Room
pub fn get_or_create_room( &self, room_id: &RoomId, room_state: RoomState ) -> Room
Lookup the Room for the given RoomId, or create one, if it didn’t exist yet in the store
sourcepub fn get_stripped_rooms(&self) -> Vec<Room>
👎Deprecated: Use get_rooms_filtered with RoomStateFilter::INVITED instead.
pub fn get_stripped_rooms(&self) -> Vec<Room>
Get all the rooms this client knows about.
sourcepub fn store(&self) -> &DynStateStore
pub fn store(&self) -> &DynStateStore
Get a reference to the store.
sourcepub async fn set_session_meta(&self, session_meta: SessionMeta) -> Result<()>
pub async fn set_session_meta(&self, session_meta: SessionMeta) -> Result<()>
Set the meta of the session.
If encryption is enabled, this also initializes or restores the
OlmMachine
.
Arguments
session_meta
- The meta of a session that the user already has from a previous login call.
This method panics if it is called twice.
sourcepub async fn regenerate_olm(&self) -> Result<()>
Available on crate feature e2e-encryption
only.
pub async fn regenerate_olm(&self) -> Result<()>
e2e-encryption
only.Recreate an OlmMachine
from scratch.
In particular, this will clear all its caches.
sourcepub async fn sync_token(&self) -> Option<String>
pub async fn sync_token(&self) -> Option<String>
Get the current, if any, sync token of the client. This will be None if the client didn’t sync at least once.
sourcepub async fn room_joined(&self, room_id: &RoomId) -> Result<Room>
pub async fn room_joined(&self, room_id: &RoomId) -> Result<Room>
User has joined a room.
Update the internal and cached state accordingly. Return the final Room.
sourcepub async fn room_left(&self, room_id: &RoomId) -> Result<()>
pub async fn room_left(&self, room_id: &RoomId) -> Result<()>
User has left a room.
Update the internal and cached state accordingly.
sourcepub async fn receive_sync_response(
&self,
response: Response
) -> Result<SyncResponse>
pub async fn receive_sync_response( &self, response: Response ) -> Result<SyncResponse>
Receive a response from a sync call.
Arguments
response
- The response that we received after a successful sync.
sourcepub async fn receive_members(
&self,
room_id: &RoomId,
response: &Response
) -> Result<MembersResponse>
pub async fn receive_members( &self, room_id: &RoomId, response: &Response ) -> Result<MembersResponse>
Receive a get member events response and convert it to a deserialized
MembersResponse
Arguments
-
room_id
- The room id this response belongs to. -
response
- The raw response that was received from the server.
sourcepub async fn receive_filter_upload(
&self,
filter_name: &str,
response: &Response
) -> Result<()>
pub async fn receive_filter_upload( &self, filter_name: &str, response: &Response ) -> Result<()>
Receive a successful filter upload response, the filter id will be stored under the given name in the store.
The filter id can later be retrieved with the get_filter
method.
Arguments
-
filter_name
- The name that should be used to persist the filter id in the store. -
response
- The successful filter upload response containing the filter id.
sourcepub async fn get_filter(&self, filter_name: &str) -> StoreResult<Option<String>>
pub async fn get_filter(&self, filter_name: &str) -> StoreResult<Option<String>>
Get the filter id of a previously uploaded filter.
Note: A filter will first need to be uploaded and persisted using
receive_filter_upload
.
Arguments
filter_name
- The name of the filter that was previously used to persist the filter.
Available on crate feature e2e-encryption
only.
e2e-encryption
only.Get a to-device request that will share a room key with users in a room.
sourcepub async fn olm_machine(&self) -> RwLockReadGuard<'_, Option<OlmMachine>>
Available on crate feature e2e-encryption
only.
pub async fn olm_machine(&self) -> RwLockReadGuard<'_, Option<OlmMachine>>
e2e-encryption
only.Get the olm machine.
sourcepub async fn get_push_rules(&self, changes: &StateChanges) -> Result<Ruleset>
pub async fn get_push_rules(&self, changes: &StateChanges) -> Result<Ruleset>
Get the push rules.
Gets the push rules from changes
if they have been updated, otherwise
get them from the store. As a fallback, uses
Ruleset::server_default
if the user is logged in.
sourcepub async fn get_push_room_context(
&self,
room: &Room,
room_info: &RoomInfo,
changes: &StateChanges
) -> Result<Option<PushConditionRoomCtx>>
pub async fn get_push_room_context( &self, room: &Room, room_info: &RoomInfo, changes: &StateChanges ) -> Result<Option<PushConditionRoomCtx>>
Get the push context for the given room.
Tries to get the data from changes
or the up to date room_info
.
Loads the data from the store otherwise.
Returns None
if some data couldn’t be found. This should only happen
in brand new rooms, while we process its state.
sourcepub async fn update_push_room_context(
&self,
push_rules: &mut PushConditionRoomCtx,
user_id: &UserId,
room_info: &RoomInfo,
changes: &StateChanges
)
pub async fn update_push_room_context( &self, push_rules: &mut PushConditionRoomCtx, user_id: &UserId, room_info: &RoomInfo, changes: &StateChanges )
Update the push context for the given room.
Updates the context data from changes
or room_info
.
sourcepub fn subscribe_to_ignore_user_list_changes(&self) -> Subscriber<()>
pub fn subscribe_to_ignore_user_list_changes(&self) -> Subscriber<()>
Returns a subscriber that publishes an event every time the ignore user list changes
source§impl BaseClient
impl BaseClient
sourcepub async fn process_sliding_sync_e2ee(
&self,
extensions: &Extensions
) -> Result<Vec<Raw<AnyToDeviceEvent>>>
Available on crate features experimental-sliding-sync
and e2e-encryption
only.
pub async fn process_sliding_sync_e2ee( &self, extensions: &Extensions ) -> Result<Vec<Raw<AnyToDeviceEvent>>>
experimental-sliding-sync
and e2e-encryption
only.Processes the E2EE-related events from the Sliding Sync response.
In addition to writes to the crypto store, this may also write into the state store, in particular it may write latest-events to the state store.
sourcepub async fn process_sliding_sync<PEP: PreviousEventsProvider>(
&self,
response: &Response,
previous_events_provider: &PEP
) -> Result<SyncResponse>
Available on crate feature experimental-sliding-sync
only.
pub async fn process_sliding_sync<PEP: PreviousEventsProvider>( &self, response: &Response, previous_events_provider: &PEP ) -> Result<SyncResponse>
experimental-sliding-sync
only.Process a response from a sliding sync call.
Arguments
response
- The response that we received after a successful sliding sync.
Trait Implementations§
source§impl Clone for BaseClient
impl Clone for BaseClient
source§fn clone(&self) -> BaseClient
fn clone(&self) -> BaseClient
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moresource§impl Debug for BaseClient
Available on non-tarpaulin_include
only.
impl Debug for BaseClient
tarpaulin_include
only.