Function presser::read_slice_at_offset
source · pub unsafe fn read_slice_at_offset<'a, T, S: Slab + ?Sized>(
slab: &'a S,
offset: usize,
len: usize
) -> Result<&'a [T], Error>
Expand description
Reads a &[T]
within slab
at offset
.
offset
is the offset, in bytes, after the start ofslab
at which a[T; len]
is placed.len
is the length of the returned slice, counted in elements ofT
.
The function will return an error if:
offset
withinslab
is not properly aligned forT
offset
is out of bounds of theslab
offset + size_of::<T> * len
is out of bounds of theslab
Safety
You must have previously fully-initialized a valid* a [T; len]
at the given offset into slab
.
* Validity is a complex topic not to be taken lightly. See this rust reference page for more details.