#[non_exhaustive]pub struct Transactor { /* private fields */ }
Expand description
A set of undoable updates and requests against a dataset.
Implementations§
Source§impl Transactor
impl Transactor
Sourcepub async fn closed(&self) -> bool
pub async fn closed(&self) -> bool
Check if transaction is finished.
If the transaction has been cancelled or committed,
then this function will return true
, and any further
calls to functions on this transaction will result
in a Error::TxFinished
error.
Sourcepub async fn cancel(&mut self) -> Result<(), Error>
pub async fn cancel(&mut self) -> Result<(), Error>
Cancel a transaction.
This reverses all changes made within the transaction.
Sourcepub async fn commit(&mut self) -> Result<(), Error>
pub async fn commit(&mut self) -> Result<(), Error>
Commit a transaction.
This attempts to commit all changes made within the transaction.
Sourcepub async fn exists<K>(
&mut self,
key: K,
version: Option<u64>,
) -> Result<bool, Error>
pub async fn exists<K>( &mut self, key: K, version: Option<u64>, ) -> Result<bool, Error>
Check if a key exists in the datastore.
Sourcepub async fn get<K>(
&mut self,
key: K,
version: Option<u64>,
) -> Result<Option<Val>, Error>
pub async fn get<K>( &mut self, key: K, version: Option<u64>, ) -> Result<Option<Val>, Error>
Fetch a key from the datastore.
Sourcepub async fn getm<K>(&mut self, keys: Vec<K>) -> Result<Vec<Option<Val>>, Error>
pub async fn getm<K>(&mut self, keys: Vec<K>) -> Result<Vec<Option<Val>>, Error>
Fetch many keys from the datastore.
Sourcepub async fn getr<K>(
&mut self,
rng: Range<K>,
version: Option<u64>,
) -> Result<Vec<(Key, Val)>, Error>
pub async fn getr<K>( &mut self, rng: Range<K>, version: Option<u64>, ) -> Result<Vec<(Key, Val)>, Error>
Retrieve a specific range of keys from the datastore.
This function fetches all matching key-value pairs from the underlying datastore in grouped batches.
Sourcepub async fn getp<K>(&mut self, key: K) -> Result<Vec<(Key, Val)>, Error>
pub async fn getp<K>(&mut self, key: K) -> Result<Vec<(Key, Val)>, Error>
Retrieve a specific prefixed range of keys from the datastore.
This function fetches all matching key-value pairs from the underlying datastore in grouped batches.
Sourcepub async fn set<K, V>(
&mut self,
key: K,
val: V,
version: Option<u64>,
) -> Result<(), Error>
pub async fn set<K, V>( &mut self, key: K, val: V, version: Option<u64>, ) -> Result<(), Error>
Insert or update a key in the datastore.
Sourcepub async fn replace<K, V>(&mut self, key: K, val: V) -> Result<(), Error>
pub async fn replace<K, V>(&mut self, key: K, val: V) -> Result<(), Error>
Insert or replace a key in the datastore.
Sourcepub async fn put<K, V>(
&mut self,
key: K,
val: V,
version: Option<u64>,
) -> Result<(), Error>
pub async fn put<K, V>( &mut self, key: K, val: V, version: Option<u64>, ) -> Result<(), Error>
Insert a key if it doesn’t exist in the datastore.
Sourcepub async fn putc<K, V>(
&mut self,
key: K,
val: V,
chk: Option<V>,
) -> Result<(), Error>
pub async fn putc<K, V>( &mut self, key: K, val: V, chk: Option<V>, ) -> Result<(), Error>
Update a key in the datastore if the current value matches a condition.
Sourcepub async fn delc<K, V>(&mut self, key: K, chk: Option<V>) -> Result<(), Error>
pub async fn delc<K, V>(&mut self, key: K, chk: Option<V>) -> Result<(), Error>
Delete a key from the datastore if the current value matches a condition.
Sourcepub async fn delr<K>(&mut self, rng: Range<K>) -> Result<(), Error>
pub async fn delr<K>(&mut self, rng: Range<K>) -> Result<(), Error>
Delete a range of keys from the datastore.
This function deletes all matching key-value pairs from the underlying datastore in grouped batches.
Sourcepub async fn delp<K>(&mut self, key: K) -> Result<(), Error>
pub async fn delp<K>(&mut self, key: K) -> Result<(), Error>
Delete a prefixed range of keys from the datastore.
This function deletes all matching key-value pairs from the underlying datastore in grouped batches.
Sourcepub async fn clr<K>(&mut self, key: K) -> Result<(), Error>
pub async fn clr<K>(&mut self, key: K) -> Result<(), Error>
Delete all versions of a key from the datastore.
Sourcepub async fn clrc<K, V>(&mut self, key: K, chk: Option<V>) -> Result<(), Error>
pub async fn clrc<K, V>(&mut self, key: K, chk: Option<V>) -> Result<(), Error>
Delete all versions of a key from the datastore if the current value matches a condition.
Sourcepub async fn clrr<K>(&mut self, rng: Range<K>) -> Result<(), Error>
pub async fn clrr<K>(&mut self, rng: Range<K>) -> Result<(), Error>
Delete all versions of a range of keys from the datastore.
This function deletes all matching key-value pairs from the underlying datastore in grouped batches.
Sourcepub async fn clrp<K>(&mut self, key: K) -> Result<(), Error>
pub async fn clrp<K>(&mut self, key: K) -> Result<(), Error>
Delete all versions of a prefixed range of keys from the datastore.
This function deletes all matching key-value pairs from the underlying datastore in grouped batches.
Sourcepub async fn keys<K>(
&mut self,
rng: Range<K>,
limit: u32,
version: Option<u64>,
) -> Result<Vec<Key>, Error>
pub async fn keys<K>( &mut self, rng: Range<K>, limit: u32, version: Option<u64>, ) -> Result<Vec<Key>, Error>
Retrieve a specific range of keys from the datastore.
This function fetches the full range of keys without values, in a single request to the underlying datastore.
Sourcepub async fn scan<K>(
&mut self,
rng: Range<K>,
limit: u32,
version: Option<u64>,
) -> Result<Vec<(Key, Val)>, Error>
pub async fn scan<K>( &mut self, rng: Range<K>, limit: u32, version: Option<u64>, ) -> Result<Vec<(Key, Val)>, Error>
Retrieve a specific range of keys from the datastore.
This function fetches the full range of key-value pairs, in a single request to the underlying datastore.
Sourcepub async fn batch_keys<K>(
&mut self,
rng: Range<K>,
batch: u32,
version: Option<u64>,
) -> Result<Batch<Key>, Error>
pub async fn batch_keys<K>( &mut self, rng: Range<K>, batch: u32, version: Option<u64>, ) -> Result<Batch<Key>, Error>
Retrieve a batched scan over a specific range of keys in the datastore.
This function fetches keys, in batches, with multiple requests to the underlying datastore.
Sourcepub async fn count<K>(&mut self, rng: Range<K>) -> Result<usize, Error>
pub async fn count<K>(&mut self, rng: Range<K>) -> Result<usize, Error>
Count the total number of keys within a range in the datastore.
This function fetches the total count, in batches, with multiple requests to the underlying datastore.
Sourcepub async fn batch_keys_vals<K>(
&mut self,
rng: Range<K>,
batch: u32,
version: Option<u64>,
) -> Result<Batch<(Key, Val)>, Error>
pub async fn batch_keys_vals<K>( &mut self, rng: Range<K>, batch: u32, version: Option<u64>, ) -> Result<Batch<(Key, Val)>, Error>
Retrieve a batched scan over a specific range of keys in the datastore.
This function fetches key-value pairs, in batches, with multiple requests to the underlying datastore.
Sourcepub async fn batch_keys_vals_versions<K>(
&mut self,
rng: Range<K>,
batch: u32,
) -> Result<Batch<(Key, Val, Version, bool)>, Error>
pub async fn batch_keys_vals_versions<K>( &mut self, rng: Range<K>, batch: u32, ) -> Result<Batch<(Key, Val, Version, bool)>, Error>
Retrieve a batched scan of all versions over a specific range of keys in the datastore.
This function fetches key-value-version pairs, in batches, with multiple requests to the underlying datastore.
Sourcepub async fn get_timestamp<K>(&mut self, key: K) -> Result<VersionStamp, Error>
pub async fn get_timestamp<K>(&mut self, key: K) -> Result<VersionStamp, Error>
Obtain a new change timestamp for a key which is replaced with the current timestamp when the transaction is committed. NOTE: This should be called when composing the change feed entries for this transaction, which should be done immediately before the transaction commit. That is to keep other transactions commit delay(pessimistic) or conflict(optimistic) as less as possible.
Sourcepub async fn set_versionstamped<K, V>(
&mut self,
ts_key: K,
prefix: K,
suffix: K,
val: V,
) -> Result<(), Error>
pub async fn set_versionstamped<K, V>( &mut self, ts_key: K, prefix: K, suffix: K, val: V, ) -> Result<(), Error>
Insert or update a key in the datastore.
Sourcepub async fn clock(&self) -> Timestamp
pub async fn clock(&self) -> Timestamp
Clock retrieves the current timestamp, without guaranteeing monotonicity in all implementations.
It is used for unreliable ordering of events as well as handling of timeouts. Operations that are not guaranteed to be correct. But also allows for lexicographical ordering.
Public for tests, but not required for usage from a user perspective.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Transactor
impl !RefUnwindSafe for Transactor
impl Send for Transactor
impl !Sync for Transactor
impl Unpin for Transactor
impl !UnwindSafe for Transactor
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
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> 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>
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>
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