Skip to main content

ActiveModelBehavior

Trait ActiveModelBehavior 

Source
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.

Implement with an empty body to accept the defaults:

ⓘ
impl ActiveModelBehavior for ActiveModel {}

Provided Methods§

Source

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.

Source

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.

Source

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.

Source

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".

Implementors§