pub struct AppTransaction { /* private fields */ }Expand description
A canonical transaction: operations and preconditions the application contract validates and authorizes, committed atomically.
Implementations§
Source§impl AppTransaction
impl AppTransaction
Sourcepub fn new(transaction_id: impl Into<String>) -> Self
pub fn new(transaction_id: impl Into<String>) -> Self
A transaction with this identity; resubmitting it after an uncertain outcome is safe.
pub fn id(&self) -> &str
Sourcepub fn insert(
self,
collection: impl Into<String>,
id: impl Into<String>,
value: Value,
) -> Self
pub fn insert( self, collection: impl Into<String>, id: impl Into<String>, value: Value, ) -> Self
Create a record that must not exist.
Sourcepub fn update(
self,
collection: impl Into<String>,
id: impl Into<String>,
value: Value,
) -> Self
pub fn update( self, collection: impl Into<String>, id: impl Into<String>, value: Value, ) -> Self
Write a record.
pub fn delete( self, collection: impl Into<String>, id: impl Into<String>, ) -> Self
Sourcepub fn precondition(self, precondition: TransactionPrecondition) -> Self
pub fn precondition(self, precondition: TransactionPrecondition) -> Self
Any precondition of the canonical contract, e.g. a record’s __version:
let tx = AppTransaction::new("tx-1").precondition(TransactionPrecondition::Record {
collection: "Order".into(),
id: "o-1".into(),
require_absent: false,
expected_version: Some(3),
expected_epoch: None,
expected_lease_id: None,
});Sourcepub fn expect_version(
self,
collection: impl Into<String>,
id: impl Into<String>,
version: u64,
) -> Self
pub fn expect_version( self, collection: impl Into<String>, id: impl Into<String>, version: u64, ) -> Self
Commit only if the record’s __version is still version.
Sourcepub fn expect_absent(
self,
collection: impl Into<String>,
id: impl Into<String>,
) -> Self
pub fn expect_absent( self, collection: impl Into<String>, id: impl Into<String>, ) -> Self
Commit only if the record does not exist.
Sourcepub fn fence(self, basis: ReadBasis) -> Self
pub fn fence(self, basis: ReadBasis) -> Self
Commit only if the state basis covers is unchanged since Application::read_basis.
Trait Implementations§
Source§impl Clone for AppTransaction
impl Clone for AppTransaction
Auto Trait Implementations§
impl Freeze for AppTransaction
impl RefUnwindSafe for AppTransaction
impl Send for AppTransaction
impl Sync for AppTransaction
impl Unpin for AppTransaction
impl UnsafeUnpin for AppTransaction
impl UnwindSafe for AppTransaction
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