pub trait ReadableVec<I: VecIndex, T: VecValue>: AnyVec {
Show 39 methods
// Required methods
fn read_into_at(&self, from: usize, to: usize, buf: &mut Vec<T>);
fn for_each_range_dyn_at(
&self,
from: usize,
to: usize,
f: &mut dyn FnMut(T),
);
fn fold_range_at<B, F: FnMut(B, T) -> B>(
&self,
from: usize,
to: usize,
init: B,
f: F,
) -> B
where Self: Sized;
fn try_fold_range_at<B, E, F: FnMut(B, T) -> Result<B, E>>(
&self,
from: usize,
to: usize,
init: B,
f: F,
) -> Result<B, E>
where Self: Sized;
// Provided methods
fn read_into(&self, from: I, to: I, buf: &mut Vec<T>) { ... }
fn cursor(&self) -> Cursor<'_, I, T, Self>
where Self: Sized { ... }
fn for_each_range_dyn(&self, from: I, to: I, f: &mut dyn FnMut(T)) { ... }
fn fold_range<B, F: FnMut(B, T) -> B>(
&self,
from: I,
to: I,
init: B,
f: F,
) -> B
where Self: Sized { ... }
fn try_fold_range<B, E, F: FnMut(B, T) -> Result<B, E>>(
&self,
from: I,
to: I,
init: B,
f: F,
) -> Result<B, E>
where Self: Sized { ... }
fn for_each_range<F: FnMut(T)>(&self, from: I, to: I, f: F)
where Self: Sized { ... }
fn collect_range(&self, from: I, to: I) -> Vec<T>
where Self: Sized { ... }
fn collect_one(&self, index: I) -> Option<T> { ... }
fn min(&self, from: I, to: I) -> Option<T>
where Self: Sized,
T: PartialOrd { ... }
fn max(&self, from: I, to: I) -> Option<T>
where Self: Sized,
T: PartialOrd { ... }
fn sum(&self, from: I, to: I) -> Option<T>
where Self: Sized,
T: AddAssign + From<u8> { ... }
fn for_each_range_at<F: FnMut(T)>(&self, from: usize, to: usize, f: F)
where Self: Sized { ... }
fn try_for_each_range_at<E, F: FnMut(T) -> Result<(), E>>(
&self,
from: usize,
to: usize,
f: F,
) -> Result<(), E>
where Self: Sized { ... }
fn for_each<F: FnMut(T)>(&self, f: F)
where Self: Sized { ... }
fn fold<B, F: FnMut(B, T) -> B>(&self, init: B, f: F) -> B
where Self: Sized { ... }
fn collect_range_at(&self, from: usize, to: usize) -> Vec<T>
where Self: Sized { ... }
fn collect_range_into_at(&self, from: usize, to: usize, buf: &mut Vec<T>) { ... }
fn collect_range_dyn(&self, from: usize, to: usize) -> Vec<T> { ... }
fn collect(&self) -> Vec<T>
where Self: Sized { ... }
fn collect_one_at(&self, index: usize) -> Option<T> { ... }
fn collect_first(&self) -> Option<T> { ... }
fn collect_last(&self) -> Option<T> { ... }
fn collect_signed_range(&self, from: Option<i64>, to: Option<i64>) -> Vec<T>
where Self: Sized { ... }
fn collect_signed_range_dyn(
&self,
from: Option<i64>,
to: Option<i64>,
) -> Vec<T> { ... }
fn collect_dyn(&self) -> Vec<T> { ... }
fn read_sorted_into_at(&self, indices: &[usize], out: &mut Vec<T>) { ... }
fn read_sorted_at(&self, indices: &[usize]) -> Vec<T> { ... }
fn read_sorted_into(&self, indices: &[I], out: &mut Vec<T>) { ... }
fn read_sorted(&self, indices: &[I]) -> Vec<T> { ... }
fn min_at(&self, from: usize, to: usize) -> Option<T>
where Self: Sized,
T: PartialOrd { ... }
fn min_dyn(&self, from: usize, to: usize) -> Option<T>
where T: PartialOrd { ... }
fn max_at(&self, from: usize, to: usize) -> Option<T>
where Self: Sized,
T: PartialOrd { ... }
fn max_dyn(&self, from: usize, to: usize) -> Option<T>
where T: PartialOrd { ... }
fn sum_at(&self, from: usize, to: usize) -> Option<T>
where Self: Sized,
T: AddAssign + From<u8> { ... }
fn sum_dyn(&self, from: usize, to: usize) -> Option<T>
where T: AddAssign + From<u8> { ... }
}Expand description
High-performance reading of vector values.
This is the primary trait for reading data from any vec type — stored, compressed, lazy, or computed. All methods see the full state including uncommitted (pushed) values.
§Method overview
| Method | Use when |
|---|---|
for_each / for_each_range | Processing every element, static dispatch |
fold / fold_range | Accumulating a result (SIMD-optimized on stored vecs) |
collect / collect_range | Materializing values into a Vec<T> |
collect_one / collect_first / collect_last | Materializing a single value |
for_each_range_dyn | Trait-object contexts (&dyn ReadableVec) |
try_fold_range | Fold with early exit on error |
read_into / cursor | Sequential access with buffer reuse |
§Typed vs _at methods
Methods like collect_one(I), fold_range(I, I, …) accept the typed index I.
The _at variants (collect_one_at(usize), fold_range_at(usize, usize, …))
accept raw usize and are what implementations override.
§Point reads
For raw vecs, use VecReader::get() for O(1) random access.
For any vec through the trait, use collect_one(i) — this materializes
a single value (decodes a page for compressed vecs).
§Performance
Stored vecs override fold_range_at and try_fold_range_at to delegate to their
internal source’s optimized fold(), enabling SIMD auto-vectorization.
The default fold_range_at uses chunked read_into_at calls with a monomorphized
inner loop — LLVM can auto-vectorize this without &mut dyn FnMut overhead.
For maximum throughput on stored vecs, prefer fold_range / for_each_range
with static dispatch (&impl ReadableVec or concrete type).
Required Methods§
Sourcefn read_into_at(&self, from: usize, to: usize, buf: &mut Vec<T>)
fn read_into_at(&self, from: usize, to: usize, buf: &mut Vec<T>)
Appends elements in [from, to) to buf.
Implementations MUST NOT clear buf — they only append. This enables
chunked fold (clear + fill per chunk) and multi-range reads (append
multiple ranges into one buffer).
Object-safe: &mut Vec<T> is a concrete type, no Self: Sized needed.
Sourcefn for_each_range_dyn_at(&self, from: usize, to: usize, f: &mut dyn FnMut(T))
fn for_each_range_dyn_at(&self, from: usize, to: usize, f: &mut dyn FnMut(T))
Iterates over [from, to) by raw index, calling f for each value.
Object-safe: callable on &dyn ReadableVec. Every implementor must
provide this — there is intentionally no default to prevent silent
fallback to a slow buffered path.
Sourcefn fold_range_at<B, F: FnMut(B, T) -> B>(
&self,
from: usize,
to: usize,
init: B,
f: F,
) -> Bwhere
Self: Sized,
fn fold_range_at<B, F: FnMut(B, T) -> B>(
&self,
from: usize,
to: usize,
init: B,
f: F,
) -> Bwhere
Self: Sized,
Folds over [from, to) by raw index with an accumulator.
Every implementor must provide an optimal path — there is intentionally no default to prevent silent fallback to a slow buffered path.
Sourcefn try_fold_range_at<B, E, F: FnMut(B, T) -> Result<B, E>>(
&self,
from: usize,
to: usize,
init: B,
f: F,
) -> Result<B, E>where
Self: Sized,
fn try_fold_range_at<B, E, F: FnMut(B, T) -> Result<B, E>>(
&self,
from: usize,
to: usize,
init: B,
f: F,
) -> Result<B, E>where
Self: Sized,
Fallible fold over [from, to) by raw index with early exit on error.
Every implementor must provide an optimal path — there is intentionally no default to prevent silent fallback to a slow buffered path.
Provided Methods§
Sourcefn read_into(&self, from: I, to: I, buf: &mut Vec<T>)
fn read_into(&self, from: I, to: I, buf: &mut Vec<T>)
Appends elements in [from, to) to buf using typed indices.
Sourcefn cursor(&self) -> Cursor<'_, I, T, Self>where
Self: Sized,
fn cursor(&self) -> Cursor<'_, I, T, Self>where
Self: Sized,
Creates a forward-only Cursor that reuses an internal buffer across
chunked read_into_at calls. One allocation for the lifetime of the cursor.
Sourcefn for_each_range_dyn(&self, from: I, to: I, f: &mut dyn FnMut(T))
fn for_each_range_dyn(&self, from: I, to: I, f: &mut dyn FnMut(T))
Iterates over [from, to) by typed index, calling f for each value (object-safe).
Sourcefn fold_range<B, F: FnMut(B, T) -> B>(&self, from: I, to: I, init: B, f: F) -> Bwhere
Self: Sized,
fn fold_range<B, F: FnMut(B, T) -> B>(&self, from: I, to: I, init: B, f: F) -> Bwhere
Self: Sized,
Folds over [from, to) by typed index with an accumulator.
Sourcefn try_fold_range<B, E, F: FnMut(B, T) -> Result<B, E>>(
&self,
from: I,
to: I,
init: B,
f: F,
) -> Result<B, E>where
Self: Sized,
fn try_fold_range<B, E, F: FnMut(B, T) -> Result<B, E>>(
&self,
from: I,
to: I,
init: B,
f: F,
) -> Result<B, E>where
Self: Sized,
Fallible fold over [from, to) by typed index with early exit on error.
Sourcefn for_each_range<F: FnMut(T)>(&self, from: I, to: I, f: F)where
Self: Sized,
fn for_each_range<F: FnMut(T)>(&self, from: I, to: I, f: F)where
Self: Sized,
Calls f for each value in [from, to) by typed index. Requires Sized.
Sourcefn collect_range(&self, from: I, to: I) -> Vec<T>where
Self: Sized,
fn collect_range(&self, from: I, to: I) -> Vec<T>where
Self: Sized,
Collects values in [from, to) by typed index into a Vec<T>.
Sourcefn collect_one(&self, index: I) -> Option<T>
fn collect_one(&self, index: I) -> Option<T>
Collects a single value at typed index, or None if out of bounds.
Sourcefn min(&self, from: I, to: I) -> Option<T>where
Self: Sized,
T: PartialOrd,
fn min(&self, from: I, to: I) -> Option<T>where
Self: Sized,
T: PartialOrd,
Returns the minimum value in [from, to) by typed index, or None if empty.
Sourcefn max(&self, from: I, to: I) -> Option<T>where
Self: Sized,
T: PartialOrd,
fn max(&self, from: I, to: I) -> Option<T>where
Self: Sized,
T: PartialOrd,
Returns the maximum value in [from, to) by typed index, or None if empty.
Sourcefn sum(&self, from: I, to: I) -> Option<T>
fn sum(&self, from: I, to: I) -> Option<T>
Returns the sum of values in [from, to) by typed index, or None if empty.
Sourcefn for_each_range_at<F: FnMut(T)>(&self, from: usize, to: usize, f: F)where
Self: Sized,
fn for_each_range_at<F: FnMut(T)>(&self, from: usize, to: usize, f: F)where
Self: Sized,
Calls f for each value in [from, to) by raw index. Requires Sized (static dispatch).
Sourcefn try_for_each_range_at<E, F: FnMut(T) -> Result<(), E>>(
&self,
from: usize,
to: usize,
f: F,
) -> Result<(), E>where
Self: Sized,
fn try_for_each_range_at<E, F: FnMut(T) -> Result<(), E>>(
&self,
from: usize,
to: usize,
f: F,
) -> Result<(), E>where
Self: Sized,
Fallible for-each over [from, to) by raw index with early exit on error.
Sourcefn fold<B, F: FnMut(B, T) -> B>(&self, init: B, f: F) -> Bwhere
Self: Sized,
fn fold<B, F: FnMut(B, T) -> B>(&self, init: B, f: F) -> Bwhere
Self: Sized,
Folds over all values with an accumulator.
Sourcefn collect_range_at(&self, from: usize, to: usize) -> Vec<T>where
Self: Sized,
fn collect_range_at(&self, from: usize, to: usize) -> Vec<T>where
Self: Sized,
Collects values in [from, to) by raw index into a Vec<T>.
Sourcefn collect_range_into_at(&self, from: usize, to: usize, buf: &mut Vec<T>)
fn collect_range_into_at(&self, from: usize, to: usize, buf: &mut Vec<T>)
Clears buf then fills it with values in [from, to). Reuses the buffer allocation.
Sourcefn collect_range_dyn(&self, from: usize, to: usize) -> Vec<T>
fn collect_range_dyn(&self, from: usize, to: usize) -> Vec<T>
Collects values in [from, to) into a Vec<T> (object-safe).
Sourcefn collect_one_at(&self, index: usize) -> Option<T>
fn collect_one_at(&self, index: usize) -> Option<T>
Collects a single value at raw index, or None if out of bounds.
Uses for_each_range_dyn_at with a stack-local Option. Stored vecs
override for_each_range_dyn_at → fold_range_at for zero-alloc reads;
lazy vecs override collect_one_at directly.
Sourcefn collect_first(&self) -> Option<T>
fn collect_first(&self) -> Option<T>
Collects the first value, or None if empty.
Sourcefn collect_last(&self) -> Option<T>
fn collect_last(&self) -> Option<T>
Collects the last value, or None if empty.
Sourcefn collect_signed_range(&self, from: Option<i64>, to: Option<i64>) -> Vec<T>where
Self: Sized,
fn collect_signed_range(&self, from: Option<i64>, to: Option<i64>) -> Vec<T>where
Self: Sized,
Collects values using signed indices. Negative indices count from the end
(Python-style): -1 is the last element, -2 is second-to-last, etc.
Sourcefn collect_signed_range_dyn(&self, from: Option<i64>, to: Option<i64>) -> Vec<T>
fn collect_signed_range_dyn(&self, from: Option<i64>, to: Option<i64>) -> Vec<T>
Collects values using signed indices (object-safe).
Sourcefn collect_dyn(&self) -> Vec<T>
fn collect_dyn(&self) -> Vec<T>
Collects all values into a Vec<T> (object-safe).
Sourcefn read_sorted_into_at(&self, indices: &[usize], out: &mut Vec<T>)
fn read_sorted_into_at(&self, indices: &[usize], out: &mut Vec<T>)
Reads values at specific sorted indices (ascending), skipping holes.
Default uses a forward-only Cursor — each underlying page is read
at most once. Lazy vecs override to map indices to their source and
call this method recursively, bottoming out at stored vecs.
indices must be sorted ascending. Output order matches indices.
Sourcefn read_sorted_at(&self, indices: &[usize]) -> Vec<T>
fn read_sorted_at(&self, indices: &[usize]) -> Vec<T>
Reads values at specific sorted indices (ascending), returning a new Vec.
Sourcefn read_sorted_into(&self, indices: &[I], out: &mut Vec<T>)
fn read_sorted_into(&self, indices: &[I], out: &mut Vec<T>)
Reads values at specific sorted typed indices, appending to out.
Sourcefn read_sorted(&self, indices: &[I]) -> Vec<T>
fn read_sorted(&self, indices: &[I]) -> Vec<T>
Reads values at specific sorted typed indices, returning a new Vec.
Sourcefn min_at(&self, from: usize, to: usize) -> Option<T>where
Self: Sized,
T: PartialOrd,
fn min_at(&self, from: usize, to: usize) -> Option<T>where
Self: Sized,
T: PartialOrd,
Returns the minimum value in [from, to) by raw index, or None if empty.
Sourcefn min_dyn(&self, from: usize, to: usize) -> Option<T>where
T: PartialOrd,
fn min_dyn(&self, from: usize, to: usize) -> Option<T>where
T: PartialOrd,
Returns the minimum value in [from, to), or None if empty (object-safe).
Sourcefn max_at(&self, from: usize, to: usize) -> Option<T>where
Self: Sized,
T: PartialOrd,
fn max_at(&self, from: usize, to: usize) -> Option<T>where
Self: Sized,
T: PartialOrd,
Returns the maximum value in [from, to) by raw index, or None if empty.
Sourcefn max_dyn(&self, from: usize, to: usize) -> Option<T>where
T: PartialOrd,
fn max_dyn(&self, from: usize, to: usize) -> Option<T>where
T: PartialOrd,
Returns the maximum value in [from, to), or None if empty (object-safe).