Struct libsql_client::transaction::Transaction
source · pub struct Transaction<'a> { /* private fields */ }
Implementations§
source§impl<'a> Transaction<'a>
impl<'a> Transaction<'a>
pub async fn new(client: &'a Client, id: u64) -> Result<Transaction<'a>>
sourcepub async fn execute(&self, stmt: impl Into<Statement>) -> Result<ResultSet>
pub async fn execute(&self, stmt: impl Into<Statement>) -> Result<ResultSet>
Executes a statement within the current transaction.
§Example
let mut db = libsql_client::Client::from_env().await?;
let tx = db.transaction().await?;
tx.execute(Statement::with_args("INSERT INTO users (name) VALUES (?)", args!["John"])).await?;
let res = tx.execute(Statement::with_args("INSERT INTO users (name) VALUES (?)", args!["Jane"])).await;
if res.is_err() {
tx.rollback().await?;
} else {
tx.commit().await?;
}
Auto Trait Implementations§
impl<'a> !RefUnwindSafe for Transaction<'a>
impl<'a> !Send for Transaction<'a>
impl<'a> !Sync for Transaction<'a>
impl<'a> Unpin for Transaction<'a>
impl<'a> !UnwindSafe for Transaction<'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