pub trait ITransaction: Send + Sync {
// Required methods
fn commit(
self: Box<Self>,
) -> Pin<Box<dyn Future<Output = EFResult<()>> + Send + 'static>>;
fn rollback(
self: Box<Self>,
) -> Pin<Box<dyn Future<Output = EFResult<()>> + Send + 'static>>;
fn create_point<'a>(
&'a mut self,
name: &'a str,
) -> Pin<Box<dyn Future<Output = EFResult<()>> + Send + 'a>>;
fn release_point<'a>(
&'a mut self,
name: &'a str,
) -> Pin<Box<dyn Future<Output = EFResult<()>> + Send + 'a>>;
fn rollback_point<'a>(
&'a mut self,
name: &'a str,
) -> Pin<Box<dyn Future<Output = EFResult<()>> + Send + 'a>>;
fn set_isolation<'a>(
&'a mut self,
level: IsolationLevel,
) -> Pin<Box<dyn Future<Output = EFResult<()>> + Send + 'a>>;
fn connection(&mut self) -> &mut (dyn IAsyncConnection + Send);
}Expand description
Transaction handle abstracting the Priority 2 connection-level transaction methods.
commit / rollback consume self: Box<Self> to make use-after-commit
impossible at the type level. Savepoint and isolation methods take
&mut self and return a boxed future borrowing the handle.
Send + Sync is required so that Box<dyn ITransaction> can be stored in
DbContext (which DI registers as Scoped, requiring Send + Sync).
Required Methods§
Sourcefn commit(
self: Box<Self>,
) -> Pin<Box<dyn Future<Output = EFResult<()>> + Send + 'static>>
fn commit( self: Box<Self>, ) -> Pin<Box<dyn Future<Output = EFResult<()>> + Send + 'static>>
Commits the transaction and consumes the handle.
Sourcefn rollback(
self: Box<Self>,
) -> Pin<Box<dyn Future<Output = EFResult<()>> + Send + 'static>>
fn rollback( self: Box<Self>, ) -> Pin<Box<dyn Future<Output = EFResult<()>> + Send + 'static>>
Rolls back the transaction and consumes the handle.
Sourcefn create_point<'a>(
&'a mut self,
name: &'a str,
) -> Pin<Box<dyn Future<Output = EFResult<()>> + Send + 'a>>
fn create_point<'a>( &'a mut self, name: &'a str, ) -> Pin<Box<dyn Future<Output = EFResult<()>> + Send + 'a>>
Creates a savepoint within the current transaction.
Sourcefn release_point<'a>(
&'a mut self,
name: &'a str,
) -> Pin<Box<dyn Future<Output = EFResult<()>> + Send + 'a>>
fn release_point<'a>( &'a mut self, name: &'a str, ) -> Pin<Box<dyn Future<Output = EFResult<()>> + Send + 'a>>
Releases (commits) a previously created savepoint.
Sourcefn rollback_point<'a>(
&'a mut self,
name: &'a str,
) -> Pin<Box<dyn Future<Output = EFResult<()>> + Send + 'a>>
fn rollback_point<'a>( &'a mut self, name: &'a str, ) -> Pin<Box<dyn Future<Output = EFResult<()>> + Send + 'a>>
Rolls back to the named savepoint, preserving the outer transaction.
Sourcefn set_isolation<'a>(
&'a mut self,
level: IsolationLevel,
) -> Pin<Box<dyn Future<Output = EFResult<()>> + Send + 'a>>
fn set_isolation<'a>( &'a mut self, level: IsolationLevel, ) -> Pin<Box<dyn Future<Output = EFResult<()>> + Send + 'a>>
Sets the isolation level of the current transaction.
Sourcefn connection(&mut self) -> &mut (dyn IAsyncConnection + Send)
fn connection(&mut self) -> &mut (dyn IAsyncConnection + Send)
Exposes the underlying connection so save_changes() can reuse the
ambient transaction’s connection.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".