pub struct TableTransaction<K, V> {
    pub(crate) initial: BTreeMap<K, V>,
    pub(crate) pending: BTreeMap<K, Option<V>>,
    pub(crate) uniqueness_violation: fn(a: &V, b: &V) -> bool,
}
Expand description

TableTransaction emulates some features of a typical SQL transaction over table for a StashCollection.

It supports:

  • uniqueness constraints
  • transactional reads and writes (including read-your-writes before commit)

K is the primary key type. Multiple entries with the same key are disallowed. V is the an arbitrary value type.

To finalize, add the results of TableTransaction::pending() to an AppendBatch.

Fields

initial: BTreeMap<K, V>pending: BTreeMap<K, Option<V>>uniqueness_violation: fn(a: &V, b: &V) -> bool

Implementations

Create a new TableTransaction with initial data. uniqueness_violation is a function whether there is a uniqueness violation among two values.

Consumes and returns the pending changes and their diffs. Diff is guaranteed to be 1 or -1.

Iterates over the items viewable in the current transaction in arbitrary order.

Returns the items viewable in the current transaction.

Iterates over the items viewable in the current transaction, and provides a Vec where additional pending items can be inserted, which will be appended to current pending items. Does not verify unqiueness.

Inserts a new k,v pair.

Returns an error if the uniqueness check failed or the key already exists.

Updates k, v pairs. f is a function that can return Some(V) if the value should be updated, otherwise None. Returns the number of changed entries.

Returns an error if the uniqueness check failed.

Deletes items for which f returns true. Returns the keys and values of the deleted entries.

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Attaches the provided Context to this type, returning a WithContext wrapper. Read more

Attaches the current Context to this type, returning a WithContext wrapper. Read more

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

Instruments this type with the current Span, returning an Instrumented wrapper. Read more

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Wrap the input message T in a tonic::Request

Should always be Self

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.

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

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