Database

Struct Database 

Source
pub struct Database { /* private fields */ }

Implementations§

Source§

impl Database

Source

pub async fn open( location: ConnectionType<'_>, key: &DatabaseKey, ) -> Result<Database, CryptoKeystoreError>

Source

pub async fn location(&self) -> Result<Option<String>, CryptoKeystoreError>

Source

pub async fn conn(&self) -> Result<ConnectionGuard<'_>, CryptoKeystoreError>

Get direct exclusive access to the connection.

Source

pub async fn close(&self) -> Result<(), CryptoKeystoreError>

Source

pub async fn wipe(&self) -> Result<(), CryptoKeystoreError>

Close this database and delete its contents.

Source

pub async fn export_copy( &self, destination_path: &str, ) -> Result<(), CryptoKeystoreError>

Export a copy of the database to the specified path. This creates a fully vacuumed and optimized copy of the database. The copy will be encrypted with the same key as the source database.

§Platform Support

This method is only available on platforms using SQLCipher (not WASM).

§Arguments
  • destination_path - The file path where the database copy should be created
§Errors

Returns an error if:

  • The database is in-memory (cannot export in-memory databases)
  • The destination path is invalid
  • The export operation fails
Source

pub async fn migrate_db_key_type_to_bytes( name: &str, old_key: &str, new_key: &DatabaseKey, ) -> Result<(), CryptoKeystoreError>

Source

pub async fn update_key( &mut self, new_key: &DatabaseKey, ) -> Result<(), CryptoKeystoreError>

Source

pub async fn new_transaction(&self) -> Result<(), CryptoKeystoreError>

Waits for the current transaction to be committed or rolled back, then starts a new one.

Source

pub async fn commit_transaction(&self) -> Result<(), CryptoKeystoreError>

Source

pub async fn rollback_transaction(&self) -> Result<(), CryptoKeystoreError>

Source

pub async fn child_groups( &self, entity: PersistedMlsGroup, ) -> Result<Vec<PersistedMlsGroup>, CryptoKeystoreError>

Source

pub async fn save<'a, E>( &self, entity: E, ) -> Result<<E as EntityBase>::AutoGeneratedFields, CryptoKeystoreError>

Source

pub async fn remove<'a, E>( &self, id: &<E as PrimaryKey>::PrimaryKey, ) -> Result<(), CryptoKeystoreError>

Source

pub async fn remove_borrowed<'a, E>( &self, id: &<E as BorrowPrimaryKey>::BorrowedPrimaryKey, ) -> Result<(), CryptoKeystoreError>

Source

pub async fn find_pending_messages_by_conversation_id( &self, conversation_id: &[u8], ) -> Result<Vec<MlsPendingMessage>, CryptoKeystoreError>

Source

pub async fn remove_pending_messages_by_conversation_id( &self, conversation_id: impl AsRef<[u8]> + Send, ) -> Result<(), CryptoKeystoreError>

Trait Implementations§

Source§

impl Clone for Database

Source§

fn clone(&self) -> Database

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl CryptoKeystoreMls for Database

Source§

fn mls_fetch_keypackages<'life0, 'async_trait, V>( &'life0 self, count: u32, ) -> Pin<Box<dyn Future<Output = Result<Vec<V>, CryptoKeystoreError>> + Send + 'async_trait>>
where 'life0: 'async_trait, V: 'async_trait + MlsEntity, Database: 'async_trait,

Fetches Keypackages Read more
Source§

fn mls_group_exists<'life0, 'async_trait>( &'life0 self, group_id: impl AsRef<[u8]> + Send + 'async_trait, ) -> Pin<Box<dyn Future<Output = bool> + Send + 'async_trait>>
where 'life0: 'async_trait, Database: 'async_trait,

Checks if the given MLS group id exists in the keystore Note: in case of any error, this will return false Read more
Source§

fn mls_group_persist<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, group_id: impl AsRef<[u8]> + Send + 'async_trait, state: &'life1 [u8], parent_group_id: Option<&'life2 [u8]>, ) -> Pin<Box<dyn Future<Output = Result<(), CryptoKeystoreError>> + Send + 'async_trait>>
where 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait, Database: 'async_trait,

Persists a MlsGroup Read more
Source§

fn mls_groups_restore<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = Result<HashMap<Vec<u8>, (Option<Vec<u8>>, Vec<u8>)>, CryptoKeystoreError>> + Send + 'async_trait>>
where 'life0: 'async_trait, Database: 'async_trait,

Loads MlsGroups from the database. It will be returned as a HashMap where the key is the group/conversation id and the value the group state Read more
Source§

fn mls_group_delete<'life0, 'async_trait>( &'life0 self, group_id: impl AsRef<[u8]> + Send + 'async_trait, ) -> Pin<Box<dyn Future<Output = Result<(), CryptoKeystoreError>> + Send + 'async_trait>>
where 'life0: 'async_trait, Database: 'async_trait,

Deletes MlsGroups from the database. Read more
Source§

fn mls_pending_groups_save<'life0, 'life1, 'life2, 'life3, 'async_trait>( &'life0 self, group_id: impl AsRef<[u8]> + Send + 'async_trait, mls_group: &'life1 [u8], custom_configuration: &'life2 [u8], parent_group_id: Option<&'life3 [u8]>, ) -> Pin<Box<dyn Future<Output = Result<(), CryptoKeystoreError>> + Send + 'async_trait>>
where 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait, 'life3: 'async_trait, Database: 'async_trait,

Saves a MlsGroup in a temporary table (typically used in scenarios where the group cannot be committed until the backend acknowledges it, like external commits) Read more
Source§

fn mls_pending_groups_load<'life0, 'async_trait>( &'life0 self, group_id: impl AsRef<[u8]> + Send + 'async_trait, ) -> Pin<Box<dyn Future<Output = Result<Option<(Vec<u8>, Vec<u8>)>, CryptoKeystoreError>> + Send + 'async_trait>>
where 'life0: 'async_trait, Database: 'async_trait,

Loads a temporary MlsGroup and its configuration from the database Read more
Source§

fn mls_pending_groups_delete<'life0, 'async_trait>( &'life0 self, group_id: impl AsRef<[u8]> + Send + 'async_trait, ) -> Pin<Box<dyn Future<Output = Result<(), CryptoKeystoreError>> + Send + 'async_trait>>
where 'life0: 'async_trait, Database: 'async_trait,

Deletes a temporary MlsGroup from the database Read more
Source§

fn save_e2ei_enrollment<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, id: &'life1 [u8], content: &'life2 [u8], ) -> Pin<Box<dyn Future<Output = Result<(), CryptoKeystoreError>> + Send + 'async_trait>>
where 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait, Database: 'async_trait,

