Skip to main content

ModelHooks

Trait ModelHooks 

Source
pub trait ModelHooks {
    // Provided methods
    fn before_save(&mut self) -> impl Future<Output = Result<(), Error>> + Send { ... }
    fn after_save(&mut self) -> impl Future<Output = Result<(), Error>> + Send { ... }
}
Expand description

Hooks that can be implemented to run logic before or after database operations.

Provided Methods§

Source

fn before_save(&mut self) -> impl Future<Output = Result<(), Error>> + Send

Ran before a model is saved to the database.

Source

fn after_save(&mut self) -> impl Future<Output = Result<(), Error>> + Send

Ran after a model is successfully saved to the database.

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§