Cursor

Trait Cursor 

Source
pub trait Cursor {
    // Required methods
    fn close(&mut self) -> Result<(), LsmErrorCode>;
    fn first(&mut self) -> Result<(), LsmErrorCode>;
    fn last(&mut self) -> Result<(), LsmErrorCode>;
    fn seek(
        &mut self,
        key: &[u8],
        mode: LsmCursorSeekOp,
    ) -> Result<(), LsmErrorCode>;
    fn next(&mut self) -> Result<(), LsmErrorCode>;
    fn prev(&mut self) -> Result<(), LsmErrorCode>;
    fn valid(&self) -> Result<(), LsmErrorCode>;
    fn get_key(&self) -> Result<Vec<u8>, LsmErrorCode>;
    fn get_value(&self) -> Result<Vec<u8>, LsmErrorCode>;
    fn compare(&self, key: &[u8]) -> Result<Ordering, LsmErrorCode>;
}
Expand description

Primary set of methods of database cursors.

Required Methods§

Source

fn close(&mut self) -> Result<(), LsmErrorCode>

Closes a database cursor.

Source

fn first(&mut self) -> Result<(), LsmErrorCode>

Moves the cursor to the very first record in the database.

Source

fn last(&mut self) -> Result<(), LsmErrorCode>

Moves the cursor to the very last record in the database.

Source

fn seek( &mut self, key: &[u8], mode: LsmCursorSeekOp, ) -> Result<(), LsmErrorCode>

Moves the cursor in the database to the record pointed by key. How this operation behaves depends on the given seek mode (LsmCursorSeekOp).

Source

fn next(&mut self) -> Result<(), LsmErrorCode>

Moves the cursor to the next record in the database (as seen from the current value the cursor is pointing to).

Source

fn prev(&mut self) -> Result<(), LsmErrorCode>

Moves the cursor to the previous record in the database (as seen from the current value the cursor is pointing to).

Source

fn valid(&self) -> Result<(), LsmErrorCode>

Tests whether the cursor is currently pointing to a valid database record.

Source

fn get_key(&self) -> Result<Vec<u8>, LsmErrorCode>

Obtains a copy of the key of the record the cursor is currently pointing to (if valid).

Source

fn get_value(&self) -> Result<Vec<u8>, LsmErrorCode>

Obtains a copy of the value of the record the cursor is currently pointing to (if valid).

Source

fn compare(&self, key: &[u8]) -> Result<Ordering, LsmErrorCode>

Compares the key the cursor is currently pointing to (if valid) with the given key (as per memcmp). The result of the comparison (< 0, == 0, > 0) is returned.

Implementors§

Source§

impl Cursor for LsmCursor<'_>

Custom implementation of Cursor for LsmCursor.