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<'_>
impl Transaction<'_>
pub fn id(&self) -> Guid
Sourcepub fn start_timestamp(&self) -> Timestamp
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.
Sourcepub async fn ping(&self) -> Result<()>
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.
Sourcepub fn is_finished(&self) -> bool
pub fn is_finished(&self) -> bool
Whether the transaction has been committed or aborted.
Sourcepub async fn lookup_rows(
&self,
path: &str,
columns: &[&str],
keys: &[Row],
options: LookupOptions<'_>,
) -> Result<Vec<MaybeRow>>
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.
Sourcepub async fn lookup_rows_with_columns(
&self,
path: &str,
columns: &[&str],
keys: &[Row],
options: LookupOptions<'_>,
) -> Result<(Vec<MaybeRow>, Vec<String>)>
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.
Sourcepub async fn select_rows_with_columns(
&self,
query: &str,
options: SelectOptions,
) -> Result<(Vec<MaybeRow>, Vec<String>)>
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.
Sourcepub async fn select_rows(
&self,
query: &str,
options: SelectOptions,
) -> Result<Vec<MaybeRow>>
pub async fn select_rows( &self, query: &str, options: SelectOptions, ) -> Result<Vec<MaybeRow>>
Runs a query as of this transaction’s start timestamp.
Sourcepub async fn insert_rows(
&self,
path: &str,
columns: &[&str],
rows: &[Row],
) -> Result<()>
pub async fn insert_rows( &self, path: &str, columns: &[&str], rows: &[Row], ) -> Result<()>
Writes rows.
Sourcepub async fn delete_rows(
&self,
path: &str,
columns: &[&str],
keys: &[Row],
) -> Result<()>
pub async fn delete_rows( &self, path: &str, columns: &[&str], keys: &[Row], ) -> Result<()>
Deletes rows by key. Each row carries only the key columns.
Sourcepub async fn modify_rows(
&self,
path: &str,
columns: &[&str],
rows: &[Row],
modification: RowModificationType,
) -> Result<()>
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.