pub trait PostingCursor {
// Required methods
fn peek(&self) -> Option<Posting>;
fn advance(&mut self);
fn seek(&mut self, target: RecordId) -> Option<Posting>;
fn remaining(&self) -> usize;
fn last_id(&self) -> Option<RecordId>;
fn exhaust(&mut self);
// Provided methods
fn upper_bound(&self) -> Weight { ... }
fn lower_bound(&self) -> Weight { ... }
fn drain_through(
&mut self,
hi: RecordId,
visit: impl FnMut(RecordId, Weight),
) { ... }
fn is_exhausted(&self) -> bool { ... }
}Expand description
A forward-only reader over one posting list, sorted by record id.
A cursor is always positioned either on an element (the current one,
returned by peek) or past the end. It only ever moves
forward: seek with a target at or below the current id
is a no-op that returns the current element, and moving backwards is
never required by the search loop.
Implementations back the cursor with any storage — a Vec in RAM, an
mmap’d slice, a decoded block — as long as they honour the ceiling
invariant: upper_bound is at least the weight of
every element from the current position to the end of the list.
Required Methods§
Sourcefn peek(&self) -> Option<Posting>
fn peek(&self) -> Option<Posting>
The current element, or None once the cursor is past the end.
Sourcefn seek(&mut self, target: RecordId) -> Option<Posting>
fn seek(&mut self, target: RecordId) -> Option<Posting>
Move forward to the first element whose id is >= target and return
it. Returns None when no such element exists; the cursor is then
past the end. Never moves backwards.
Provided Methods§
Sourcefn upper_bound(&self) -> Weight
fn upper_bound(&self) -> Weight
An upper bound on the weights of the elements not yet consumed, the
current one included. f32::NEG_INFINITY once past the end.
Sourcefn lower_bound(&self) -> Weight
fn lower_bound(&self) -> Weight
A lower bound on the weights of the elements not yet consumed. The default is unbounded, which is always correct; storages that track a suffix minimum can tighten it so negative query weights prune too.
Sourcefn drain_through(&mut self, hi: RecordId, visit: impl FnMut(RecordId, Weight))
fn drain_through(&mut self, hi: RecordId, visit: impl FnMut(RecordId, Weight))
Consume every element with id <= hi, handing each (id, weight) to
visit in id order. Leaves the cursor on the first element above
hi (or past the end).
Sourcefn is_exhausted(&self) -> bool
fn is_exhausted(&self) -> bool
True once the cursor is past the end.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".