Persists an enrollment instance Read more
Source§

fn pop_e2ei_enrollment<'life0, 'life1, 'async_trait>( &'life0 self, id: &'life1 [u8], ) -> Pin<Box<dyn Future<Output = Result<Option<Vec<u8>>, CryptoKeystoreError>> + Send + 'async_trait>>
where 'life0: 'async_trait, 'life1: 'async_trait, Database: 'async_trait,

Fetches and delete the enrollment instance Read more
Source§

impl CryptoKeystoreProteus for Database

Source§

fn proteus_store_prekey<'life0, 'life1, 'async_trait>( &'life0 self, id: u16, prekey: &'life1 [u8], ) -> Pin<Box<dyn Future<Output = Result<(), CryptoKeystoreError>> + Send + 'async_trait>>
where 'life0: 'async_trait, 'life1: 'async_trait, Database: 'async_trait,

Source§

impl Debug for Database

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
Source§

impl FetchFromDatabase for Database

Source§

fn get<'life0, 'life1, 'async_trait, E>( &'life0 self, id: &'life1 <E as PrimaryKey>::PrimaryKey, ) -> Pin<Box<dyn Future<Output = Result<Option<E>, CryptoKeystoreError>> + Send + 'async_trait>>
where 'life0: 'async_trait, 'life1: 'async_trait, E: Entity<ConnectionType = SqlCipherConnection> + Clone + Send + Sync + 'async_trait, Database: 'async_trait,

Get an instance of E from the database by its primary key.
Source§

fn get_borrowed<'life0, 'life1, 'async_trait, E>( &'life0 self, id: &'life1 <E as BorrowPrimaryKey>::BorrowedPrimaryKey, ) -> Pin<Box<dyn Future<Output = Result<Option<E>, CryptoKeystoreError>> + Send + 'async_trait>>
where 'life0: 'async_trait, 'life1: 'async_trait, E: EntityGetBorrowed<ConnectionType = SqlCipherConnection> + Clone + Send + Sync + 'async_trait, <E as PrimaryKey>::PrimaryKey: Borrow<<E as BorrowPrimaryKey>::BorrowedPrimaryKey>, &'a <E as BorrowPrimaryKey>::BorrowedPrimaryKey: for<'a> KeyType, Database: 'async_trait,

Get an instance of E from the database by the borrowed form of its primary key.
Source§

