pub struct ScopedKvStore<KV> { /* private fields */ }Expand description
A directory-pinned view of another KvStore.
The store is pinned to a directory, and every operation’s directory argument is a relative path from the pin: the empty path names the pinned directory itself, and a non-empty path names a subdirectory of it. The inner store sees the joined absolute path; the caller never types the pinned part again. Bounds pass through unchanged — they are always over the within-directory key, so a scan yields keys of the directory the call names.
The pinned directory (and any relative subdirectory) is created lazily like any other (the first write allocates it); reads on a never-written directory are empty.
This type is scope plumbing, not a capability boundary.
Self::inner, Self::inner_mut, and Self::into_inner deliberately
expose the wrapped store, through which code may access any directory.
Callers that need structural isolation must not hand out those escape
hatches. Higher layers own that restriction; the scoped handles held by
state-machine crates are the actual capability boundary.
§Commit
Commit forwards straight through, unwrapped: pinning a directory
cannot fail at commit time, so there is no scoped error to introduce and
the caller keeps the backend’s own commit error type.
Implementations§
Source§impl<KV> ScopedKvStore<KV>
impl<KV> ScopedKvStore<KV>
Sourcepub fn new(inner: KV, dir: impl Into<Vec<Vec<u8>>>) -> Self
pub fn new(inner: KV, dir: impl Into<Vec<Vec<u8>>>) -> Self
Wrap inner, pinning every operation under the directory dir:
a caller path p is issued to the inner store as dir ++ p.
An empty directory pins the root and yields a transparent pass-through view.
Sourcepub fn inner_mut(&mut self) -> &mut KV
pub fn inner_mut(&mut self) -> &mut KV
Mutably borrow the wrapped store, which still sees any directory.
Sourcepub fn into_inner(self) -> KV
pub fn into_inner(self) -> KV
Unwrap, returning the underlying store.