pub trait AsyncPendingManager: Send + Sync + 'static {
    type Error: Error + Send + Sync + 'static;
    type Key: Send + Sync + 'static;
    type Value: Send + Sync + 'static;

    // Required methods
    fn is_empty(&self) -> bool;
    fn len(&self) -> usize;
    fn get(
        &self,
        key: &Self::Key
    ) -> impl Future<Output = Result<Option<&EntryValue<Self::Value>>, Self::Error>> + Send;
    fn insert(
        &mut self,
        key: Self::Key,
        value: EntryValue<Self::Value>
    ) -> impl Future<Output = Result<(), Self::Error>> + Send;
    fn remove_entry(
        &mut self,
        key: &Self::Key
    ) -> impl Future<Output = Result<Option<(Self::Key, EntryValue<Self::Value>)>, Self::Error>> + Send;
    fn keys(
        &self
    ) -> impl Future<Output = impl Iterator<Item = &Self::Key>> + Send;
    fn iter(
        &self
    ) -> impl Future<Output = impl Iterator<Item = (&Self::Key, &EntryValue<Self::Value>)>> + Send;
    fn into_iter(
        self
    ) -> impl Future<Output = impl Iterator<Item = (Self::Key, EntryValue<Self::Value>)>> + Send;
}
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 + Send + Sync + 'static

The error type returned by the pending manager.

source

type Key: Send + Sync + 'static

The key type.

source

type Value: Send + Sync + 'static

The value type.

Required Methods§

source

fn is_empty(&self) -> bool

Returns true if the buffer is empty.

source

fn len(&self) -> usize

Returns the number of elements in the buffer.

source

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

Returns a reference to the value corresponding to the key.

source

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

Inserts a key-value pair into the buffer.

source

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

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

source

fn keys(&self) -> impl Future<Output = impl Iterator<Item = &Self::Key>> + Send

Returns an iterator over the keys in the buffer.

source

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

Returns an iterator over the key-value pairs in the buffer.

source

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

Returns an iterator that consumes the buffer.

Object Safety§

This trait is not object safe.

Implementations on Foreign Types§

source§

impl<K, V> AsyncPendingManager for BTreeMap<K, EntryValue<V>>
where K: Eq + Hash + Ord + Send + Sync + 'static, V: Send + Sync + 'static,

§

type Error = Infallible

§

type Key = K

§

type Value = V

source§

fn is_empty(&self) -> bool

source§

fn len(&self) -> usize

source§

async fn get( &self, key: &K ) -> Result<Option<&EntryValue<<BTreeMap<K, EntryValue<V>> as AsyncPendingManager>::Value>>, <BTreeMap<K, EntryValue<V>> as AsyncPendingManager>::Error>

source§

async fn insert( &mut self, key: K, value: EntryValue<<BTreeMap<K, EntryValue<V>> as AsyncPendingManager>::Value> ) -> Result<(), <BTreeMap<K, EntryValue<V>> as AsyncPendingManager>::Error>

source§

async fn remove_entry( &mut self, key: &K ) -> Result<Option<(K, EntryValue<<BTreeMap<K, EntryValue<V>> as AsyncPendingManager>::Value>)>, <BTreeMap<K, EntryValue<V>> as AsyncPendingManager>::Error>

source§

async fn keys(&self) -> impl Iterator<Item = &K>

source§

async fn iter( &self ) -> impl Iterator<Item = (&K, &EntryValue<<BTreeMap<K, EntryValue<V>> as AsyncPendingManager>::Value>)>

source§

async fn into_iter( self ) -> impl Iterator<Item = (K, EntryValue<<BTreeMap<K, EntryValue<V>> as AsyncPendingManager>::Value>)>

source§

impl<K, V, S> AsyncPendingManager for IndexMap<K, EntryValue<V>, S>
where K: Eq + Hash + Send + Sync + 'static, V: Send + Sync + 'static, S: BuildHasher + Default + Send + Sync + 'static,

§

type Error = Infallible

§

type Key = K

§

type Value = V

source§

fn is_empty(&self) -> bool

source§

fn len(&self) -> usize

source§

async fn get( &self, key: &K ) -> Result<Option<&EntryValue<V>>, <IndexMap<K, EntryValue<V>, S> as AsyncPendingManager>::Error>

source§

async fn insert( &mut self, key: K, value: EntryValue<V> ) -> Result<(), <IndexMap<K, EntryValue<V>, S> as AsyncPendingManager>::Error>

source§

async fn remove_entry( &mut self, key: &K ) -> Result<Option<(K, EntryValue<V>)>, <IndexMap<K, EntryValue<V>, S> as AsyncPendingManager>::Error>

source§

async fn keys(&self) -> impl Iterator<Item = &K>

source§

async fn iter(&self) -> impl Iterator<Item = (&K, &EntryValue<V>)>

source§

async fn into_iter(self) -> impl Iterator<Item = (K, EntryValue<V>)>

Implementors§