pub trait Layer<K, V>: Send + Sync {
// Required methods
fn seek<'life0, 'life1, 'async_trait>(
&'life0 self,
bound: Bound<&'life1 K>,
) -> Pin<Box<dyn Future<Output = Result<BoxedLayerIterator<'_, K, V>, Error>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait;
fn len(&self) -> usize;
fn lock(&self) -> Option<Arc<DropEvent>>;
fn close<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait;
fn get_version(&self) -> Version;
// Provided methods
fn handle(&self) -> Option<&dyn ReadObjectHandle> { ... }
fn purge_cached_data(&self) { ... }
fn maybe_contains_key(&self, _key: &K) -> bool { ... }
fn record_inspect_data(self: Arc<Self>, _node: &Node) { ... }
}
Expand description
Layer is a trait that all layers need to implement (mutable and immutable).
Required Methods§
Sourcefn seek<'life0, 'life1, 'async_trait>(
&'life0 self,
bound: Bound<&'life1 K>,
) -> Pin<Box<dyn Future<Output = Result<BoxedLayerIterator<'_, K, V>, Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn seek<'life0, 'life1, 'async_trait>(
&'life0 self,
bound: Bound<&'life1 K>,
) -> Pin<Box<dyn Future<Output = Result<BoxedLayerIterator<'_, K, V>, Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Searches for a key. Bound::Excluded is not supported. Bound::Unbounded positions the iterator on the first item in the layer.
Sourcefn lock(&self) -> Option<Arc<DropEvent>>
fn lock(&self) -> Option<Arc<DropEvent>>
Locks the layer preventing it from being closed. This will never block i.e. there can be many locks concurrently. The lock is purely advisory: seek will still work even if lock has not been called; it merely causes close to wait until all locks are released. Returns None if close has been called for the layer.
Sourcefn close<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn close<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Waits for existing locks readers to finish and then returns. Subsequent calls to lock will return None.
Sourcefn get_version(&self) -> Version
fn get_version(&self) -> Version
Returns the version number used by structs in this layer
Provided Methods§
Sourcefn handle(&self) -> Option<&dyn ReadObjectHandle>
fn handle(&self) -> Option<&dyn ReadObjectHandle>
If the layer is persistent, returns the handle to its contents. Returns None for in-memory layers.
Sourcefn purge_cached_data(&self)
fn purge_cached_data(&self)
Some layer implementations may choose to cache data in-memory. Calling this function will request that the layer purges unused cached data. This is intended to run on a timer.
Sourcefn maybe_contains_key(&self, _key: &K) -> bool
fn maybe_contains_key(&self, _key: &K) -> bool
Returns whether the layer might contain records relevant to key
. Note that this can
return true even if the layer has no records relevant to key
, but it will never return
false if there are such records. (As such, always returning true is a trivially correct
implementation.)
Sourcefn record_inspect_data(self: Arc<Self>, _node: &Node)
fn record_inspect_data(self: Arc<Self>, _node: &Node)
Records inspect data for the layer into node
. Called lazily when inspect is queried.