pub struct CDB { /* private fields */ }
Expand description
CDB file reader
Example
let cdb = cdb::CDB::open("tests/test1.cdb").unwrap();
for result in cdb.find(b"one") {
println!("{:?}", result.unwrap());
}
Implementations
sourceimpl 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
let cdb = cdb::CDB::open("tests/test1.cdb").unwrap();
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
let cdb = cdb::CDB::open("tests/test1.cdb").unwrap();
if let Some(record) = cdb.get(b"one") {
println!("{:?}", record.unwrap());
}
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
let cdb = cdb::CDB::open("tests/test1.cdb").unwrap();
for result in cdb.find(b"one") {
println!("{:?}", result.unwrap());
}
sourcepub fn iter(&self) -> CDBKeyValueIter<'_> ⓘ
pub fn iter(&self) -> CDBKeyValueIter<'_> ⓘ
Iterate over all the (key, value)
pairs in the database.
Examples
let cdb = cdb::CDB::open("tests/test1.cdb").unwrap();
for result in cdb.iter() {
let (key, value) = result.unwrap();
println!("{:?} => {:?}", key, value);
}
Auto Trait Implementations
impl RefUnwindSafe for CDB
impl Send for CDB
impl Sync for CDB
impl Unpin for CDB
impl UnwindSafe for CDB
Blanket Implementations
sourceimpl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more