Trait keyvalint::Cursor

source ·
pub trait Cursor {
    type Error: Debug;

    // Required methods
    fn seek_to_first(&mut self) -> Result<(), Self::Error>;
    fn seek_to_last(&mut self) -> Result<(), Self::Error>;
    fn seek(&mut self, key: &[u8]) -> Result<(), Self::Error>;
    fn prev(&mut self) -> Result<(), Self::Error>;
    fn next(&mut self) -> Result<(), Self::Error>;
    fn key(&self) -> Option<KeyRef<'_>>;
    fn value(&self) -> Option<&[u8]>;

    // Provided method
    fn key_value(&self) -> Option<KeyValueRef<'_>> { ... }
}
Expand description

A Cursor allows for iterating through data.

Required Associated Types§

source

type Error: Debug

The type of error returned by this cursor.

Required Methods§

source

fn seek_to_first(&mut self) -> Result<(), Self::Error>

Seek past the first valid key-value pair to a beginning-of-stream sentinel.

source

fn seek_to_last(&mut self) -> Result<(), Self::Error>

Seek past the last valid key-value pair to an end-of-stream sentinel.

source

fn seek(&mut self, key: &[u8]) -> Result<(), Self::Error>

Seek to this key. After a call to seek, the values of [key] and [value] should return the sought-to key or the key that’s lexicographically next after key.

source

fn prev(&mut self) -> Result<(), Self::Error>

Advance the cursor forward to the lexicographically-previous key.

source

fn next(&mut self) -> Result<(), Self::Error>

Advance the cursor forward to the lexicographically-next key.

source

fn key(&self) -> Option<KeyRef<'_>>

The key where this cursor is positioned, or None if the cursor is positioned at the bounds.

source

fn value(&self) -> Option<&[u8]>

The value where this cursor is positioned, or None if the cursor is positioned at a tombstone or the limits of the cursor.

Provided Methods§

source

fn key_value(&self) -> Option<KeyValueRef<'_>>

Return a KeyValueRef corresponding to the current position of the cursor. By default this will stitch together the values of key() and value() to make a KeyValueRef.

Trait Implementations§

source§

impl<E: Debug> Cursor for Box<dyn Cursor<Error = E>>

§

type Error = E

The type of error returned by this cursor.
source§

fn seek_to_first(&mut self) -> Result<(), Self::Error>

Seek past the first valid key-value pair to a beginning-of-stream sentinel.
source§

fn seek_to_last(&mut self) -> Result<(), Self::Error>

Seek past the last valid key-value pair to an end-of-stream sentinel.
source§

fn seek(&mut self, key: &[u8]) -> Result<(), Self::Error>

Seek to this key. After a call to seek, the values of [key] and [value] should return the sought-to key or the key that’s lexicographically next after key.
source§

fn prev(&mut self) -> Result<(), Self::Error>

Advance the cursor forward to the lexicographically-previous key.
source§

fn next(&mut self) -> Result<(), Self::Error>

Advance the cursor forward to the lexicographically-next key.
source§

fn key(&self) -> Option<KeyRef<'_>>

The key where this cursor is positioned, or None if the cursor is positioned at the bounds.
source§

fn value(&self) -> Option<&[u8]>

The value where this cursor is positioned, or None if the cursor is positioned at a tombstone or the limits of the cursor.
source§

fn key_value(&self) -> Option<KeyValueRef<'_>>

Return a KeyValueRef corresponding to the current position of the cursor. By default this will stitch together the values of key() and value() to make a KeyValueRef.

Implementations on Foreign Types§

source§

impl Cursor for ()

§

type Error = ()

source§

fn seek_to_first(&mut self) -> Result<(), Self::Error>

source§

fn seek_to_last(&mut self) -> Result<(), Self::Error>

source§

fn seek(&mut self, _: &[u8]) -> Result<(), Self::Error>

source§

fn prev(&mut self) -> Result<(), Self::Error>

source§

fn next(&mut self) -> Result<(), Self::Error>

source§

fn key(&self) -> Option<KeyRef<'_>>

source§

fn value(&self) -> Option<&[u8]>

source§

impl<E: Debug> Cursor for Box<dyn Cursor<Error = E>>

§

type Error = E

source§

fn seek_to_first(&mut self) -> Result<(), Self::Error>

source§

fn seek_to_last(&mut self) -> Result<(), Self::Error>

source§

fn seek(&mut self, key: &[u8]) -> Result<(), Self::Error>

source§

fn prev(&mut self) -> Result<(), Self::Error>

source§

fn next(&mut self) -> Result<(), Self::Error>

source§

fn key(&self) -> Option<KeyRef<'_>>

source§

fn value(&self) -> Option<&[u8]>

Implementors§