Skip to main content

Hooks

Trait Hooks 

Source
pub trait Hooks:
    Sized
    + Send
    + Sync
    + 'static {
    // Provided methods
    fn before_save<'life0, 'life1, 'async_trait>(
        &'life0 mut self,
        _pool: &'life1 PgPool,
    ) -> Pin<Box<dyn Future<Output = OrmResult<()>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait { ... }
    fn after_save<'life0, 'life1, 'async_trait>(
        &'life0 self,
        _pool: &'life1 PgPool,
    ) -> Pin<Box<dyn Future<Output = OrmResult<()>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait { ... }
    fn before_create<'life0, 'life1, 'async_trait>(
        &'life0 mut self,
        _pool: &'life1 PgPool,
    ) -> Pin<Box<dyn Future<Output = OrmResult<()>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait { ... }
    fn after_create<'life0, 'life1, 'async_trait>(
        &'life0 self,
        _pool: &'life1 PgPool,
    ) -> Pin<Box<dyn Future<Output = OrmResult<()>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait { ... }
    fn before_update<'life0, 'life1, 'async_trait>(
        &'life0 mut self,
        _pool: &'life1 PgPool,
    ) -> Pin<Box<dyn Future<Output = OrmResult<()>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait { ... }
    fn after_update<'life0, 'life1, 'async_trait>(
        &'life0 self,
        _pool: &'life1 PgPool,
    ) -> Pin<Box<dyn Future<Output = OrmResult<()>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait { ... }
    fn before_delete<'life0, 'life1, 'async_trait>(
        &'life0 self,
        _pool: &'life1 PgPool,
    ) -> Pin<Box<dyn Future<Output = OrmResult<()>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait { ... }
    fn after_delete<'life0, 'life1, 'async_trait>(
        &'life0 self,
        _pool: &'life1 PgPool,
    ) -> Pin<Box<dyn Future<Output = OrmResult<()>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait { ... }
}
Expand description

Хуки жизненного цикла модели.

Реализуйте только те методы, которые нужны. Все методы по умолчанию — no-op (возвращают Ok(())).

Provided Methods§

Source

fn before_save<'life0, 'life1, 'async_trait>( &'life0 mut self, _pool: &'life1 PgPool, ) -> Pin<Box<dyn Future<Output = OrmResult<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Перед любым сохранением (INSERT или UPDATE).

Source

fn after_save<'life0, 'life1, 'async_trait>( &'life0 self, _pool: &'life1 PgPool, ) -> Pin<Box<dyn Future<Output = OrmResult<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

После любого сохранения.

Source

fn before_create<'life0, 'life1, 'async_trait>( &'life0 mut self, _pool: &'life1 PgPool, ) -> Pin<Box<dyn Future<Output = OrmResult<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Перед INSERT.

Source

fn after_create<'life0, 'life1, 'async_trait>( &'life0 self, _pool: &'life1 PgPool, ) -> Pin<Box<dyn Future<Output = OrmResult<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

После INSERT.

Source

fn before_update<'life0, 'life1, 'async_trait>( &'life0 mut self, _pool: &'life1 PgPool, ) -> Pin<Box<dyn Future<Output = OrmResult<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Перед UPDATE.

Source

fn after_update<'life0, 'life1, 'async_trait>( &'life0 self, _pool: &'life1 PgPool, ) -> Pin<Box<dyn Future<Output = OrmResult<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

После UPDATE.

Source

fn before_delete<'life0, 'life1, 'async_trait>( &'life0 self, _pool: &'life1 PgPool, ) -> Pin<Box<dyn Future<Output = OrmResult<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Перед DELETE.

Source

fn after_delete<'life0, 'life1, 'async_trait>( &'life0 self, _pool: &'life1 PgPool, ) -> Pin<Box<dyn Future<Output = OrmResult<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

После DELETE.

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§