Trait lsmlite_rs::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.