Skip to main content

open_module_db

Function open_module_db 

Source
pub fn open_module_db<P: AsRef<Path>>(data_dir: P) -> Result<Arc<dyn Database>>
Expand description

Open the module’s database at {data_dir}/db/.

Module databases need to create named trees on demand (open_tree()). Only Sled and TidesDB support fully dynamic tree creation. Redb only supports a fixed set of pre-declared tables; RocksDB requires all column families to be declared at open time.

Backend selection (first match wins):

  1. MODULE_CONFIG_DATABASE_BACKEND — set by the node from effective module DB policy (see blvm_node::storage::database::module_subprocess_database_backend_preference)
  2. MODULE_DATABASE_BACKEND env var (same values; manual override)
  3. Auto-select Sled as first choice, then fall back through Sled→TidesDB create_database attempts

If the resolved backend does not support dynamic trees the function warns and falls back as above. If no dynamic backend is compiled into blvm-node, it returns an error.

§Example

let db = open_module_db(module_data_dir)?;
let tree = db.open_tree("my_tree")?;
tree.insert(b"key", b"value")?;