pub trait ISaveChangesInterceptor: Send + Sync {
// Provided methods
fn on_saving<'life0, 'life1, 'async_trait>(
&'life0 self,
_ctx: &'life1 SaveChangesContext,
) -> Pin<Box<dyn Future<Output = EFResult<()>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait { ... }
fn on_saved<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
_ctx: &'life1 SaveChangesContext,
_result: &'life2 SaveChangesResultContext,
) -> Pin<Box<dyn Future<Output = EFResult<()>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait { ... }
fn on_save_failed<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
_ctx: &'life1 SaveChangesContext,
_error: &'life2 EFError,
) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait { ... }
}Expand description
Interface for intercepting save_changes() operations.
All methods have default no-op implementations so users only override what they need.
§Lifecycle
on_saving(ctx) �?[execute SQL] �?on_saved(ctx, result)
on_save_failed(ctx, error) (if error)Provided Methods§
Sourcefn on_saving<'life0, 'life1, 'async_trait>(
&'life0 self,
_ctx: &'life1 SaveChangesContext,
) -> Pin<Box<dyn Future<Output = EFResult<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn on_saving<'life0, 'life1, 'async_trait>(
&'life0 self,
_ctx: &'life1 SaveChangesContext,
) -> Pin<Box<dyn Future<Output = EFResult<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Called before SQL commands are executed.
Return Err(...) to abort the save. The transaction will be
rolled back and on_save_failed will NOT be called (this is
a pre-commit rejection, not a database failure).
Sourcefn on_saved<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
_ctx: &'life1 SaveChangesContext,
_result: &'life2 SaveChangesResultContext,
) -> Pin<Box<dyn Future<Output = EFResult<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
fn on_saved<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
_ctx: &'life1 SaveChangesContext,
_result: &'life2 SaveChangesResultContext,
) -> Pin<Box<dyn Future<Output = EFResult<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Called after a successful save (transaction committed).
Sourcefn on_save_failed<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
_ctx: &'life1 SaveChangesContext,
_error: &'life2 EFError,
) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
fn on_save_failed<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
_ctx: &'life1 SaveChangesContext,
_error: &'life2 EFError,
) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Called when the save fails with a database error.
The transaction has already been rolled back at this point. The error is passed by reference for inspection; the interceptor cannot suppress it.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".