pub trait TransactionParticipant: 'static {
// Required methods
fn begin(
&self,
connection: &mut dyn SqliteConnection,
origin: WriteOrigin,
) -> Result<(), DbError>;
fn before_commit(
&self,
connection: &mut dyn SqliteConnection,
origin: WriteOrigin,
changes: &[RowChange],
) -> Result<Refresh, DbError>;
}Expand description
Queue-confined extension participating in the SAME SQL transaction as model changes.
Callbacks must use only the supplied connection, never re-enter the container, commit,
roll back, perform network I/O, or mutate reactive models. Returning an error aborts the
transaction. before_commit runs after worker reactions and intermediate saves settle.
Persist extension state transactionally; callbacks may run again following a rollback.
Required Methods§
Sourcefn begin(
&self,
connection: &mut dyn SqliteConnection,
origin: WriteOrigin,
) -> Result<(), DbError>
fn begin( &self, connection: &mut dyn SqliteConnection, origin: WriteOrigin, ) -> Result<(), DbError>
Sourcefn before_commit(
&self,
connection: &mut dyn SqliteConnection,
origin: WriteOrigin,
changes: &[RowChange],
) -> Result<Refresh, DbError>
fn before_commit( &self, connection: &mut dyn SqliteConnection, origin: WriteOrigin, changes: &[RowChange], ) -> Result<Refresh, DbError>
The transaction’s folded change set is changes: accumulated across every flush in
the transaction (a worker job’s intermediate saves included), empty again after a
rollback. The answer names the cache refresh to run after a successful COMMIT, before
the work is acknowledged; a refresh failure surfaces as
DbErrorKind::CommittedRefreshFailed (the data is durable, it cannot roll back).
§Errors
An error aborts the transaction.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".