Struct matrix_sdk_base::BaseClient [−][src]
pub struct BaseClient { /* fields omitted */ }
Expand description
A no IO Client implementation.
This Client is a state machine that receives responses and events and accordingly updates its state.
Implementations
Create a new client.
Arguments
config
- An optional session if the user already has one from a previous login call.
The current client session containing our user id, device id and access token.
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.
Restore a previously logged in session.
Arguments
session
- An session that the user already has from a previous login call.
Get the current, if any, sync token of the client. This will be None if the client didn’t sync at least once.
Receive a response from a sync call.
Arguments
response
- The response that we received after a successful sync.
pub 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.
pub 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.
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.
This is supported on encryption
only.
encryption
only.Get the outgoing requests that need to be sent out.
This returns a list of OutGoingRequest
, those requests need to be sent
out to the server and the responses need to be passed back to the state
machine using mark_request_as_sent
.
pub async fn mark_request_as_sent<'a>(
&self,
request_id: &Uuid,
response: impl Into<IncomingResponse<'a>>
) -> Result<()>
This is supported on encryption
only.
pub async fn mark_request_as_sent<'a>(
&self,
request_id: &Uuid,
response: impl Into<IncomingResponse<'a>>
) -> Result<()>
encryption
only.Mark the request with the given request id as sent.
Arguments
-
request_id
- The unique id of the request that was sent out. This is needed to couple the response with the now sent out request. -
response
- The response that was received from the server after the outgoing request was sent out.
pub async fn get_missing_sessions(
&self,
users: impl Iterator<Item = &UserId>
) -> Result<Option<(Uuid, KeysClaimRequest)>>
This is supported on encryption
only.
pub async fn get_missing_sessions(
&self,
users: impl Iterator<Item = &UserId>
) -> Result<Option<(Uuid, KeysClaimRequest)>>
encryption
only.Get a tuple of device and one-time keys that need to be uploaded.
Returns an empty error if no keys need to be uploaded.
This is supported on encryption
only.
encryption
only.Get a to-device request that will share a group session for a room.
pub async fn encrypt(
&self,
room_id: &RoomId,
content: impl Into<AnyMessageEventContent>
) -> Result<EncryptedEventContent>
This is supported on encryption
only.
pub async fn encrypt(
&self,
room_id: &RoomId,
content: impl Into<AnyMessageEventContent>
) -> Result<EncryptedEventContent>
encryption
only.Encrypt a message event content.
pub async fn invalidate_group_session(
&self,
room_id: &RoomId
) -> Result<bool, CryptoStoreError>
This is supported on encryption
only.
pub async fn invalidate_group_session(
&self,
room_id: &RoomId
) -> Result<bool, CryptoStoreError>
encryption
only.Invalidate the currently active outbound group session for the given room.
Returns true if a session was invalidated, false if there was no session to invalidate.
pub async fn get_device(
&self,
user_id: &UserId,
device_id: &DeviceId
) -> StdResult<Option<Device>, CryptoStoreError>
This is supported on encryption
only.
pub async fn get_device(
&self,
user_id: &UserId,
device_id: &DeviceId
) -> StdResult<Option<Device>, CryptoStoreError>
encryption
only.Get a specific device of a user.
Arguments
-
user_id
- The unique id of the user that the device belongs to. -
device_id
- The unique id of the device.
Returns a Device
if one is found and the crypto store didn’t throw an
error.
This will always return None if the client hasn’t been logged in.
Example
let device = client.get_device(&alice, "DEVICEID".into()).await;
println!("{:?}", device);
Get the user login session.
If the client is currently logged in, this will return a
matrix_sdk::Session
object which can later be given to
restore_login
.
Returns a session object if the client is logged in. Otherwise returns
None
.
pub async fn get_user_devices(
&self,
user_id: &UserId
) -> StdResult<UserDevices, CryptoStoreError>
This is supported on encryption
only.
pub async fn get_user_devices(
&self,
user_id: &UserId
) -> StdResult<UserDevices, CryptoStoreError>
encryption
only.Get a map holding all the devices of an user.
This will always return an empty map if the client hasn’t been logged in.
Arguments
user_id
- The unique id of the user that the devices belong to.
Panics
Panics if the client hasn’t been logged in and the crypto layer thus hasn’t been initialized.
Example
let devices = client.get_user_devices(&alice).await.unwrap();
for device in devices.devices() {
println!("{:?}", device);
}
This is supported on encryption
only.
encryption
only.Get the olm machine.
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.
pub 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.
pub 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
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
Mutably borrows from an owned value. Read more
Instruments this type with the provided Span
, returning an
Instrumented
wrapper. Read more