Struct zerovec::ule::MultiFieldsULE
source · #[repr(transparent)]pub struct MultiFieldsULE(VarZeroSlice<[u8], Index32>);
Expand description
This type is used by the custom derive to represent multiple VarULE
fields packed into a single end-of-struct field. It is not recommended
to use this type directly.
Logically, consider it to be (V1, V2, V3, ..)
where V1
etc are potentially different VarULE
types.
Internally, it is represented by a VarZeroSlice.
Tuple Fields§
§0: VarZeroSlice<[u8], Index32>
Implementations§
source§impl MultiFieldsULE
impl MultiFieldsULE
sourcepub fn compute_encoded_len_for(lengths: &[usize]) -> usize
pub fn compute_encoded_len_for(lengths: &[usize]) -> usize
Compute the amount of bytes needed to support elements with lengths lengths
sourcepub fn new_from_lengths_partially_initialized<'a>(
lengths: &[usize],
output: &'a mut [u8],
) -> &'a mut Self
pub fn new_from_lengths_partially_initialized<'a>( lengths: &[usize], output: &'a mut [u8], ) -> &'a mut Self
Construct a partially initialized MultiFieldsULE backed by a mutable byte buffer
sourcepub unsafe fn set_field_at<T: VarULE + ?Sized, A: EncodeAsVarULE<T> + ?Sized>(
&mut self,
idx: usize,
value: &A,
)
pub unsafe fn set_field_at<T: VarULE + ?Sized, A: EncodeAsVarULE<T> + ?Sized>( &mut self, idx: usize, value: &A, )
Given a buffer of size obtained by Self::compute_encoded_len_for()
, write element A to index idx
§Safety
idx
must be in rangeT
must be the appropriate type expected by the custom derive in this usage of this type
sourcepub unsafe fn validate_field<T: VarULE + ?Sized>(
&self,
index: usize,
) -> Result<(), ZeroVecError>
pub unsafe fn validate_field<T: VarULE + ?Sized>( &self, index: usize, ) -> Result<(), ZeroVecError>
sourcepub unsafe fn get_field<T: VarULE + ?Sized>(&self, index: usize) -> &T
pub unsafe fn get_field<T: VarULE + ?Sized>(&self, index: usize) -> &T
Get field at index
as a value of type T
§Safety
index
must be in range- Element at
index
must have been created with the VarULE type T
sourcepub unsafe fn from_byte_slice_unchecked(bytes: &[u8]) -> &Self
pub unsafe fn from_byte_slice_unchecked(bytes: &[u8]) -> &Self
Trait Implementations§
source§impl Debug for MultiFieldsULE
impl Debug for MultiFieldsULE
source§impl PartialEq for MultiFieldsULE
impl PartialEq for MultiFieldsULE
source§impl VarULE for MultiFieldsULE
impl VarULE for MultiFieldsULE
source§fn validate_byte_slice(slice: &[u8]) -> Result<(), ZeroVecError>
fn validate_byte_slice(slice: &[u8]) -> Result<(), ZeroVecError>
Note: MultiFieldsULE is usually used in cases where one should be calling .validate_field() directly for each field, rather than using the regular VarULE impl.
This impl exists so that EncodeAsVarULE can work.
source§unsafe fn from_byte_slice_unchecked(bytes: &[u8]) -> &Self
unsafe fn from_byte_slice_unchecked(bytes: &[u8]) -> &Self
&[u8]
, and return it as &Self
with the same lifetime, assuming
that this byte slice has previously been run through Self::parse_byte_slice()
with
success. Read moresource§fn parse_byte_slice(bytes: &[u8]) -> Result<&Self, ZeroVecError>
fn parse_byte_slice(bytes: &[u8]) -> Result<&Self, ZeroVecError>
source§fn as_byte_slice(&self) -> &[u8] ⓘ
fn as_byte_slice(&self) -> &[u8] ⓘ
impl Eq for MultiFieldsULE
impl StructuralPartialEq for MultiFieldsULE
Auto Trait Implementations§
impl Freeze for MultiFieldsULE
impl RefUnwindSafe for MultiFieldsULE
impl Send for MultiFieldsULE
impl !Sized for MultiFieldsULE
impl Sync for MultiFieldsULE
impl Unpin for MultiFieldsULE
impl UnwindSafe for MultiFieldsULE
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> EncodeAsVarULE<T> for T
impl<T> EncodeAsVarULE<T> for T
source§fn encode_var_ule_as_slices<R>(&self, cb: impl FnOnce(&[&[u8]]) -> R) -> R
fn encode_var_ule_as_slices<R>(&self, cb: impl FnOnce(&[&[u8]]) -> R) -> R
cb
with a piecewise list of byte slices that when concatenated
produce the memory pattern of the corresponding instance of T
. Read moresource§fn encode_var_ule_len(&self) -> usize
fn encode_var_ule_len(&self) -> usize
VarULE
typesource§fn encode_var_ule_write(&self, dst: &mut [u8])
fn encode_var_ule_write(&self, dst: &mut [u8])
VarULE
type to the dst
buffer. dst
should
be the size of Self::encode_var_ule_len()