Skip to main content

OneTimeKeysQueries

Trait OneTimeKeysQueries 

Source
pub trait OneTimeKeysQueries: Database {
    // Provided methods
    async fn try_insert_one_time_key(
        &mut self,
        key_algorithm: &OneTimeKeyAlgorithm,
        key_name: &OneTimeKeyName,
        user_id: &UserId,
        device_id: &DeviceId,
        key: &OneTimeKey,
    ) -> Result<(), DatabaseError> { ... }
    async fn import_one_time_key(
        &mut self,
        key_algorithm: &OneTimeKeyAlgorithm,
        key_name: &OneTimeKeyName,
        user_id: &UserId,
        device_id: &DeviceId,
        key: &OneTimeKey,
    ) -> Result<bool, DatabaseError> { ... }
    async fn fetch_one_time_keys_counts(
        &mut self,
        user_id: &UserId,
        device_id: &DeviceId,
    ) -> Result<BTreeMap<OneTimeKeyAlgorithm, UInt>, DatabaseError> { ... }
    async fn fetch_one_time_keys(
        &mut self,
        one_time_keys: &BTreeMap<OwnedUserId, BTreeMap<OwnedDeviceId, OneTimeKeyAlgorithm>>,
    ) -> Result<OneTimeKeyMap, DatabaseError> { ... }
    async fn delete_one_time_keys(
        &mut self,
        nids: &[i32],
    ) -> Result<(), DatabaseError> { ... }
}
Expand description

Queries related to the one_time_keys table.

Provided Methods§

Source

async fn try_insert_one_time_key( &mut self, key_algorithm: &OneTimeKeyAlgorithm, key_name: &OneTimeKeyName, user_id: &UserId, device_id: &DeviceId, key: &OneTimeKey, ) -> Result<(), DatabaseError>

Tries inserting one-time keys for a user into the database.

NOTE: If the given key already exists, does nothing.

Source

async fn import_one_time_key( &mut self, key_algorithm: &OneTimeKeyAlgorithm, key_name: &OneTimeKeyName, user_id: &UserId, device_id: &DeviceId, key: &OneTimeKey, ) -> Result<bool, DatabaseError>

Idempotently inserts a one-time key for import purposes.

Returns true if a new row was inserted, false if it already existed (i.e. the ON CONFLICT DO NOTHING branch fired). This makes imports safe to resume and replay.

Source

async fn fetch_one_time_keys_counts( &mut self, user_id: &UserId, device_id: &DeviceId, ) -> Result<BTreeMap<OneTimeKeyAlgorithm, UInt>, DatabaseError>

Given a [UserId], returns the counts of OTKs per algorithm they own.

Source

async fn fetch_one_time_keys( &mut self, one_time_keys: &BTreeMap<OwnedUserId, BTreeMap<OwnedDeviceId, OneTimeKeyAlgorithm>>, ) -> Result<OneTimeKeyMap, DatabaseError>

Fetch one one-time key for each requested user’s device and algorithm.

Source

async fn delete_one_time_keys( &mut self, nids: &[i32], ) -> Result<(), DatabaseError>

Deletes a one-time key from the database by its ID.

Returns the number of affected (e.g deleted) rows.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§

Source§

impl<T> OneTimeKeysQueries for T
where T: Database,