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(&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 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_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.
Get a to-device request that will share a room key with users in a room.
sourcepub fn olm_machine(&self) -> Option<&OlmMachine>
pub fn olm_machine(&self) -> Option<&OlmMachine>
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
.
Trait Implementations
sourceimpl Clone for BaseClient
impl Clone for BaseClient
sourcefn clone(&self) -> BaseClient
fn clone(&self) -> BaseClient
Returns a copy of the value. Read more
1.0.0 · sourcefn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source
. Read more
sourceimpl Debug for BaseClient
impl Debug for BaseClient
Auto Trait Implementations
impl !RefUnwindSafe for BaseClient
impl Send for BaseClient
impl Sync for BaseClient
impl Unpin for BaseClient
impl !UnwindSafe for BaseClient
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<T> Instrument for T
impl<T> Instrument for T
sourcefn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
sourcefn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
sourceimpl<T> WithSubscriber for T
impl<T> WithSubscriber for T
sourcefn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> where
S: Into<Dispatch>,
fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> where
S: Into<Dispatch>,
Attaches the provided Subscriber
to this type, returning a
WithDispatch
wrapper. Read more
sourcefn with_current_subscriber(self) -> WithDispatch<Self>
fn with_current_subscriber(self) -> WithDispatch<Self>
Attaches the current default Subscriber
to this type, returning a
WithDispatch
wrapper. Read more