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
sourceimpl 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 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 session_tokens(&self) -> ReadOnlyMutable<Option<SessionTokens>>
pub fn session_tokens(&self) -> ReadOnlyMutable<Option<SessionTokens>>
Get the session tokens.
If the client is currently logged in, this will return a
SessionTokens object which contains the access token and optional
refresh token. Otherwise it returns None.
sourcepub fn set_session_tokens(&self, tokens: SessionTokens)
pub fn set_session_tokens(&self, tokens: SessionTokens)
Set the session tokens.
sourcepub fn session(&self) -> Option<Session>
pub fn session(&self) -> Option<Session>
Get the user login session.
If the client is currently logged in, this will return a
Session object which can later be given to
BaseClient::restore_login.
Returns a session object if the client is logged in. Otherwise returns
None.
sourcepub fn get_rooms(&self) -> Vec<Room>ⓘNotable traits for Vec<u8, A>impl<A> Write for Vec<u8, A>where
A: Allocator,
pub fn get_rooms(&self) -> Vec<Room>ⓘNotable traits for Vec<u8, A>impl<A> Write for Vec<u8, A>where
A: Allocator,
A: Allocator,
Get all the rooms this client knows about.
sourcepub fn get_stripped_rooms(&self) -> Vec<Room>ⓘNotable traits for Vec<u8, A>impl<A> Write for Vec<u8, A>where
A: Allocator,
pub fn get_stripped_rooms(&self) -> Vec<Room>ⓘNotable traits for Vec<u8, A>impl<A> Write for Vec<u8, A>where
A: Allocator,
A: Allocator,
Get all the rooms this client knows about.
sourcepub fn store(&self) -> &dyn StateStore
pub fn store(&self) -> &dyn StateStore
Get a reference to the store.
sourcepub async fn receive_login_response(&self, response: &Response) -> Result<()>
pub async fn receive_login_response(&self, response: &Response) -> Result<()>
Receive a login response and update the session of the client.
Arguments
response- A successful login response that contains our access token and device ID.
sourcepub async fn restore_login(&self, session: Session) -> Result<()>
pub async fn restore_login(&self, session: Session) -> Result<()>
Restore a previously logged in session.
Arguments
session- An session that the user already has from a previous login call.
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 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_messages(
&self,
room_id: &RoomId,
timeline: TimelineSlice
) -> Result<()>
Available on crate feature experimental-timeline only.
pub async fn receive_messages(
&self,
room_id: &RoomId,
timeline: TimelineSlice
) -> Result<()>
experimental-timeline only.Receive a timeline slice obtained from a messages request.
You should pass only slices requested from the store to this function.
timeline- TheTimelineSlice
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 fn olm_machine(&self) -> Option<&OlmMachine>
Available on crate feature e2e-encryption only.
pub fn olm_machine(&self) -> 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.
sourceimpl BaseClient
impl BaseClient
sourcepub async fn process_sliding_sync(
&self,
response: Response
) -> Result<SyncResponse>
Available on crate feature sliding-sync only.
pub async fn process_sliding_sync(
&self,
response: Response
) -> Result<SyncResponse>
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
sourceimpl Clone for BaseClient
impl Clone for BaseClient
sourcefn clone(&self) -> BaseClient
fn clone(&self) -> BaseClient
1.0.0 · sourcefn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moresourceimpl Debug for BaseClient
Available on non-tarpaulin_include only.
impl Debug for BaseClient
tarpaulin_include only.