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 default client.

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.

Get a reference to the store.

Is the client logged in.

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.

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.

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.

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.

This is supported on 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.

This is supported on 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.

Get a to-device request that will share a group session for a room.

Get the room with the given room id.

Arguments

  • room_id - The id of the room that should be fetched.
This is supported on encryption only.

Encrypt a message event content.

This is supported on 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.

This is supported on 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.

This is supported on 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.

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.

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.

Update the push context for the given room.

Updates the context data from changes or room_info.

Trait Implementations

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Formats the value using the given formatter. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Performs the conversion.

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more

Instruments this type with the current Span, returning an Instrumented wrapper. Read more

Performs the conversion.

The alignment of pointer.

The type for initializers.

Initializes a with the given initializer. Read more

Dereferences the given pointer. Read more

Mutably dereferences the given pointer. Read more

Drops the object pointed to by the given pointer. Read more

Should always be Self

The resulting type after obtaining ownership.

Creates owned data from borrowed data, usually by cloning. Read more

🔬 This is a nightly-only experimental API. (toowned_clone_into)

recently added

Uses borrowed data to replace owned data, usually by cloning. Read more

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.