pub struct RaspBatch<T> { /* private fields */ }Expand description
Structure-of-arrays storage for bounds-checked pointers.
T is a phantom type; each entry refers to an externally-owned
[T] region. The caller is responsible for keeping the regions
alive for the lifetime of the batch. Use push_from_slice with
the returned slice as a borrow anchor.
Implementations§
Source§impl<T> RaspBatch<T>
impl<T> RaspBatch<T>
pub fn new() -> Self
pub fn with_capacity(n: usize) -> Self
pub fn len(&self) -> usize
pub fn is_empty(&self) -> bool
pub fn capacity(&self) -> usize
Sourcepub fn push_from_slice<'a>(
&mut self,
slice: &'a [T],
perms: u32,
) -> Result<(RaspBatchIndex<T>, &'a [T]), RaspError>
pub fn push_from_slice<'a>( &mut self, slice: &'a [T], perms: u32, ) -> Result<(RaspBatchIndex<T>, &'a [T]), RaspError>
Push a new pointer from a borrowed slice. The returned slice is the lifetime anchor; the batch’s pointer is valid only as long as the anchor is held.
Sourcepub fn push_raw(
&mut self,
ptr: u64,
base: u64,
length: u32,
perms: u32,
) -> Result<RaspBatchIndex<T>, RaspError>
pub fn push_raw( &mut self, ptr: u64, base: u64, length: u32, perms: u32, ) -> Result<RaspBatchIndex<T>, RaspError>
Push from raw integer fields (caller manages target lifetime).
Sourcepub fn check_read_scalar(&self, idx: RaspBatchIndex<T>) -> Result<(), RaspError>
pub fn check_read_scalar(&self, idx: RaspBatchIndex<T>) -> Result<(), RaspError>
Per-element scalar check. Used by per-index call sites and as the correctness oracle for the SIMD batch path.
Sourcepub fn raw_ptr(&self, idx: RaspBatchIndex<T>) -> Option<*const T>
pub fn raw_ptr(&self, idx: RaspBatchIndex<T>) -> Option<*const T>
Raw pointer at the given index. Returns None for an
out-of-range index. The pointer is NOT validated; pair with
check_read_scalar (or use read_at which combines both).
Sourcepub unsafe fn read_at(&self, idx: RaspBatchIndex<T>) -> Result<T, RaspError>where
T: Copy,
pub unsafe fn read_at(&self, idx: RaspBatchIndex<T>) -> Result<T, RaspError>where
T: Copy,
Bounds + permission check followed by a dereference. The
caller’s responsibility for the original target lifetime
still applies (see push_from_slice’s borrow anchor).
§Safety
The target of the pointer at idx must still be valid
(alive, properly aligned for T, and accessible via the
permissions encoded). The check enforces the permissions
recorded at push time; it does NOT prove the target’s
allocation has not been freed.
Sourcepub fn check_read_all_scalar(&self) -> Vec<Result<(), RaspError>>
pub fn check_read_all_scalar(&self) -> Vec<Result<(), RaspError>>
Batch scalar check across the whole array. Reference path.
Sourcepub fn count_valid_scalar(&self) -> u32
pub fn count_valid_scalar(&self) -> u32
Count of valid entries (Ok results) via scalar path. Avoids
the Vec<Result> allocation when only the count is needed.
Sourcepub unsafe fn count_valid_avx2(&self) -> u32
pub unsafe fn count_valid_avx2(&self) -> u32
AVX2-accelerated count of valid entries. Processes 4 elements
per loop iteration using contiguous SIMD loads from each
parallel Vec.
§Safety
Caller must guarantee AVX2 is supported by the runtime CPU.
Sourcepub unsafe fn count_valid_avx512(&self) -> u32
pub unsafe fn count_valid_avx512(&self) -> u32
AVX-512F count of valid entries. Processes 8 elements per
iteration: ZMM (8x u64) loads for ptrs/bases, YMM (8x u32)
loads for lengths/perms, mask-producing
_mm512_cmpgt_epi64_mask for both bounds checks. Doubles the
per-iteration throughput of the AVX2 path.
§Safety
Caller must guarantee AVX-512F is supported by the runtime CPU.
Sourcepub fn count_valid(&self) -> u32
pub fn count_valid(&self) -> u32
Cross-platform safe count of valid entries. Dispatches to
count_valid_avx512 when AVX-512F is present, then
count_valid_avx2, then count_valid_scalar.
Sourcepub unsafe fn check_read_all_avx2(&self) -> Vec<Result<(), RaspError>>
pub unsafe fn check_read_all_avx2(&self) -> Vec<Result<(), RaspError>>
AVX2-accelerated full validation that writes per-index results.
Slower than count_valid_avx2 because it materialises a
Vec<Result> instead of just counting; use this when the
caller needs per-index error attribution.
§Safety
Caller must guarantee AVX2 is supported by the runtime CPU.
Sourcepub unsafe fn check_read_all_avx512(&self) -> Vec<Result<(), RaspError>>
pub unsafe fn check_read_all_avx512(&self) -> Vec<Result<(), RaspError>>
AVX-512F full validation that writes per-index results.
Processes 8 elements per iteration via ZMM loads and
mask-producing _mm512_cmpgt_epi64_mask. Bit-exact equivalent
of check_read_all_avx2 and check_read_all_scalar.
§Safety
Caller must guarantee AVX-512F is supported by the runtime CPU.