pub trait ActiveModelBehavior: ActiveModelTrait {
// Provided methods
fn before_save<'life0, 'async_trait, C>(
self,
_db: &'life0 C,
_insert: bool,
) -> Pin<Box<dyn Future<Output = Result<Self>> + Send + 'async_trait>>
where C: 'async_trait + ConnectionTrait,
Self: Send + 'async_trait,
'life0: 'async_trait { ... }
fn after_save<'life0, 'async_trait, C>(
model: <Self::Entity as EntityTrait>::Model,
_db: &'life0 C,
_insert: bool,
) -> Pin<Box<dyn Future<Output = Result<<Self::Entity as EntityTrait>::Model>> + Send + 'async_trait>>
where C: 'async_trait + ConnectionTrait,
Self: Send + 'async_trait,
'life0: 'async_trait { ... }
fn before_delete<'life0, 'async_trait, C>(
self,
_db: &'life0 C,
) -> Pin<Box<dyn Future<Output = Result<Self>> + Send + 'async_trait>>
where C: 'async_trait + ConnectionTrait,
Self: Send + 'async_trait,
'life0: 'async_trait { ... }
fn after_delete<'life0, 'async_trait, C>(
self,
_db: &'life0 C,
) -> Pin<Box<dyn Future<Output = Result<Self>> + Send + 'async_trait>>
where C: 'async_trait + ConnectionTrait,
Self: Send + 'async_trait,
'life0: 'async_trait { ... }
}Expand description
Hooks around writes, with no-op defaults.
They run around the methods of ActiveModelTrait only (insert,
update, save and delete); statements built from the entity, such
as Entity::insert or Entity::delete_many, bypass them. An error from an after_* hook is returned once the
statement has run, so outside a transaction the write stays applied.
Implement with an empty body to accept the defaults:
impl ActiveModelBehavior for ActiveModel {}Provided Methods§
Sourcefn before_save<'life0, 'async_trait, C>(
self,
_db: &'life0 C,
_insert: bool,
) -> Pin<Box<dyn Future<Output = Result<Self>> + Send + 'async_trait>>where
C: 'async_trait + ConnectionTrait,
Self: Send + 'async_trait,
'life0: 'async_trait,
fn before_save<'life0, 'async_trait, C>(
self,
_db: &'life0 C,
_insert: bool,
) -> Pin<Box<dyn Future<Output = Result<Self>> + Send + 'async_trait>>where
C: 'async_trait + ConnectionTrait,
Self: Send + 'async_trait,
'life0: 'async_trait,
Called before insert (insert == true) or update; may rewrite the active model.
§Errors
Returns whatever the implementation chooses to fail with; the default never fails.
Sourcefn after_save<'life0, 'async_trait, C>(
model: <Self::Entity as EntityTrait>::Model,
_db: &'life0 C,
_insert: bool,
) -> Pin<Box<dyn Future<Output = Result<<Self::Entity as EntityTrait>::Model>> + Send + 'async_trait>>where
C: 'async_trait + ConnectionTrait,
Self: Send + 'async_trait,
'life0: 'async_trait,
fn after_save<'life0, 'async_trait, C>(
model: <Self::Entity as EntityTrait>::Model,
_db: &'life0 C,
_insert: bool,
) -> Pin<Box<dyn Future<Output = Result<<Self::Entity as EntityTrait>::Model>> + Send + 'async_trait>>where
C: 'async_trait + ConnectionTrait,
Self: Send + 'async_trait,
'life0: 'async_trait,
Called after a successful insert or update with the stored model.
§Errors
Returns whatever the implementation chooses to fail with; the default never fails.
Sourcefn before_delete<'life0, 'async_trait, C>(
self,
_db: &'life0 C,
) -> Pin<Box<dyn Future<Output = Result<Self>> + Send + 'async_trait>>where
C: 'async_trait + ConnectionTrait,
Self: Send + 'async_trait,
'life0: 'async_trait,
fn before_delete<'life0, 'async_trait, C>(
self,
_db: &'life0 C,
) -> Pin<Box<dyn Future<Output = Result<Self>> + Send + 'async_trait>>where
C: 'async_trait + ConnectionTrait,
Self: Send + 'async_trait,
'life0: 'async_trait,
Called before delete; may rewrite the active model.
§Errors
Returns whatever the implementation chooses to fail with; the default never fails.
Sourcefn after_delete<'life0, 'async_trait, C>(
self,
_db: &'life0 C,
) -> Pin<Box<dyn Future<Output = Result<Self>> + Send + 'async_trait>>where
C: 'async_trait + ConnectionTrait,
Self: Send + 'async_trait,
'life0: 'async_trait,
fn after_delete<'life0, 'async_trait, C>(
self,
_db: &'life0 C,
) -> Pin<Box<dyn Future<Output = Result<Self>> + Send + 'async_trait>>where
C: 'async_trait + ConnectionTrait,
Self: Send + 'async_trait,
'life0: 'async_trait,
Called after a successful delete.
§Errors
Returns whatever the implementation chooses to fail with; the default never fails.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".