changelog shortlog graph tags branches changeset files revisions annotate raw help

Mercurial > core / rust/lib/db/src/lib.rs

changeset 698: 96958d3eb5b0
parent: f3d814fb136a
author: Richard Westhaver <ellis@rwest.io>
date: Fri, 04 Oct 2024 22:04:59 -0400
permissions: -rw-r--r--
description: fixes
1 //! db modules
2 //!
3 //! This library provides types and builder functions for working with
4 //! databases. Currently the only backend supported is RocksDB.
5 #![feature(associated_type_defaults)]
6 use obj::Configure;
7 #[cfg(feature = "rocksdb")]
8 pub use rocksdb;
9 use std::path::PathBuf;
10 
11 mod err;
12 pub use err::{Error, Result};
13 
14 #[cfg(test)]
15 mod tests;
16 
17 pub trait Db {
18  #[cfg(feature = "rocksdb")]
19  type DB = rocksdb::DB;
20  #[cfg(not(feature = "rocksdb"))]
21  type DB;
22  fn db_init(&self) -> Result<Self::DB>;
23  fn db_init_mut(&mut self) -> Result<()>;
24  fn db_open(&self) -> Result<()>;
25  fn db_close(&self) -> Result<()>;
26  fn db_close_mut(&mut self) -> Result<()>;
27  fn db_query(&self) -> Result<()>;
28  fn db_transaction(&self) -> Result<()>;
29 }
30 
31 pub trait DbConfigExt: Configure {
32  fn db_path(self) -> Option<PathBuf>;
33  fn db_user(self) -> Option<String>;
34  fn set_db_config_value(&mut self, key: &str, val: &str) -> Option<String>;
35  fn get_db_config_value(self, key: &str) -> Option<String>;
36 }