pub trait EntityDatabaseMutation<'a>: Entity<ConnectionType = KeystoreDatabaseConnection> {
type Transaction: 'a;
// Required methods
fn save<'life0, 'async_trait>(
&'a self,
tx: &'life0 Self::Transaction,
) -> Pin<Box<dyn Future<Output = CryptoKeystoreResult<()>> + Send + 'async_trait>>
where Self: 'async_trait,
'a: 'async_trait,
'life0: 'async_trait;
fn count<'life0, 'async_trait>(
tx: &'life0 Self::Transaction,
) -> Pin<Box<dyn Future<Output = CryptoKeystoreResult<u32>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait;
fn delete<'life0, 'life1, 'async_trait>(
tx: &'life0 Self::Transaction,
id: &'life1 <Self as Entity>::PrimaryKey,
) -> Pin<Box<dyn Future<Output = CryptoKeystoreResult<bool>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait;
// Provided method
fn pre_save<'life0, 'async_trait>(
&'life0 mut self,
) -> Pin<Box<dyn Future<Output = CryptoKeystoreResult<Self::AutoGeneratedFields>> + Send + 'async_trait>>
where Self: Send + 'async_trait,
'life0: 'async_trait { ... }
}Expand description
Extend an Entity with db-mutating operations which can be performed when provided with a transaction.
Required Associated Types§
type Transaction: 'a
Required Methods§
Sourcefn save<'life0, 'async_trait>(
&'a self,
tx: &'life0 Self::Transaction,
) -> Pin<Box<dyn Future<Output = CryptoKeystoreResult<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'a: 'async_trait,
'life0: 'async_trait,
fn save<'life0, 'async_trait>(
&'a self,
tx: &'life0 Self::Transaction,
) -> Pin<Box<dyn Future<Output = CryptoKeystoreResult<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'a: 'async_trait,
'life0: 'async_trait,
Use the transaction’s interface to save this entity to the database
Sourcefn count<'life0, 'async_trait>(
tx: &'life0 Self::Transaction,
) -> Pin<Box<dyn Future<Output = CryptoKeystoreResult<u32>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn count<'life0, 'async_trait>(
tx: &'life0 Self::Transaction,
) -> Pin<Box<dyn Future<Output = CryptoKeystoreResult<u32>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Use the transaction’s interface to count the number of entities of this type in the database.
Sourcefn delete<'life0, 'life1, 'async_trait>(
tx: &'life0 Self::Transaction,
id: &'life1 <Self as Entity>::PrimaryKey,
) -> Pin<Box<dyn Future<Output = CryptoKeystoreResult<bool>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn delete<'life0, 'life1, 'async_trait>(
tx: &'life0 Self::Transaction,
id: &'life1 <Self as Entity>::PrimaryKey,
) -> Pin<Box<dyn Future<Output = CryptoKeystoreResult<bool>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
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:
async fn delete(tx: &Self::Transaction, key: &Self::PrimaryKey) -> CoreCryptoKeystoreResult<bool> {
<Self as EntityTransactionDeleteBorrowed<'a>>::delete_borrowed(tx, id).await
}Provided Methods§
Sourcefn pre_save<'life0, 'async_trait>(
&'life0 mut self,
) -> Pin<Box<dyn Future<Output = CryptoKeystoreResult<Self::AutoGeneratedFields>> + Send + 'async_trait>>where
Self: Send + 'async_trait,
'life0: 'async_trait,
fn pre_save<'life0, 'async_trait>(
&'life0 mut self,
) -> Pin<Box<dyn Future<Output = CryptoKeystoreResult<Self::AutoGeneratedFields>> + Send + 'async_trait>>where
Self: Send + 'async_trait,
'life0: 'async_trait,
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.
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.