pub struct CDB { /* private fields */ }Expand description
CDB file reader
§Example
use cdb2::CDB;
let cdb = CDB::open("tests/test1.cdb")?;
for result in cdb.find(b"one") {
println!("{:?}", result?);
}Implementations§
Source§impl CDB
impl CDB
Sourcepub fn open<P: AsRef<Path>>(filename: P) -> Result<CDB>
pub fn open<P: AsRef<Path>>(filename: P) -> Result<CDB>
Opens the named file and returns the CDB reader.
§Examples
use cdb2::CDB;
let cdb = CDB::open("tests/test1.cdb")?;Sourcepub fn get(&self, key: &[u8]) -> Option<Result<Vec<u8>>>
pub fn get(&self, key: &[u8]) -> Option<Result<Vec<u8>>>
Find the first record with the named key.
§Examples
use cdb2::CDB;
let cdb = CDB::open("tests/test1.cdb")?;
if let Some(record) = cdb.get(b"one") {
println!("{:?}", record?);
}Sourcepub fn find(&self, key: &[u8]) -> CDBValueIter<'_> ⓘ
pub fn find(&self, key: &[u8]) -> CDBValueIter<'_> ⓘ
Find all records with the named key. The returned iterator produces each value associated with the key.
§Examples
use cdb2::CDB;
let cdb = CDB::open("tests/test1.cdb")?;
for result in cdb.find(b"one") {
println!("{:?}", result?);
}Sourcepub fn iter(&self) -> CDBKeyValueIter<'_> ⓘ
pub fn iter(&self) -> CDBKeyValueIter<'_> ⓘ
Iterate over all the (key, value) pairs in the database.
§Examples
use cdb2::CDB;
let cdb = CDB::open("tests/test1.cdb")?;
for result in cdb.iter() {
let (key, value) = result?;
println!("{:?} => {:?}", key, value);
}Auto Trait Implementations§
impl Freeze for CDB
impl RefUnwindSafe for CDB
impl Send for CDB
impl Sync for CDB
impl Unpin for CDB
impl UnwindSafe for CDB
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more