Struct tinycdb::Cdb [] [src]

pub struct Cdb {
    // some fields omitted
}

The Cdb struct represents an open instance of a CDB database.

Methods

impl Cdb
[src]

fn open(path: &Path) -> CdbResult<Box<Cdb>>

open(path) will open the CDB database at the given file path, returning either the CDB struct or an error indicating why the database could not be opened.

fn new<F>(path: &Path, create: F) -> CdbResult<Box<Cdb>> where F: FnMut(&mut CdbCreator)

new(path, cb) is responsible for creating a new CDB database. The given closure is called with an instance of a CdbCreator, allowing the closure to insert values into the CDB database. Once the closure returns, the database can no longer be updated. The now-open database instance is then returned.

fn find(&mut self, key: &[u8]) -> Option<&[u8]>

find(key) searches the database for the given key, and, if it's found, will return the associated value as an immutable byte slice. Note that, since it is possible to have multiple records with the same key, find will only return the value of the first key.

fn find_mut(&mut self, key: &[u8]) -> Option<Vec<u8>>

find_mut(key) searches the database for the given key, and, if it's found, will return the associated value as a Vec<u8>. Note that, since it is possible to have multiple records with the same key, find_mut will only return the value of the first key.

fn exists(&mut self, key: &[u8]) -> bool

exists(key) returns whether the key exists in the database. This is essentially the same as the find(key) call, except that it does not allocate space for the returned value, and thus may be faster.

fn iter<'i>(&'i mut self) -> CdbIterator<'i>

iter() returns an iterator over all the keys in the database. Only one iterator for a database can be active at a time.

Trait Implementations

impl Drop for Cdb
[src]

fn drop(&mut self)

A method called when the value goes out of scope. Read more