pub struct AlignedVarLenOffsets<'a>(/* private fields */);Expand description
Slice of offsets to var-len members, in units of 2-byte words.
This type is intended as a demonstration of the VarLenMembers interface,
and is used in testing and benchmarking.
Note that this visitor is not suitable for sum types, or for types which contain sums.
Units of 2-byte words because VarLenRef is 2-byte aligned.
Note that VarLenRef is 4 bytes wide, but only 2-byte aligned.
The listed offsets must not overlap, i.e. there must be a gap of at least 2 between each offset.
For AlignedVarLenOffsets([n]), a 4-byte VarLenRef exists in each row at +2n bytes.
e.g.:
AlignedVarLenOffsets([0, 4])
has:
row >= 12 bytes,
- var-len ref at +0..4 bytes (i.e. +0..2
u16s). - fixed-len field(s) at +4..8 bytes (i.e. +2..4
u16s). - var-len ref at +8..12 bytes (i.e. +4..6
u16s). - fixed-len field(s) at +12.. (i.e. +6..
u16s), if row_size > 12.
Implementations§
Source§impl<'a> AlignedVarLenOffsets<'a>
impl<'a> AlignedVarLenOffsets<'a>
Sourcepub const fn from_offsets(offsets: &'a [u16]) -> Self
pub const fn from_offsets(offsets: &'a [u16]) -> Self
Returns an AlignedVarLenOffsets using offsets.
Trait Implementations§
Source§impl<'a> Clone for AlignedVarLenOffsets<'a>
impl<'a> Clone for AlignedVarLenOffsets<'a>
Source§fn clone(&self) -> AlignedVarLenOffsets<'a>
fn clone(&self) -> AlignedVarLenOffsets<'a>
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl VarLenMembers for AlignedVarLenOffsets<'_>
impl VarLenMembers for AlignedVarLenOffsets<'_>
Source§unsafe fn visit_var_len<'this, 'row>(
&'this self,
row: &'row Bytes,
) -> Self::Iter<'this, 'row>
unsafe fn visit_var_len<'this, 'row>( &'this self, row: &'row Bytes, ) -> Self::Iter<'this, 'row>
§Safety
row must be 2-byte aligned.
row must be an allocation of at least 2n + 2 bytes,
where n is the largest offset in self.
All callers of visit_var_len on a particular row
must visit the same set of VarLenRefs,
though they may do so through different implementors of VarLenMembers.
E.g. it would be valid to use an AlignedVarLenOffsets to initialize a row,
then later read from it using a hypothetical optimized JITted visitor,
provided the JITted visitor visited the same set of offsets.
Source§unsafe fn visit_var_len_mut<'this, 'row>(
&'this self,
row: &'row mut Bytes,
) -> Self::IterMut<'this, 'row>
unsafe fn visit_var_len_mut<'this, 'row>( &'this self, row: &'row mut Bytes, ) -> Self::IterMut<'this, 'row>
§Safety
row must be 2-byte aligned.
row must be an allocation of at least 2n + 2 bytes,
where n is the largest offset in self.
All callers of visit_var_len on a particular row
must visit the same set of VarLenRefs,
though they may do so through different implementors of VarLenMembers.
E.g. it would be valid to use an AlignedVarLenOffsets to initialize a row,
then later read from it using a hypothetical optimized JITted visitor,
provided the JITted visitor visited the same set of offsets.
Source§type Iter<'this, 'row> = AlignedVarLenOffsetsIter<'this, 'row>
where
Self: 'this
type Iter<'this, 'row> = AlignedVarLenOffsetsIter<'this, 'row> where Self: 'this
VarLenMembers::visit_var_len.Source§type IterMut<'this, 'row> = AlignedVarLenOffsetsIterMut<'this, 'row>
where
Self: 'this
type IterMut<'this, 'row> = AlignedVarLenOffsetsIterMut<'this, 'row> where Self: 'this
VarLenMembers::visit_var_len_mut.impl<'a> Copy for AlignedVarLenOffsets<'a>
Auto Trait Implementations§
impl<'a> Freeze for AlignedVarLenOffsets<'a>
impl<'a> RefUnwindSafe for AlignedVarLenOffsets<'a>
impl<'a> Send for AlignedVarLenOffsets<'a>
impl<'a> Sync for AlignedVarLenOffsets<'a>
impl<'a> Unpin for AlignedVarLenOffsets<'a>
impl<'a> UnwindSafe for AlignedVarLenOffsets<'a>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more