#[repr(transparent)]pub(crate) struct VarZeroLengthlessSlice<T: ?Sized, F> {
marker: PhantomData<(F, T)>,
entire_slice: [u8],
}Expand description
A slice representing the index and data tables of a VarZeroVec,
without any length fields. The length field is expected to be stored elsewhere.
Without knowing the length this is of course unsafe to use directly.
Fields§
§marker: PhantomData<(F, T)>§entire_slice: [u8]The original slice this was constructed from
Implementations§
Source§impl<T: VarULE + ?Sized, F: VarZeroVecFormat> VarZeroLengthlessSlice<T, F>
impl<T: VarULE + ?Sized, F: VarZeroVecFormat> VarZeroLengthlessSlice<T, F>
Sourcepub(crate) unsafe fn as_components<'a>(
&'a self,
len: u32,
) -> VarZeroVecComponents<'a, T, F>
pub(crate) unsafe fn as_components<'a>( &'a self, len: u32, ) -> VarZeroVecComponents<'a, T, F>
Obtain a VarZeroVecComponents borrowing from the internal buffer
Safety: len must be the length associated with this value
Sourcepub fn parse_bytes<'a>(len: u32, slice: &'a [u8]) -> Result<&'a Self, UleError>
pub fn parse_bytes<'a>(len: u32, slice: &'a [u8]) -> Result<&'a Self, UleError>
Parse a VarZeroLengthlessSlice from a slice of the appropriate format
Slices of the right format can be obtained via VarZeroSlice::as_bytes()
Sourcepub(crate) const unsafe fn from_bytes_unchecked(bytes: &[u8]) -> &Self
pub(crate) const unsafe fn from_bytes_unchecked(bytes: &[u8]) -> &Self
Uses a &[u8] buffer as a VarZeroLengthlessSlice<T> without any verification.
§Safety
bytes need to be an output from VarZeroLengthlessSlice::as_bytes(), or alternatively
successfully pass through parse_bytes (with len)
The length associated with this value will be the length associated with the original slice.
Sourcepub(crate) unsafe fn from_bytes_unchecked_mut(bytes: &mut [u8]) -> &mut Self
pub(crate) unsafe fn from_bytes_unchecked_mut(bytes: &mut [u8]) -> &mut Self
Uses a &mut [u8] buffer as a VarZeroLengthlessSlice<T> without any verification.
§Safety
bytes need to be an output from VarZeroLengthlessSlice::as_bytes(), or alternatively
be valid to be passed to from_bytes_unchecked_with_length
The length associated with this value will be the length associated with the original slice.
Sourcepub(crate) unsafe fn get_unchecked(&self, len: u32, idx: usize) -> &T
pub(crate) unsafe fn get_unchecked(&self, len: u32, idx: usize) -> &T
Get one of this slice’s elements
§Safety
index must be in range, and len must be the length associated with this
instance of VarZeroLengthlessSlice.
Sourcepub(crate) const fn as_bytes(&self) -> &[u8] ⓘ
pub(crate) const fn as_bytes(&self) -> &[u8] ⓘ
Get a reference to the entire encoded backing buffer of this slice
The bytes can be passed back to Self::parse_bytes().
To take the bytes as a vector, see VarZeroVec::into_bytes().
Sourcepub(crate) unsafe fn get_bytes_at_mut(
&mut self,
len: u32,
idx: usize,
) -> &mut [u8] ⓘ
pub(crate) unsafe fn get_bytes_at_mut( &mut self, len: u32, idx: usize, ) -> &mut [u8] ⓘ
Get the bytes behind this as a mutable slice
§Safety
lenis the length associated with thisVarZeroLengthlessSlice- The resultant slice is only mutated in a way such that it remains a valid
T
§Panics
Panics when idx is not in bounds for this slice
Trait Implementations§
Source§impl<T: PartialEq + ?Sized, F: PartialEq> PartialEq for VarZeroLengthlessSlice<T, F>
impl<T: PartialEq + ?Sized, F: PartialEq> PartialEq for VarZeroLengthlessSlice<T, F>
Source§fn eq(&self, other: &VarZeroLengthlessSlice<T, F>) -> bool
fn eq(&self, other: &VarZeroLengthlessSlice<T, F>) -> bool
self and other values to be equal, and is used by ==.