[−][src]Struct tinycdb::Cdb
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]
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.
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>ⓘ
[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
Auto Trait Implementations
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,