pub trait FallbackKeysQueries: Database {
// Provided methods
async fn upsert_fallback_key(
&mut self,
key_algorithm: &OneTimeKeyAlgorithm,
key_name: &OneTimeKeyName,
user_id: &UserId,
device_id: &DeviceId,
key: &OneTimeKey,
) -> Result<(), DatabaseError> { ... }
async fn import_fallback_key(
&mut self,
key_algorithm: &OneTimeKeyAlgorithm,
key_name: &OneTimeKeyName,
user_id: &UserId,
device_id: &DeviceId,
key: &OneTimeKey,
used: bool,
) -> Result<bool, DatabaseError> { ... }
async fn fetch_fallback_keys(
&mut self,
fallback_keys: &BTreeMap<OwnedUserId, BTreeMap<OwnedDeviceId, OneTimeKeyAlgorithm>>,
) -> Result<OneTimeKeyMap, DatabaseError> { ... }
async fn set_fallback_keys_used(
&mut self,
nids: &[i32],
) -> Result<(), DatabaseError> { ... }
async fn fetch_unused_fallback_keys_algorithms(
&mut self,
user_id: &UserId,
device_id: &DeviceId,
) -> Result<Vec<OneTimeKeyAlgorithm>, DatabaseError> { ... }
}Expand description
Queries related to the fallback_keys table.
Provided Methods§
Sourceasync fn upsert_fallback_key(
&mut self,
key_algorithm: &OneTimeKeyAlgorithm,
key_name: &OneTimeKeyName,
user_id: &UserId,
device_id: &DeviceId,
key: &OneTimeKey,
) -> Result<(), DatabaseError>
async fn upsert_fallback_key( &mut self, key_algorithm: &OneTimeKeyAlgorithm, key_name: &OneTimeKeyName, user_id: &UserId, device_id: &DeviceId, key: &OneTimeKey, ) -> Result<(), DatabaseError>
Inserts fallback keys for a user into the database.
§Conflict resolution
If a fallback key for the same device and algorithm is already present in the database, it will get overwritten by the given new one.
Sourceasync fn import_fallback_key(
&mut self,
key_algorithm: &OneTimeKeyAlgorithm,
key_name: &OneTimeKeyName,
user_id: &UserId,
device_id: &DeviceId,
key: &OneTimeKey,
used: bool,
) -> Result<bool, DatabaseError>
async fn import_fallback_key( &mut self, key_algorithm: &OneTimeKeyAlgorithm, key_name: &OneTimeKeyName, user_id: &UserId, device_id: &DeviceId, key: &OneTimeKey, used: bool, ) -> Result<bool, DatabaseError>
Idempotently inserts a fallback key for import purposes, preserving the
used flag from the export.
Returns true if a new row was inserted, false if a fallback key
already exists with the same device ID and algorithm. This makes imports
safe to resume and replay an import.
Sourceasync fn fetch_fallback_keys(
&mut self,
fallback_keys: &BTreeMap<OwnedUserId, BTreeMap<OwnedDeviceId, OneTimeKeyAlgorithm>>,
) -> Result<OneTimeKeyMap, DatabaseError>
async fn fetch_fallback_keys( &mut self, fallback_keys: &BTreeMap<OwnedUserId, BTreeMap<OwnedDeviceId, OneTimeKeyAlgorithm>>, ) -> Result<OneTimeKeyMap, DatabaseError>
Fetches all the requested fallback keys
Sourceasync fn set_fallback_keys_used(
&mut self,
nids: &[i32],
) -> Result<(), DatabaseError>
async fn set_fallback_keys_used( &mut self, nids: &[i32], ) -> Result<(), DatabaseError>
Sets all the given fallback keys’ used field to true.
Returns the number of affected (i.e. modified) rows.
Sourceasync fn fetch_unused_fallback_keys_algorithms(
&mut self,
user_id: &UserId,
device_id: &DeviceId,
) -> Result<Vec<OneTimeKeyAlgorithm>, DatabaseError>
async fn fetch_unused_fallback_keys_algorithms( &mut self, user_id: &UserId, device_id: &DeviceId, ) -> Result<Vec<OneTimeKeyAlgorithm>, DatabaseError>
Fetches the list of unused fallback keys algorithms stored for the given user’s device.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".