pub trait FlozHooks: Sized {
// Provided methods
fn before_create(&self) -> Result<(), FlozError> { ... }
fn after_create(&self) { ... }
fn before_save(&mut self) -> Result<(), FlozError> { ... }
fn after_save(&self) { ... }
fn before_delete(&self) -> Result<(), FlozError> { ... }
fn after_delete(&self) { ... }
}Expand description
Lifecycle hooks for database operations.
before_* hooks return Result — returning Err(...) aborts the operation.
after_* hooks are fire-and-forget notifications.
Provided Methods§
Sourcefn before_create(&self) -> Result<(), FlozError>
fn before_create(&self) -> Result<(), FlozError>
Called before create(). Return Err to abort the INSERT.
Takes &self (immutable). Modify fields before calling create().
Sourcefn after_create(&self)
fn after_create(&self)
Called after a successful create().
Sourcefn before_save(&mut self) -> Result<(), FlozError>
fn before_save(&mut self) -> Result<(), FlozError>
Called before save(). Can modify the entity (e.g., set updated_at).
Return Err to abort the UPDATE.
If this hook sets a field via set_*(), the field becomes dirty and
will be included in the UPDATE statement.
Sourcefn after_save(&self)
fn after_save(&self)
Called after a successful save().
Sourcefn before_delete(&self) -> Result<(), FlozError>
fn before_delete(&self) -> Result<(), FlozError>
Called before delete(). Return Err to abort the DELETE.
Sourcefn after_delete(&self)
fn after_delete(&self)
Called after a successful delete().
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".