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§
Required Methods§
sourcefn seek_to_first(&mut self) -> Result<(), Self::Error>
fn seek_to_first(&mut self) -> Result<(), Self::Error>
Seek past the first valid key-value pair to a beginning-of-stream sentinel.
sourcefn seek_to_last(&mut self) -> Result<(), Self::Error>
fn seek_to_last(&mut self) -> Result<(), Self::Error>
Seek past the last valid key-value pair to an end-of-stream sentinel.
sourcefn seek(&mut self, key: &[u8]) -> Result<(), Self::Error>
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.
sourcefn prev(&mut self) -> Result<(), Self::Error>
fn prev(&mut self) -> Result<(), Self::Error>
Advance the cursor forward to the lexicographically-previous key.
sourcefn next(&mut self) -> Result<(), Self::Error>
fn next(&mut self) -> Result<(), Self::Error>
Advance the cursor forward to the lexicographically-next key.
Provided Methods§
sourcefn key_value(&self) -> Option<KeyValueRef<'_>>
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>>
impl<E: Debug> Cursor for Box<dyn Cursor<Error = E>>
source§fn seek_to_first(&mut self) -> Result<(), Self::Error>
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>
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>
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>
fn prev(&mut self) -> Result<(), Self::Error>
Advance the cursor forward to the lexicographically-previous key.
source§fn next(&mut self) -> Result<(), Self::Error>
fn next(&mut self) -> Result<(), Self::Error>
Advance the cursor forward to the lexicographically-next key.
source§fn key(&self) -> Option<KeyRef<'_>>
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]>
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<'_>>
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.