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.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.