Struct libsql_client::transaction::SyncTransaction
source · pub struct SyncTransaction<'a> { /* private fields */ }
Implementations§
source§impl<'a> SyncTransaction<'a>
impl<'a> SyncTransaction<'a>
pub fn new(client: &'a SyncClient, id: u64) -> Result<SyncTransaction<'a>>
sourcepub fn execute(&self, stmt: impl Into<Statement>) -> Result<ResultSet>
pub fn execute(&self, stmt: impl Into<Statement>) -> Result<ResultSet>
Executes a statement within the current transaction.
§Example
let mut db = libsql_client::SyncClient::from_env()?;
let tx = db.transaction()?;
tx.execute(Statement::with_args("INSERT INTO users (name) VALUES (?)", args!["John"]))?;
let res = tx.execute(Statement::with_args("INSERT INTO users (name) VALUES (?)", args!["Jane"]));
if res.is_err() {
tx.rollback()?;
} else {
tx.commit()?;
}
Auto Trait Implementations§
impl<'a> !RefUnwindSafe for SyncTransaction<'a>
impl<'a> !Send for SyncTransaction<'a>
impl<'a> !Sync for SyncTransaction<'a>
impl<'a> Unpin for SyncTransaction<'a>
impl<'a> !UnwindSafe for SyncTransaction<'a>
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
source§impl<T> Instrument for T
impl<T> Instrument for T
source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
source§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
Wrap the input message
T
in a tonic::Request