pub trait StateCache: EstimateSize {
type Key: Ord + EstimateSize;
type Value: EstimateSize;
type Filler<'a>: StateCacheFiller<Key = Self::Key, Value = Self::Value> + 'a
where Self: 'a;
// Required methods
fn is_synced(&self) -> bool;
fn begin_syncing(&mut self) -> Self::Filler<'_>;
fn insert(
&mut self,
key: Self::Key,
value: Self::Value,
) -> Option<Self::Value>;
fn delete(&mut self, key: &Self::Key) -> Option<Self::Value>;
fn apply_batch(
&mut self,
batch: impl IntoIterator<Item = (Op, Self::Key, Self::Value)>,
);
fn clear(&mut self);
fn values(&self) -> impl Iterator<Item = &Self::Value>;
fn first_key_value(&self) -> Option<(&Self::Key, &Self::Value)>;
}
Expand description
A common interface for state table cache.
Required Associated Types§
type Key: Ord + EstimateSize
type Value: EstimateSize
sourcetype Filler<'a>: StateCacheFiller<Key = Self::Key, Value = Self::Value> + 'a
where
Self: 'a
type Filler<'a>: StateCacheFiller<Key = Self::Key, Value = Self::Value> + 'a where Self: 'a
Type of state cache filler, for syncing the cache with the state table.
Required Methods§
sourcefn begin_syncing(&mut self) -> Self::Filler<'_>
fn begin_syncing(&mut self) -> Self::Filler<'_>
Begin syncing the cache with the state table.
sourcefn insert(&mut self, key: Self::Key, value: Self::Value) -> Option<Self::Value>
fn insert(&mut self, key: Self::Key, value: Self::Value) -> Option<Self::Value>
Insert an entry into the cache. Should not break cache validity.
sourcefn delete(&mut self, key: &Self::Key) -> Option<Self::Value>
fn delete(&mut self, key: &Self::Key) -> Option<Self::Value>
Delete an entry from the cache. Should not break cache validity.
sourcefn apply_batch(
&mut self,
batch: impl IntoIterator<Item = (Op, Self::Key, Self::Value)>,
)
fn apply_batch( &mut self, batch: impl IntoIterator<Item = (Op, Self::Key, Self::Value)>, )
Apply a batch of operations to the cache. Should not break cache validity.
sourcefn first_key_value(&self) -> Option<(&Self::Key, &Self::Value)>
fn first_key_value(&self) -> Option<(&Self::Key, &Self::Value)>
Get the reference of first key-value pair in the cache.
Object Safety§
This trait is not object safe.