[][src]Struct matrix_sdk_base::BaseClient

pub struct BaseClient { /* fields omitted */ }

A no IO Client implementation.

This Client is a state machine that receives responses and events and accordingly updates its state.

Implementations

impl BaseClient[src]

pub fn new() -> Result<Self>[src]

Create a new default client.

pub fn new_with_config(config: BaseClientConfig) -> Result<Self>[src]

Create a new client.

Arguments

  • config - An optional session if the user already has one from a previous login call.

pub fn session(&self) -> &Arc<RwLock<Option<Session>>>[src]

The current client session containing our user id, device id and access token.

pub async fn logged_in(&self) -> bool[src]

Is the client logged in.

pub async fn add_event_emitter(&self, emitter: Box<dyn EventEmitter>)[src]

Add EventEmitter to Client.

The methods of EventEmitter are called when the respective RoomEvents occur.

pub async fn store_room_state(&self, room_id: &RoomId) -> Result<()>[src]

When a client is provided the state store will load state from the StateStore.

Returns true when a state store sync has successfully completed.

pub async fn receive_login_response(&self, response: &Response) -> Result<()>[src]

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.

pub async fn restore_login(&self, session: Session) -> Result<()>[src]

Restore a previously logged in session.

Arguments

  • session - An session that the user already has from a previous login call.

pub async fn get_joined_room(
    &self,
    room_id: &RoomId
) -> Option<Arc<RwLock<Room>>>
[src]

Get a joined room with the given room id.

Arguments

room_id - The unique id of the room that should be fetched.

pub fn joined_rooms(&self) -> Arc<RwLock<HashMap<RoomId, Arc<RwLock<Room>>>>>[src]

Returns the joined rooms this client knows about.

A HashMap of room id to matrix::models::Room

pub async fn get_invited_room(
    &self,
    room_id: &RoomId
) -> Option<Arc<RwLock<Room>>>
[src]

Get an invited room with the given room id.

Arguments

room_id - The unique id of the room that should be fetched.

pub fn invited_rooms(&self) -> Arc<RwLock<HashMap<RoomId, Arc<RwLock<Room>>>>>[src]

Returns the invited rooms this client knows about.

A HashMap of room id to matrix::models::Room

pub async fn get_left_room(&self, room_id: &RoomId) -> Option<Arc<RwLock<Room>>>[src]

Get an left room with the given room id.

Arguments

room_id - The unique id of the room that should be fetched.

pub fn left_rooms(&self) -> Arc<RwLock<HashMap<RoomId, Arc<RwLock<Room>>>>>[src]

Returns the left rooms this client knows about.

A HashMap of room id to matrix::models::Room

pub async fn receive_joined_timeline_event(
    &self,
    room_id: &RoomId,
    event: &mut Raw<AnySyncRoomEvent>
) -> Result<bool>
[src]

Receive a timeline event for a joined room and update the client state.

Returns a bool, true when the Room state has been updated.

This will in-place replace the event with a decrypted one if the encryption feature is turned on, the event is encrypted and if we successfully decrypted the event.

Arguments

  • room_id - The unique id of the room the event belongs to.

  • event - The event that should be handled by the client.

pub async fn receive_joined_state_event(
    &self,
    room_id: &RoomId,
    event: &AnySyncStateEvent
) -> Result<bool>
[src]

Receive a state event for a joined room and update the client state.

Returns true if the state of the room changed, false otherwise.

Arguments

  • room_id - The unique id of the room the event belongs to.

  • event - The event that should be handled by the client.

pub async fn receive_invite_state_event(
    &self,
    room_id: &RoomId,
    event: &AnyStrippedStateEvent
) -> Result<bool>
[src]

Receive a state event for a room the user has been invited to.

Returns true if the state of the room changed, false otherwise.

Arguments

  • room_id - The unique id of the room the event belongs to.

  • event - A AnyStrippedStateEvent that should be handled by the client.

pub async fn receive_left_timeline_event(
    &self,
    room_id: &RoomId,
    event: &Raw<AnySyncRoomEvent>
) -> Result<bool>
[src]

Receive a timeline event for a room the user has left and update the client state.

Returns a tuple of the successfully decrypted event, or None on failure and a bool, true when the Room state has been updated.

Arguments

  • room_id - The unique id of the room the event belongs to.

  • event - The event that should be handled by the client.

pub async fn receive_left_state_event(
    &self,
    room_id: &RoomId,
    event: &AnySyncStateEvent
) -> Result<bool>
[src]

Receive a state event for a room the user has left and update the client state.

Returns true if the state of the room changed, false otherwise.

