Struct Transactor

Source
#[non_exhaustive]
pub struct Transactor { /* private fields */ }
Expand description

A set of undoable updates and requests against a dataset.

Implementations§

Source§

impl Transactor

Source

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.

Source

pub async fn cancel(&mut self) -> Result<(), Error>

Cancel a transaction.

This reverses all changes made within the transaction.

Source

pub async fn commit(&mut self) -> Result<(), Error>

Commit a transaction.

This attempts to commit all changes made within the transaction.

Source

pub async fn exists<K>( &mut self, key: K, version: Option<u64>, ) -> Result<bool, Error>
where K: KeyEncode + Debug,

Check if a key exists in the datastore.

Source

pub async fn get<K>( &mut self, key: K, version: Option<u64>, ) -> Result<Option<Val>, Error>
where K: KeyEncode + Debug,

Fetch a key from the datastore.

Source

pub async fn getm<K>(&mut self, keys: Vec<K>) -> Result<Vec<Option<Val>>, Error>
where K: KeyEncode + Debug,

Fetch many keys from the datastore.

Source

pub async fn getr<K>( &mut self, rng: Range<K>, version: Option<u64>, ) -> Result<Vec<(Key, Val)>, Error>
where K: KeyEncode + Debug,

Retrieve a specific range of keys from the datastore.

This function fetches all matching key-value pairs from the underlying datastore in grouped batches.

Source

pub async fn getp<K>(&mut self, key: K) -> Result<Vec<(Key, Val)>, Error>
where K: KeyEncode + Debug,

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.

Source

pub async fn set<K, V>( &mut self, key: K, val: V, version: Option<u64>, ) -> Result<(), Error>
where K: KeyEncode + Debug, V: Into<Val> + Debug,

Insert or update a key in the datastore.

Source

pub async fn replace<K, V>(&mut self, key: K, val: V) -> Result<(), Error>
where K: KeyEncode + Debug, V: Into<Val> + Debug,

Insert or replace a key in the datastore.

Source

pub async fn put<K, V>( &mut self, key: K, val: V, version: Option<u64>, ) -> Result<(), Error>
where K: KeyEncode + Debug, V: Into<Val> + Debug,

Insert a key if it doesn’t exist in the datastore.

Source

pub async fn putc<K, V>( &mut self, key: K, val: V, chk: Option<V>, ) -> Result<(), Error>
where K: KeyEncode + Debug, V: Into<Val> + Debug,

Update a key in the datastore if the current value matches a condition.

Source

pub async fn del<K>(&mut self, key: K) -> Result<(), Error>
where K: KeyEncode + Debug,

Delete a key from the datastore.

Source

pub async fn delc<K, V>(&mut self, key: K, chk: Option<V>) -> Result<(), Error>
where K: KeyEncode + Debug, V: Into<Val> + Debug,

Delete a key from the datastore if the current value matches a condition.

Source

pub async fn delr<K>(&mut self, rng: Range<K>) -> Result<(), Error>
where K: KeyEncode + Debug,

Delete a range of keys from the datastore.

This function deletes all matching key-value pairs from the underlying datastore in grouped batches.

Source

pub async fn delp<K>(&mut self, key: K) -> Result<(), Error>
where K: KeyEncode + Debug,

Delete a prefixed range of keys from the datastore.

This function deletes all matching key-value pairs from the underlying datastore in grouped batches.

Source

pub async fn clr<K>(&mut self, key: K) -> Result<(), Error>
where K: KeyEncode + Debug,

Delete all versions of a key from the datastore.

Source

pub async fn clrc<K, V>(&mut self, key: K, chk: Option<V>) -> Result<(), Error>
where K: KeyEncode + Debug, V: Into<Val> + Debug,

Delete all versions of a key from the datastore if the current value matches a condition.

Source

pub async fn clrr<K>(&mut self, rng: Range<K>) -> Result<(), Error>
where K: KeyEncode + Debug,

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.

Source

pub async fn clrp<K>(&mut self, key: K) -> Result<(), Error>
where K: KeyEncode + Debug,

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.

Source

pub async fn keys<K>( &mut self, rng: Range<K>, limit: u32, version: Option<u64>, ) -> Result<Vec<Key>, Error>
where K: KeyEncode + Debug,

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.

Source

pub async fn scan<K>( &mut self, rng: Range<K>, limit: u32, version: Option<u64>, ) -> Result<Vec<(Key, Val)>, Error>
where K: KeyEncode + Debug,

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.

Source

pub async fn batch_keys<K>( &mut self, rng: Range<K>, batch: u32, version: Option<u64>, ) -> Result<Batch<Key>, Error>
where K: KeyEncode + Debug,

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.

Source

pub async fn count<K>(&mut self, rng: Range<K>) -> Result<usize, Error>
where K: KeyEncode + Debug,

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.

Source

pub async fn batch_keys_vals<K>( &mut self, rng: Range<K>, batch: u32, version: Option<u64>, ) -> Result<Batch<(Key, Val)>, Error>
where K: KeyEncode + Debug,

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.

Source

pub async fn batch_keys_vals_versions<K>( &mut self, rng: Range<K>, batch: u32, ) -> Result<Batch<(Key, Val, Version, bool)>, Error>
where K: KeyEncode + Debug,

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.

Source

pub async fn get_timestamp<K>(&mut self, key: K) -> Result<VersionStamp, Error>
where K: KeyEncode + Debug,

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.

Source

pub async fn set_versionstamped<K, V>( &mut self, ts_key: K, prefix: K, suffix: K, val: V, ) -> Result<(), Error>
where K: KeyEncode + Debug, V: Into<Val> + Debug,

Insert or update a key in the datastore.

Source

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§

Source§

impl Display for Transactor

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

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<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToSmolStr for T
where T: Display + ?Sized,

Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
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

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

impl<G1, G2> Within<G2> for G1
where G2: Contains<G1>,

Source§

fn is_within(&self, b: &G2) -> bool

Source§

impl<T> ErasedDestructor for T
where T: 'static,

Source§

impl<T> MaybeSendSync for T

Source§

impl<T> ParallelSend for T
where T: Send,