Skip to main content

Transaction

Struct Transaction 

Source
pub struct Transaction<'a> { /* private fields */ }
Expand description

An open transaction.

Dropping one does not abort it: Drop cannot await, and a silent best-effort abort would be a lie. An unfinished transaction is left to expire on the server after its timeout, and Transaction::abort is there to end it now.

Implementations§

Source§

impl Transaction<'_>

Source

pub fn id(&self) -> Guid

Source

pub fn start_timestamp(&self) -> Timestamp

The transaction’s read timestamp.

Reads inside a tablet transaction are expressed purely as this timestamp: TReqLookupRows and TReqSelectRows have no transaction_id field at all.

Source

pub async fn ping(&self) -> Result<()>

Tells the server the transaction is still wanted.

Must be called more often than the transaction’s timeout, or the server aborts it.

Source

pub async fn commit(self) -> Result<()>

Commits the transaction.

Source

pub async fn abort(self) -> Result<()>

Aborts the transaction.

Source

pub fn is_finished(&self) -> bool

Whether the transaction has been committed or aborted.

Source

pub async fn lookup_rows( &self, path: &str, columns: &[&str], keys: &[Row], options: LookupOptions<'_>, ) -> Result<Vec<MaybeRow>>

Looks rows up as of this transaction’s start timestamp.

Source

pub async fn lookup_rows_with_columns( &self, path: &str, columns: &[&str], keys: &[Row], options: LookupOptions<'_>, ) -> Result<(Vec<MaybeRow>, Vec<String>)>

Looks rows up as of this transaction, with the reply’s column names.

Source

pub async fn select_rows_with_columns( &self, query: &str, options: SelectOptions, ) -> Result<(Vec<MaybeRow>, Vec<String>)>

Runs a query as of this transaction, with the reply’s column names.

Source

pub async fn select_rows( &self, query: &str, options: SelectOptions, ) -> Result<Vec<MaybeRow>>

Runs a query as of this transaction’s start timestamp.

Source

pub async fn insert_rows( &self, path: &str, columns: &[&str], rows: &[Row], ) -> Result<()>

Writes rows.

Source

pub async fn delete_rows( &self, path: &str, columns: &[&str], keys: &[Row], ) -> Result<()>

Deletes rows by key. Each row carries only the key columns.

Source

pub async fn modify_rows( &self, path: &str, columns: &[&str], rows: &[Row], modification: RowModificationType, ) -> Result<()>

Applies one modification type to every row.

row_modification_types is a parallel array to the rows in the attachment: entry i is the type of row i, and the server relies on the two staying the same length.

Trait Implementations§

Source§

impl<'a> Debug for Transaction<'a>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<'a> !RefUnwindSafe for Transaction<'a>

§

impl<'a> !UnwindSafe for Transaction<'a>

§

impl<'a> Freeze for Transaction<'a>

§

impl<'a> Send for Transaction<'a>

§

impl<'a> Sync for Transaction<'a>

§

impl<'a> Unpin for Transaction<'a>

§

impl<'a> UnsafeUnpin for Transaction<'a>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V