Arguments

  • room_id - The unique id of the room the event belongs to.

  • event - The event that should be handled by the client.

pub async fn receive_presence_event(
    &self,
    room_id: &RoomId,
    event: &PresenceEvent
) -> bool
[src]

Receive a presence event from a sync response and updates the client state.

Returns true if the state of the room changed, false otherwise.

Arguments

  • room_id - The unique id of the room the event belongs to.

  • event - The event that should be handled by the client.

pub async fn receive_room_account_data_event(
    &self,
    _: &RoomId,
    event: &AnyBasicEvent
) -> bool
[src]

Receive an account data event associated to a room from a sync response and updates the client state.

Returns true if the state of the Room has changed, false otherwise.

Arguments

  • room_id - The unique id of the room the event belongs to.

  • event - The presence event for a specified room member.

pub async fn receive_account_data_event(
    &self,
    event: &AnyBasicEvent
) -> Vec<Arc<RwLock<Room>>>
[src]

Receive an account data event from a sync response and updates the client state.

Returns true if the state of any room has changed, false otherwise.

Arguments

  • event - The presence event for a specified room member.

pub async fn receive_ephemeral_event(
    &self,
    event: &AnySyncEphemeralRoomEvent
) -> bool
[src]

Receive an ephemeral event from a sync response and updates the client state.

Returns true if the state of the Room has changed, false otherwise.

Arguments

  • room_id - The unique id of the room the event belongs to.

  • event - The presence event for a specified room member.

pub async fn sync_token(&self) -> Option<String>[src]

Get the current, if any, sync token of the client. This will be None if the client didn't sync at least once.

pub async fn receive_sync_response(&self, response: &mut Response) -> Result<()>[src]

Receive a response from a sync call.

Arguments

  • response - The response that we received after a successful sync.

pub async fn should_share_group_session(&self, room_id: &RoomId) -> bool[src]

This is supported on encryption only.

Should the client share a group session for the given room.

Returns true if a session needs to be shared before room messages can be encrypted, false if one is already shared and ready to encrypt room messages.

This should be called every time a new room message wants to be sent out since group sessions can expire at any time.

pub async fn outgoing_requests(&self) -> Vec<OutgoingRequest>[src]

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.

pub async fn mark_request_as_sent<'a>(
    &self,
    request_id: &Uuid,
    response: impl Into<IncomingResponse<'a>>
) -> Result<()>
[src]

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.

pub async fn get_missing_sessions(
    &self,
    users: &mut impl Iterator<Item = &UserId>
) -> Result<Option<(Uuid, KeysClaimRequest)>>
[src]

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.

pub async fn share_group_session(
    &self,
    room_id: &RoomId
) -> Result<Vec<Arc<ToDeviceRequest>>>
[src]

This is supported on 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>
[src]

This is supported on encryption only.

Encrypt a message event content.

pub async fn invalidate_group_session(&self, room_id: &RoomId) -> bool[src]

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.

pub async fn get_verification(&self, flow_id: &str) -> Option<Sas>[src]

This is supported on encryption only.

Get a Sas verification object with the given flow id.

Arguments

  • flow_id - The unique id that identifies a interactive verification flow. For in-room verifications this will be the event id of the m.key.verification.request event that started the flow, for the to-device verification flows this will be the transaction id of the m.key.verification.start event.

pub async fn get_device(
    &self,
    user_id: &UserId,
    device_id: &DeviceId
) -> StdResult<Option<Device>, CryptoStoreError>
[src]

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);

pub async fn get_session(&self) -> Option<Session>[src]

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>
[src]

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);
}

pub async fn olm_machine(&self) -> Option<OlmMachine>[src]

This is supported on encryption only.

Get the olm machine.

Trait Implementations

impl Clone for BaseClient[src]

impl Debug for BaseClient[src]

Auto Trait Implementations

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> AsyncTraitDeps for T where
    T: Send + Sync + Debug
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> Conv for T

impl<T> Conv for T

impl<T> FmtForward for T

impl<T> From<T> for T[src]

impl<T> Instrument for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> Pipe for T where
    T: ?Sized

impl<T> Pipe for T

impl<T> PipeAsRef for T

impl<T> PipeBorrow for T

impl<T> PipeDeref for T

impl<T> PipeRef for T

impl<T> Same<T> for T

type Output = T

Should always be Self

impl<T> Tap for T

impl<T> Tap for T

impl<T, U> TapAsRef<U> for T where
    U: ?Sized

impl<T, U> TapBorrow<U> for T where
    U: ?Sized

impl<T> TapDeref for T

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T> TryConv for T

impl<T> TryConv for T

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<V, T> VZip<V> for T where
    V: MultiLane<T>,