Struct Cursor

Source
pub struct Cursor { /* private fields */ }

Implementations§

Source§

impl Cursor

Source

pub fn next(&mut self) -> Result<(Option<DBT<'_>>, Option<DBT<'_>>), Error>

Iterate over key/data pairs in the database.

§Examples
use libdb::Flags;
// Note: BDB requires that the key and value be mutable.
let mut key   = String::from("key").into_bytes();
let mut value = String::from("value").into_bytes();
let ret = db.put(None, key.as_mut_slice(), value.as_mut_slice(), Flags::DB_NONE);
assert!(ret.is_ok());

// get cursor and iterate
let mut cursor = db.cursor().expect("Failed to get cursor");
let (key_dbt, data_dbt) = cursor.next().expect("Could not walk cursor");
    assert_eq!("key", str::from_utf8(key_dbt.unwrap().as_slice()).unwrap());
    assert_eq!("value", str::from_utf8(data_dbt.unwrap().as_slice()).unwrap());

Auto Trait Implementations§

§

impl Freeze for Cursor

§

impl RefUnwindSafe for Cursor

§

impl !Send for Cursor

§

impl !Sync for Cursor

§

impl Unpin for Cursor

§

impl UnwindSafe for Cursor

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

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

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.