Trait txn_core::future::AsyncPwm

source ·
pub trait AsyncPwm: Sized {
    type Error: Error;
    type Key;
    type Value;
    type Options;
    type Iter<'a>: Iterator<Item = (&'a Self::Key, &'a EntryValue<Self::Value>)>
       where Self: 'a;
    type IntoIter: Iterator<Item = (Self::Key, EntryValue<Self::Value>)>;

Show 14 methods // Required methods fn new( options: Self::Options ) -> impl Future<Output = Result<Self, Self::Error>>; fn is_empty(&self) -> impl Future<Output = bool>; fn len(&self) -> impl Future<Output = usize>; fn validate_entry( &self, entry: &Entry<Self::Key, Self::Value> ) -> impl Future<Output = Result<(), Self::Error>>; fn max_batch_size(&self) -> u64; fn max_batch_entries(&self) -> u64; fn estimate_size(&self, entry: &Entry<Self::Key, Self::Value>) -> u64; fn get( &self, key: &Self::Key ) -> impl Future<Output = Result<Option<&EntryValue<Self::Value>>, Self::Error>>; fn contains_key( &self, key: &Self::Key ) -> impl Future<Output = Result<bool, Self::Error>>; fn insert( &mut self, key: Self::Key, value: EntryValue<Self::Value> ) -> impl Future<Output = Result<(), Self::Error>>; fn remove_entry( &mut self, key: &Self::Key ) -> impl Future<Output = Result<Option<(Self::Key, EntryValue<Self::Value>)>, Self::Error>>; fn rollback(&mut self) -> impl Future<Output = Result<(), Self::Error>>; fn iter( &self ) -> impl Future<Output = impl Iterator<Item = (&Self::Key, &EntryValue<Self::Value>)>>; fn into_iter( self ) -> impl Future<Output = impl Iterator<Item = (Self::Key, EntryValue<Self::Value>)>>;
}
Expand description

A pending writes manager that can be used to store pending writes in a transaction.

By default, there are two implementations of this trait:

  • [IndexMap]: A hash map with consistent ordering and fast lookups.
  • [BTreeMap]: A balanced binary tree with ordered keys and fast lookups.

But, users can create their own implementations by implementing this trait. e.g. if you want to implement a recovery transaction manager, you can use a persistent storage to store the pending writes.

Required Associated Types§

source

type Error: Error

The error type returned by the conflict manager.

source

type Key

The key type.

source

type Value

The value type.

source

type Options

The options type used to create the pending manager.

source

type Iter<'a>: Iterator<Item = (&'a Self::Key, &'a EntryValue<Self::Value>)> where Self: 'a

The iterator type that borrows the pending writes.

source

type IntoIter: Iterator<Item = (Self::Key, EntryValue<Self::Value>)>

The iterator type that consumes the pending writes.

Required Methods§

source

fn new( options: Self::Options ) -> impl Future<Output = Result<Self, Self::Error>>

Create a new pending manager with the given options.

source

fn is_empty(&self) -> impl Future<Output = bool>

Returns true if the buffer is empty.

source

fn len(&self) -> impl Future<Output = usize>

Returns the number of elements in the buffer.

source

fn validate_entry( &self, entry: &Entry<Self::Key, Self::Value> ) -> impl Future<Output = Result<(), Self::Error>>

Validate if the entry is valid for this database.

e.g.

  • If the entry is expired
  • If the key or the value is too large
  • If the key or the value is empty
  • If the key or the value contains invalid characters
  • and etc.
source

fn max_batch_size(&self) -> u64

Returns the maximum batch size in bytes

source

fn max_batch_entries(&self) -> u64

Returns the maximum entries in batch

source

fn estimate_size(&self, entry: &Entry<Self::Key, Self::Value>) -> u64

Returns the estimated size of the entry in bytes when persisted in the database.

source

fn get( &self, key: &Self::Key ) -> impl Future<Output = Result<Option<&EntryValue<Self::Value>>, Self::Error>>

Returns a reference to the value corresponding to the key.

source

fn contains_key( &self, key: &Self::Key ) -> impl Future<Output = Result<bool, Self::Error>>

Returns true if the pending manager contains the key.

source

fn insert( &mut self, key: Self::Key, value: EntryValue<Self::Value> ) -> impl Future<Output = Result<(), Self::Error>>

Inserts a key-value pair into the er.

source

fn remove_entry( &mut self, key: &Self::Key ) -> impl Future<Output = Result<Option<(Self::Key, EntryValue<Self::Value>)>, Self::Error>>

Removes a key from the pending writes, returning the key-value pair if the key was previously in the pending writes.

source

fn rollback(&mut self) -> impl Future<Output = Result<(), Self::Error>>

Rollback the pending writes.

source

fn iter( &self ) -> impl Future<Output = impl Iterator<Item = (&Self::Key, &EntryValue<Self::Value>)>>

Returns an iterator over the pending writes.

source

fn into_iter( self ) -> impl Future<Output = impl Iterator<Item = (Self::Key, EntryValue<Self::Value>)>>

Returns an iterator that consumes the pending writes.

Object Safety§

This trait is not object safe.

Implementors§

source§

impl<T> AsyncPwm for T
where T: Pwm,

§

type Error = <T as Pwm>::Error

§

type Key = <T as Pwm>::Key

§

type Value = <T as Pwm>::Value

§

type Options = <T as Pwm>::Options

§

type Iter<'a> = <T as Pwm>::Iter<'a> where Self: 'a

§

type IntoIter = <T as Pwm>::IntoIter