#[non_exhaustive]pub struct TransactionResult<T> {
pub result: T,
pub commit_response: CommitResponse,
}Expand description
Result of a read/write transaction executed by a TransactionRunner.
Contains both the application-defined return value of the closure and the
CommitResponse returned by the Spanner service upon successful commit.
§Example
let db_client = client.database_client("projects/p/instances/i/databases/d").build().await?;
let runner = db_client.read_write_transaction().build();
let tx_result = runner
.run(async |transaction| {
let statement = Statement::builder("UPDATE Users SET Active = true WHERE Id = 1").build();
let updated_rows = transaction.execute_update(statement).await?;
Ok(updated_rows)
})
.await?;
println!("Updated {} rows", tx_result.result);
if let Some(timestamp) = tx_result.commit_timestamp() {
println!("Committed at: {timestamp:?}");
}Fields (Non-exhaustive)§
This struct is marked as non-exhaustive
Non-exhaustive structs could have additional fields added in future. Therefore, non-exhaustive structs cannot be constructed in external crates using the traditional
Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.result: TThe result returned by the closure executed within the transaction.
commit_response: CommitResponseThe response from the commit RPC.
Implementations§
Source§impl<T> TransactionResult<T>
impl<T> TransactionResult<T>
Sourcepub fn new(result: T, commit_response: CommitResponse) -> Self
pub fn new(result: T, commit_response: CommitResponse) -> Self
Creates a new TransactionResult with the given result and commit response.
Sourcepub fn into_inner(self) -> T
pub fn into_inner(self) -> T
Consumes the TransactionResult, returning the closure result.
Sourcepub fn into_parts(self) -> (T, CommitResponse)
pub fn into_parts(self) -> (T, CommitResponse)
Consumes the TransactionResult, returning both the closure result and commit response.
Sourcepub fn commit_timestamp(&self) -> Option<Timestamp>
pub fn commit_timestamp(&self) -> Option<Timestamp>
Returns the Cloud Spanner timestamp at which the transaction committed, if available.
Sourcepub fn commit_stats(&self) -> Option<&CommitStats>
pub fn commit_stats(&self) -> Option<&CommitStats>
Returns the statistics about the commit, if requested and returned by Spanner.
Trait Implementations§
Source§impl<T: Clone> Clone for TransactionResult<T>
impl<T: Clone> Clone for TransactionResult<T>
Source§impl<T: Debug> Debug for TransactionResult<T>
impl<T: Debug> Debug for TransactionResult<T>
Source§impl<T: PartialEq> PartialEq for TransactionResult<T>
impl<T: PartialEq> PartialEq for TransactionResult<T>
impl<T: PartialEq> StructuralPartialEq for TransactionResult<T>
Auto Trait Implementations§
impl<T> !Freeze for TransactionResult<T>
impl<T> Forget for TransactionResult<T>
impl<T> Move for TransactionResult<T>
impl<T> RefUnwindSafe for TransactionResult<T>where
T: RefUnwindSafe,
impl<T> Send for TransactionResult<T>where
T: Send,
impl<T> Sync for TransactionResult<T>where
T: Sync,
impl<T> Unpin for TransactionResult<T>where
T: Unpin,
impl<T> UnsafeUnpin for TransactionResult<T>where
T: UnsafeUnpin,
impl<T> UnwindSafe for TransactionResult<T>where
T: UnwindSafe,
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> FutureExt for T
impl<T> FutureExt for T
Source§fn with_context(self, otel_cx: Context) -> WithContext<Self> ⓘ
fn with_context(self, otel_cx: Context) -> WithContext<Self> ⓘ
Source§fn with_current_context(self) -> WithContext<Self> ⓘ
fn with_current_context(self) -> WithContext<Self> ⓘ
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