pub struct PersistentLayer<K, V> { /* private fields */ }Expand description
A handle to an asynchronous, chunk-cached persistent layer.
Implementations§
Source§impl<K: Key, V: LayerValue> PersistentLayer<K, V>
impl<K: Key, V: LayerValue> PersistentLayer<K, V>
pub async fn open( handle: impl LayerObject + 'static, ) -> Result<Arc<dyn Layer<K, V>>, Error>
pub async fn open_layer( handle: Arc<dyn LayerObject>, ) -> Result<Arc<dyn Layer<K, V>>, Error>
pub async fn open_async( handle: Arc<dyn LayerObject>, ) -> Result<Arc<Self>, Error>
Sourcepub async fn open_handle(
handle: DataObjectHandle<ObjectStore>,
unwrapped_key: Option<UnwrappedKey>,
) -> Result<Arc<dyn Layer<K, V>>, Error>
pub async fn open_handle( handle: DataObjectHandle<ObjectStore>, unwrapped_key: Option<UnwrappedKey>, ) -> Result<Arc<dyn Layer<K, V>>, Error>
Opens a persistent layer backed by handle. If the layer is encrypted and the platform
uses a pager, unwrapped_key is registered with the pager and dropped immediately.
Trait Implementations§
Source§impl<K: Key, V: LayerValue> Layer<K, V> for PersistentLayer<K, V>
impl<K: Key, V: LayerValue> Layer<K, V> for PersistentLayer<K, V>
Source§fn 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.
Source§fn 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.
Source§fn clear_cached_data(&self)
fn clear_cached_data(&self)
Immediately clears any in-memory cached data for this layer.
Source§fn seek<'a, 'life0, 'async_trait>(
&'a self,
bound: Bound<&'life0 K>,
) -> Pin<Box<dyn Future<Output = Result<BoxedLayerIterator<'a, K, V>, Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'a: 'async_trait,
'life0: 'async_trait,
fn seek<'a, 'life0, 'async_trait>(
&'a self,
bound: Bound<&'life0 K>,
) -> Pin<Box<dyn Future<Output = Result<BoxedLayerIterator<'a, K, V>, Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'a: 'async_trait,
'life0: 'async_trait,
Searches for a key. Bound::Excluded is not supported. Bound::Unbounded positions the
iterator on the first item in the layer.
Source§fn maybe_contains_key(&self, key: &K) -> MaybeContainsKey
fn maybe_contains_key(&self, key: &K) -> MaybeContainsKey
Returns whether the layer might contain records relevant to
key. Note that this can
return MaybeContainsKey::Maybe even if the layer has no records relevant to key, but it will
never return MaybeContainsKey::False if there are such records. (As such, always
returning MaybeContainsKey::Maybe is a trivially correct implementation.)
If the key has too many hash partitions to check against the existence filter, returns
MaybeContainsKey::RangeKeyTooLarge.Source§fn has_bloom_filter(&self) -> bool
fn has_bloom_filter(&self) -> bool
Whether the bloom filter for the layer file is consulted or not. If this is false, then
maybe_contains_key will always return MaybeContainsKey::Maybe.
Note that the persistent layer file may still have a bloom filter, but it might be ignored
(e.g. for a layer file on an older version).Source§fn key_exists<'life0, 'life1, 'async_trait>(
&'life0 self,
key: &'life1 K,
) -> Pin<Box<dyn Future<Output = Result<Existence, Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn key_exists<'life0, 'life1, 'async_trait>(
&'life0 self,
key: &'life1 K,
) -> Pin<Box<dyn Future<Output = Result<Existence, Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
This is similar to
maybe_contains_key except that there must be a key and possible
state where this will indicate the key is missing i.e. always returning
Existence::MaybeExists is not a correct implementation. If an implementation has a low
cost way to determine if the key might exist, then it may use that, but if not, it must
use a slower algorithm. This method was introduced to allow for an efficient way of
determining if a particular key is free to be used. maybe_contains_key cannot be used for
this purpose because implementations might always return true which would mean it would
be impossible to ever find a key that is free to use. It might not be appropriate to use
this with range based keys: implementations should use cmp_upper_bound and test for
equality, which might not give the desired results for range based keys.Source§fn 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.
Source§fn 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.
Source§fn get_version(&self) -> Version
fn get_version(&self) -> Version
Returns the version number used by structs in this layer
Source§fn 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.Auto Trait Implementations§
impl<K, V> !Freeze for PersistentLayer<K, V>
impl<K, V> !RefUnwindSafe for PersistentLayer<K, V>
impl<K, V> !UnwindSafe for PersistentLayer<K, V>
impl<K, V> Send for PersistentLayer<K, V>
impl<K, V> Sync for PersistentLayer<K, V>
impl<K, V> Unpin for PersistentLayer<K, V>
impl<K, V> UnsafeUnpin for PersistentLayer<K, V>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
§impl<T, D> Encode<Ambiguous1, D> for Twhere
D: ResourceDialect,
impl<T, D> Encode<Ambiguous1, D> for Twhere
D: ResourceDialect,
§impl<T, D> Encode<Ambiguous2, D> for Twhere
D: ResourceDialect,
impl<T, D> Encode<Ambiguous2, D> for Twhere
D: ResourceDialect,
§impl<F, N> FidlIntoNative<Box<N>> for Fwhere
F: FidlIntoNative<N>,
impl<F, N> FidlIntoNative<Box<N>> for Fwhere
F: FidlIntoNative<N>,
fn fidl_into_native(self) -> Box<N>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more