Struct rbatis::executor::RBatisTxExecutor
source · pub struct RBatisTxExecutor {
pub tx_id: i64,
pub conn: Mutex<Box<dyn Connection>>,
pub rb: RBatis,
pub done: bool,
}
Fields§
§tx_id: i64
§conn: Mutex<Box<dyn Connection>>
§rb: RBatis
§done: bool
if tx call .commit() or .rollback() done = true. if tx not call .commit() or .rollback() done = false
Implementations§
source§impl<'a> RBatisTxExecutor
impl<'a> RBatisTxExecutor
pub fn new(rb: RBatis, conn: Box<dyn Connection>) -> Self
sourcepub async fn query_decode<T>(
&self,
sql: &str,
args: Vec<Value>,
) -> Result<T, Error>where
T: DeserializeOwned,
pub async fn query_decode<T>(
&self,
sql: &str,
args: Vec<Value>,
) -> Result<T, Error>where
T: DeserializeOwned,
query and decode
pub fn begin(self) -> BoxFuture<'static, Result<Self, Error>>
pub fn rollback(&mut self) -> BoxFuture<'_, Result<(), Error>>
pub fn commit(&mut self) -> BoxFuture<'_, Result<(), Error>>
source§impl RBatisTxExecutor
impl RBatisTxExecutor
pub fn take_conn(self) -> Option<Box<dyn Connection>>
source§impl RBatisTxExecutor
impl RBatisTxExecutor
sourcepub fn defer_async<F>(
self,
callback: fn(s: RBatisTxExecutor) -> F,
) -> RBatisTxExecutorGuard
pub fn defer_async<F>( self, callback: fn(s: RBatisTxExecutor) -> F, ) -> RBatisTxExecutorGuard
defer and use future method for example:
use rbatis::executor::RBatisTxExecutor;
use rbatis::{Error, RBatis};
async fn test_tx(tx:RBatisTxExecutor) -> Result<(),Error>{
tx.defer_async(|mut tx| async move {
tx.rollback().await;
});
Ok(())
}
Trait Implementations§
source§impl Debug for RBatisTxExecutor
impl Debug for RBatisTxExecutor
source§impl Executor for RBatisTxExecutor
impl Executor for RBatisTxExecutor
Auto Trait Implementations§
impl !Freeze for RBatisTxExecutor
impl !RefUnwindSafe for RBatisTxExecutor
impl Send for RBatisTxExecutor
impl Sync for RBatisTxExecutor
impl Unpin for RBatisTxExecutor
impl !UnwindSafe for RBatisTxExecutor
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more