pmtree::database

Trait Database

Source
pub trait Database {
    type Config: Default;

    // Required methods
    fn new(config: Self::Config) -> PmtreeResult<Self>
       where Self: Sized;
    fn load(config: Self::Config) -> PmtreeResult<Self>
       where Self: Sized;
    fn get(&self, key: DBKey) -> PmtreeResult<Option<Value>>;
    fn put(&mut self, key: DBKey, value: Value) -> PmtreeResult<()>;
    fn put_batch(&mut self, subtree: HashMap<DBKey, Value>) -> PmtreeResult<()>;
    fn close(&mut self) -> PmtreeResult<()>;
}
Expand description

Trait that must be implemented for a Database

Required Associated Types§

Source

type Config: Default

Config for database. Default is necessary for a default() pmtree function

Required Methods§

Source

fn new(config: Self::Config) -> PmtreeResult<Self>
where Self: Sized,

Creates new instance of db

Source

fn load(config: Self::Config) -> PmtreeResult<Self>
where Self: Sized,

Loades existing db (existence check required)

Source

fn get(&self, key: DBKey) -> PmtreeResult<Option<Value>>

Returns value from db by the key

Source

fn put(&mut self, key: DBKey, value: Value) -> PmtreeResult<()>

Puts the value to the db by the key

Source

fn put_batch(&mut self, subtree: HashMap<DBKey, Value>) -> PmtreeResult<()>

Puts the leaves batch to the db

Source

fn close(&mut self) -> PmtreeResult<()>

Closes the db connection

Implementors§