Trait mithril_persistence::store::StorePruner

source ·
pub trait StorePruner {
    type Key: Sync + Send;
    type Record: Sync + Send;

    // Required methods
    fn get_adapter(
        &self,
    ) -> &RwLock<Box<dyn StoreAdapter<Key = Self::Key, Record = Self::Record>>>;
    fn get_max_records(&self) -> Option<usize>;

    // Provided method
    fn prune<'life0, 'async_trait>(
        &'life0 self,
    ) -> Pin<Box<dyn Future<Output = StdResult<()>> + Send + 'async_trait>>
       where Self: Sync + 'async_trait,
             'life0: 'async_trait { ... }
}
Expand description

Implementing this trait will make store able to limit the number of the stored records by pruning them if a limit is set.

Required Associated Types§

source

type Key: Sync + Send

The key type

source

type Record: Sync + Send

The record type

Required Methods§

source

fn get_adapter( &self, ) -> &RwLock<Box<dyn StoreAdapter<Key = Self::Key, Record = Self::Record>>>

This trait requires a way to get the internal adapter.

source

fn get_max_records(&self) -> Option<usize>

Return the maximum number of elements that can exist in this store. If None, there is no limit.

Provided Methods§

source

fn prune<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = StdResult<()>> + Send + 'async_trait>>
where Self: Sync + 'async_trait, 'life0: 'async_trait,

Prune elements exceeding the specified limit.

Implementors§