UnifiedEntityDatabaseMutation

Trait UnifiedEntityDatabaseMutation 

Source
pub trait UnifiedEntityDatabaseMutation: UnifiedEntity {
    type AutoGeneratedFields: Default;

    // Required methods
    fn save(&self, tx: &Transaction<'_>) -> CryptoKeystoreResult<()>;
    fn count(tx: &Transaction<'_>) -> CryptoKeystoreResult<u32>;
    fn delete(
        tx: &Transaction<'_>,
        id: &Self::PrimaryKey,
    ) -> CryptoKeystoreResult<bool>;

    // Provided method
    fn pre_save(&mut self) -> CryptoKeystoreResult<Self::AutoGeneratedFields> { ... }
}
Expand description

Extend an Entity with db-mutating operations which can be performed when provided with a transaction.

Required Associated Types§

Source

type AutoGeneratedFields: Default

The pre_save method might generate or update some fields of the item. The canonical example is an updated_at field.

This type must contain a copy of each modification to the item, so that the caller of a .save(entity) function can know what has changed and what the new values are.

For types which are not edited on save, () is perfectly acceptable for this type.

Required Methods§

Source

fn save(&self, tx: &Transaction<'_>) -> CryptoKeystoreResult<()>

Use the transaction’s interface to save this entity to the database

Source

fn count(tx: &Transaction<'_>) -> CryptoKeystoreResult<u32>

Use the transaction’s interface to count the number of entities of this type in the database.

Source

fn delete( tx: &Transaction<'_>, id: &Self::PrimaryKey, ) -> CryptoKeystoreResult<bool>

Use the transaction’s inteface to delete this entity from the database.

Returns true if at least one entity was deleted, or false if the id was not found in the database.

For entites whose primary key has a distinct borrowed type, it is best to implement this as a direct passthrough:

fn delete(tx: &Self::Transaction, key: &Self::PrimaryKey) -> CoreCryptoKeystoreResult<bool> {
    <Self as EntityTransactionDeleteBorrowed<'a>>::delete_borrowed(tx, id).await
}

Provided Methods§

Source

fn pre_save(&mut self) -> CryptoKeystoreResult<Self::AutoGeneratedFields>

Adjust self before saving.

This will be called by the transaction’s implementation of save_mut and should not be called as part of the save implementation.

Returns, in a format specific to the entity, all the data which has been generated or updated within this method.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§

Source§

impl UnifiedEntityDatabaseMutation for E2eiCrl

Source§

impl UnifiedEntityDatabaseMutation for E2eiIntermediateCert

Source§

impl UnifiedEntityDatabaseMutation for MlsPendingMessage

Source§

impl UnifiedEntityDatabaseMutation for PersistedMlsGroup

Source§

impl UnifiedEntityDatabaseMutation for PersistedMlsPendingGroup

Source§

impl UnifiedEntityDatabaseMutation for ProteusIdentity

Source§

impl UnifiedEntityDatabaseMutation for ProteusPrekey

Source§

impl UnifiedEntityDatabaseMutation for ProteusSession

Source§

impl UnifiedEntityDatabaseMutation for StoredBufferedCommit

Source§

impl UnifiedEntityDatabaseMutation for StoredCredential

Source§

impl UnifiedEntityDatabaseMutation for StoredE2eiEnrollment

Source§

impl UnifiedEntityDatabaseMutation for StoredEncryptionKeyPair

Source§

impl UnifiedEntityDatabaseMutation for StoredEpochEncryptionKeypair

Source§

impl UnifiedEntityDatabaseMutation for StoredHpkePrivateKey

Source§

impl UnifiedEntityDatabaseMutation for StoredKeypackage

Source§

impl UnifiedEntityDatabaseMutation for StoredPskBundle

Source§

impl<T> UnifiedEntityDatabaseMutation for T