[][src]Struct tinycdb::Cdb

pub struct Cdb { /* fields omitted */ }

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

Implementations

impl Cdb[src]

pub fn open(path: &Path) -> CdbResult<Box<Cdb>>[src]

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.

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

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.

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

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.

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

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.

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

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.

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

Important traits for CdbIterator<'a>

impl<'a> Iterator for CdbIterator<'a> type Item = (&'a [u8], &'a [u8]);
[src]

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]

impl Send for Cdb[src]

Auto Trait Implementations

impl RefUnwindSafe for Cdb

impl !Sync for Cdb

impl Unpin for Cdb

impl UnwindSafe for Cdb

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.