Trait sstable::SSIterator
source · pub trait SSIterator {
// Required methods
fn advance(&mut self) -> bool;
fn current(&self, key: &mut Vec<u8>, val: &mut Vec<u8>) -> bool;
fn current_key(&self) -> Option<&[u8]>;
fn seek(&mut self, key: &[u8]);
fn reset(&mut self);
fn valid(&self) -> bool;
fn prev(&mut self) -> bool;
// Provided methods
fn next(&mut self) -> Option<(Vec<u8>, Vec<u8>)> { ... }
fn seek_to_first(&mut self) { ... }
}
Expand description
An extension of the standard Iterator
trait that supporting some additional functionality.
Note: Implementing types are expected to hold !valid()
before the first call to advance()
,
and after advance()
has returned false
for the first time.
test_util::test_iterator_properties() verifies that all properties hold for a given implementation.
Required Methods§
sourcefn advance(&mut self) -> bool
fn advance(&mut self) -> bool
Advances the position of the iterator by one element (which can be retrieved using current(). If no more elements are available, advance() returns false, and the iterator becomes invalid (i.e. as if reset() had been called).
sourcefn current(&self, key: &mut Vec<u8>, val: &mut Vec<u8>) -> bool
fn current(&self, key: &mut Vec<u8>, val: &mut Vec<u8>) -> bool
Return the current item (i.e. the item most recently returned by next()
).
sourcefn current_key(&self) -> Option<&[u8]>
fn current_key(&self) -> Option<&[u8]>
Return a reference to the key of the current item (i.e. the item most recently returned by next()
).
sourcefn seek(&mut self, key: &[u8])
fn seek(&mut self, key: &[u8])
Seek the iterator to key
or the next bigger key. If the seek is invalid (past last
element, or before first element), the iterator is reset()
and not valid.
sourcefn reset(&mut self)
fn reset(&mut self)
Resets the iterator to be !valid()
, i.e. positioned before the first element.
Provided Methods§
sourcefn next(&mut self) -> Option<(Vec<u8>, Vec<u8>)>
fn next(&mut self) -> Option<(Vec<u8>, Vec<u8>)>
next is like Iterator::next(). It’s implemented here because Rust disallows implementing a
foreign trait for any type, thus we can’t do impl<T: SSIterator> Iterator<Item=Vec<u8>> for T {}
.
sourcefn seek_to_first(&mut self)
fn seek_to_first(&mut self)
seek_to_first seeks to the first element.
Trait Implementations§
source§impl Iterator for dyn SSIterator
impl Iterator for dyn SSIterator
source§fn next(&mut self) -> Option<Self::Item>
fn next(&mut self) -> Option<Self::Item>
1.0.0 · source§fn size_hint(&self) -> (usize, Option<usize>)
fn size_hint(&self) -> (usize, Option<usize>)
source§fn advance_by(&mut self, n: usize) -> Result<(), NonZeroUsize>
fn advance_by(&mut self, n: usize) -> Result<(), NonZeroUsize>
iter_advance_by
)n
elements. Read moresource§impl SSIterator for Box<dyn SSIterator>
impl SSIterator for Box<dyn SSIterator>
source§fn advance(&mut self) -> bool
fn advance(&mut self) -> bool
source§fn current(&self, key: &mut Vec<u8>, val: &mut Vec<u8>) -> bool
fn current(&self, key: &mut Vec<u8>, val: &mut Vec<u8>) -> bool
next()
).source§fn current_key(&self) -> Option<&[u8]>
fn current_key(&self) -> Option<&[u8]>
next()
).source§fn seek(&mut self, key: &[u8])
fn seek(&mut self, key: &[u8])
key
or the next bigger key. If the seek is invalid (past last
element, or before first element), the iterator is reset()
and not valid.source§fn reset(&mut self)
fn reset(&mut self)
!valid()
, i.e. positioned before the first element.source§fn valid(&self) -> bool
fn valid(&self) -> bool
current()
would succeed.source§fn prev(&mut self) -> bool
fn prev(&mut self) -> bool
prev()
returns false and it will be !valid()
. This is inefficient for most iterator
implementations.source§fn next(&mut self) -> Option<(Vec<u8>, Vec<u8>)>
fn next(&mut self) -> Option<(Vec<u8>, Vec<u8>)>
impl<T: SSIterator> Iterator<Item=Vec<u8>> for T {}
.