Trait engine_traits::iterable::Iterator [−][src]
An iterator over a consistent set of keys and values.
Iterators are implemented for KvEngine
s and for Snapshot
s. They see a
consistent view of the database; an iterator created by an engine behaves as
if a snapshot was created first, and the iterator created from the snapshot.
Most methods on iterators will panic if they are not “valid”,
as determined by the valid
method.
An iterator is valid if it is currently “pointing” to a key/value pair.
Iterators begin in an invalid state; one of the seek
methods
must be called before beginning iteration.
Iterators may become invalid after a failed seek
,
or after iteration has ended after calling next
or prev
,
and they return false
.
Required methods
fn seek(&mut self, key: SeekKey<'_>) -> Result<bool>
[src]
Move the iterator to a specific key.
When key
is SeekKey::Start
or SeekKey::End
,
seek
and seek_for_prev
behave identically.
The difference between the two functions is how they
behave for SeekKey::Key
, and only when an exactly
matching keys is not found:
When seeking with SeekKey::Key
, and an exact match is not found,
seek
sets the iterator to the next key greater than that
specified as key
, if such a key exists;
seek_for_prev
sets the iterator to the previous key less than
that specified as key
, if such a key exists.
Returns
true
if seeking succeeded and the iterator is valid,
false
if seeking failed and the iterator is invalid.
fn seek_for_prev(&mut self, key: SeekKey<'_>) -> Result<bool>
[src]
Move the iterator to a specific key.
For the difference between this method and seek
,
see the documentation for seek
.
Returns
true
if seeking succeeded and the iterator is valid,
false
if seeking failed and the iterator is invalid.
fn prev(&mut self) -> Result<bool>
[src]
fn next(&mut self) -> Result<bool>
[src]
fn key(&self) -> &[u8]
[src]
fn value(&self) -> &[u8]
[src]
fn valid(&self) -> Result<bool>
[src]
Returns true
if the iterator points to a key
/value
pair.
Provided methods
fn seek_to_first(&mut self) -> Result<bool>
[src]
Short for seek(SeekKey::Start)
.
fn seek_to_last(&mut self) -> Result<bool>
[src]
Short for seek(SeekKey::End)
.