Skip to main content

KvDirNav

Trait KvDirNav 

Source
pub trait KvDirNav: KvStore {
    // Required methods
    fn list_dirs(
        &self,
        dir: &[&[u8]],
    ) -> impl Future<Output = Result<Vec<Vec<u8>>, Self::Error>> + MaybeSend;
    fn dir_exists(
        &self,
        dir: &[&[u8]],
    ) -> impl Future<Output = Result<bool, Self::Error>> + MaybeSend;
    fn remove_dir(
        &mut self,
        dir: &[&[u8]],
    ) -> impl Future<Output = Result<bool, Self::Error>> + MaybeSend;
}
Expand description

Directory navigation over a KvStore.

The data plane addresses data within a directory; this trait addresses the directories themselves. An implementation lists directories from the store’s own mapping: the flat backends scan one contiguous mapping range (O(children), not O(subtree keys)), the FDB backend asks its native directory layer.

All three methods validate their directory path with validate_dir before touching the engine. Their futures follow KvStore’s portability rule: they are Send on native targets and may remain thread-local on browser wasm.

Required Methods§

Source

fn list_dirs( &self, dir: &[&[u8]], ) -> impl Future<Output = Result<Vec<Vec<u8>>, Self::Error>> + MaybeSend

List the immediate child directory names under dir, as segment bytes, sorted ascending.

A missing dir yields an empty list, not an error — dir_exists is how to tell “no children” from “not there”. Output is sorted at this boundary so the ordering is deterministic regardless of the engine’s.

Source

fn dir_exists( &self, dir: &[&[u8]], ) -> impl Future<Output = Result<bool, Self::Error>> + MaybeSend

Whether the directory exists.

“Exists” means the directory is materialised: on the flat backends its child row is present (a directory with zero data keys still exists); the root exists iff the store’s anchor node exists, so a fresh, never-written store’s root does not; on FDB the layer’s mapping entry is present.

Source

fn remove_dir( &mut self, dir: &[&[u8]], ) -> impl Future<Output = Result<bool, Self::Error>> + MaybeSend

Remove dir recursively: its subdirectories (child rows and data) and all of dir’s own key data.

A data-destruction operation: everything under dir is gone, and it cannot be recovered from the store. Ok(true) if a directory existed and was removed, Ok(false) if it did not exist. The root [] is not removable — KeyError::RootNotRemovable.

The whole removal is one transaction on transactional backends.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§