pub struct Transaction<'db> { /* private fields */ }Expand description
An in-flight cross-table transaction. Holds a read snapshot taken at begin
and stages writes; nothing is durable or visible until Self::commit.
Implementations§
Source§impl<'db> Transaction<'db>
impl<'db> Transaction<'db>
pub fn read_snapshot(&self) -> Snapshot
Sourcepub fn txn_id(&self) -> u64
pub fn txn_id(&self) -> u64
The transaction’s id (generation-scoped: high 32 bits = open generation, low 32 = per-open counter). Mainly diagnostic / test-facing.
Sourcepub fn put(
&mut self,
table: &str,
cells: Vec<(u16, Value)>,
) -> Result<Option<i64>>
pub fn put( &mut self, table: &str, cells: Vec<(u16, Value)>, ) -> Result<Option<i64>>
Stage a put on table. The row id is allocated at commit so an aborted
transaction never consumes ids. If the table has an AUTO_INCREMENT
primary key and the column is omitted or null, the engine fills it now
and returns the assigned value; explicit ids are honored and advance the
counter. The value is staged in cells, so the commit path writes the
same id into the row.
pub fn put_returning( &mut self, table: &str, cells: Vec<(u16, Value)>, ) -> Result<PutResult>
Sourcepub fn delete(&mut self, table: &str, row_id: RowId) -> Result<()>
pub fn delete(&mut self, table: &str, row_id: RowId) -> Result<()>
Stage a delete of row_id on table.
pub fn delete_many( &mut self, table: &str, row_ids: Vec<RowId>, ) -> Result<Vec<OwnedRow>>
pub fn update_many( &mut self, table: &str, updates: Vec<(RowId, Vec<(u16, Value)>)>, ) -> Result<Vec<OwnedRow>>
pub fn upsert( &mut self, table: &str, insert_cells: Vec<(u16, Value)>, action: UpsertAction, ) -> Result<UpsertResult>
pub fn truncate(&mut self, table: &str) -> Result<()>
Auto Trait Implementations§
impl<'db> !RefUnwindSafe for Transaction<'db>
impl<'db> !UnwindSafe for Transaction<'db>
impl<'db> Freeze for Transaction<'db>
impl<'db> Send for Transaction<'db>
impl<'db> Sync for Transaction<'db>
impl<'db> Unpin for Transaction<'db>
impl<'db> UnsafeUnpin for Transaction<'db>
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> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more