Skip to main content

VarZeroLengthlessSlice

Struct VarZeroLengthlessSlice 

Source
#[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>

Source

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

Source

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()

Source

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.

Source

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.

Source

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.

Source

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().

Source

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
  • len is the length associated with this VarZeroLengthlessSlice
  • 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>

Source§

fn eq(&self, other: &VarZeroLengthlessSlice<T, F>) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<T: Eq + ?Sized, F: Eq> Eq for VarZeroLengthlessSlice<T, F>

Source§

impl<T: ?Sized, F> StructuralPartialEq for VarZeroLengthlessSlice<T, F>

Auto Trait Implementations§

§

impl<T, F> Freeze for VarZeroLengthlessSlice<T, F>
where T: ?Sized,

§

impl<T, F> RefUnwindSafe for VarZeroLengthlessSlice<T, F>

§

impl<T, F> Send for VarZeroLengthlessSlice<T, F>
where F: Send, T: Send + ?Sized,

§

impl<T, F> !Sized for VarZeroLengthlessSlice<T, F>

§

impl<T, F> Sync for VarZeroLengthlessSlice<T, F>
where F: Sync, T: Sync + ?Sized,

§

impl<T, F> Unpin for VarZeroLengthlessSlice<T, F>
where F: Unpin, T: Unpin + ?Sized,

§

impl<T, F> UnsafeUnpin for VarZeroLengthlessSlice<T, F>
where T: ?Sized,

§

impl<T, F> UnwindSafe for VarZeroLengthlessSlice<T, F>
where F: UnwindSafe, T: UnwindSafe + ?Sized,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more