fn count<'life0, 'async_trait, E>( &'life0 self, ) -> Pin<Box<dyn Future<Output = Result<u32, CryptoKeystoreError>> + Send + 'async_trait>>
where 'life0: 'async_trait, E: Entity<ConnectionType = SqlCipherConnection> + Clone + Send + Sync + 'async_trait, Database: 'async_trait,

Count the number of Es in the database.
Source§

fn load_all<'life0, 'async_trait, E>( &'life0 self, ) -> Pin<Box<dyn Future<Output = Result<Vec<E>, CryptoKeystoreError>> + Send + 'async_trait>>
where 'life0: 'async_trait, E: Entity<ConnectionType = SqlCipherConnection> + Clone + Send + Sync + 'async_trait, Database: 'async_trait,

Load all Es from the database.
Source§

fn search<'life0, 'life1, 'async_trait, E, SearchKey>( &'life0 self, search_key: &'life1 SearchKey, ) -> Pin<Box<dyn Future<Output = Result<Vec<E>, CryptoKeystoreError>> + Send + 'async_trait>>
where 'life0: 'async_trait, 'life1: 'async_trait, E: Entity<ConnectionType = SqlCipherConnection> + SearchableEntity<SearchKey> + Clone + Send + Sync + 'async_trait, SearchKey: KeyType + 'async_trait, Database: 'async_trait,

Search for relevant instances of E given a search key.
Source§

fn get_unique<'a, 'life0, 'async_trait, U>( &'life0 self, ) -> Pin<Box<dyn Future<Output = Result<Option<U>, CryptoKeystoreError>> + Send + 'async_trait>>
where 'a: 'async_trait, 'life0: 'async_trait, U: UniqueEntityExt<'a, ConnectionType = SqlCipherConnection> + Entity + Clone + Send + Sync + 'async_trait, Self: 'async_trait,

Get the requested unique entity from the database.
Source§

fn exists<'a, 'life0, 'async_trait, U>( &'life0 self, ) -> Pin<Box<dyn Future<Output = Result<bool, CryptoKeystoreError>> + Send + 'async_trait>>
where 'a: 'async_trait, 'life0: 'async_trait, U: UniqueEntityExt<'a, ConnectionType = SqlCipherConnection> + Entity + Clone + Send + Sync + 'async_trait, Self: 'async_trait,

Determine whether a unique entity is present in the database.
Source§

impl OpenMlsKeyStore for Database

Source§

type Error = CryptoKeystoreError

The error type returned by the [OpenMlsKeyStore].
Source§

fn store<'life0, 'life1, 'life2, 'async_trait, V>( &'life0 self, k: &'life1 [u8], v: &'life2 V, ) -> Pin<Box<dyn Future<Output = Result<(), <Database as OpenMlsKeyStore>::Error>> + Send + 'async_trait>>
where 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait, Database: Sized + 'async_trait, V: 'async_trait + MlsEntity + Sync,

Store a value v that implements the [MlsEntity] trait for serialization for ID k. Read more
Source§

fn read<'life0, 'life1, 'async_trait, V>( &'life0 self, k: &'life1 [u8], ) -> Pin<Box<dyn Future<Output = Option<V>> + Send + 'async_trait>>
where 'life0: 'async_trait, 'life1: 'async_trait, Database: Sized + 'async_trait, V: 'async_trait + MlsEntity,

Read and return a value stored for ID k that implements the [MlsEntity] trait for deserialization. Read more
Source§

fn delete<'life0, 'life1, 'async_trait, V>( &'life0 self, k: &'life1 [u8], ) -> Pin<Box<dyn Future<Output = Result<(), <Database as OpenMlsKeyStore>::Error>> + Send + 'async_trait>>
where 'life0: 'async_trait, 'life1: 'async_trait, V: 'async_trait + MlsEntity, Database: 'async_trait,

Delete a value stored for ID k. Read more
Source§

impl PreKeyStore for Database

Source§

type Error = CryptoKeystoreError

Source§

fn prekey<'life0, 'async_trait>( &'life0 mut self, id: u16, ) -> Pin<Box<dyn Future<Output = Result<Option<Vec<u8>>, <Database as PreKeyStore>::Error>> + Send + 'async_trait>>
where 'life0: 'async_trait, Database: 'async_trait,

Lookup prekey by ID.
Source§

fn remove<'life0, 'async_trait>( &'life0 mut self, id: u16, ) -> Pin<Box<dyn Future<Output = Result<(), <Database as PreKeyStore>::Error>> + Send + 'async_trait>>
where 'life0: 'async_trait, Database: 'async_trait,

Remove prekey by ID.
Source§

impl Send for Database

Source§

impl Sync for Database

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

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

fn clone_into(&self, target: &mut T)

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

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

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

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

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

§

fn vzip(self) -> V

§

impl<T> ErasedDestructor for T
where T: 'static,

§

impl<T> MaybeSendSync for T