Struct zerovec::ule::MultiFieldsULE
source · [−]#[repr(transparent)]pub struct MultiFieldsULE(_);
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.
Implementations
sourceimpl 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>
Trait Implementations
sourceimpl PartialEq<MultiFieldsULE> for MultiFieldsULE
impl PartialEq<MultiFieldsULE> for MultiFieldsULE
sourcefn eq(&self, other: &MultiFieldsULE) -> bool
fn eq(&self, other: &MultiFieldsULE) -> bool
This method tests for self
and other
values to be equal, and is used
by ==
. Read more
sourcefn ne(&self, other: &MultiFieldsULE) -> bool
fn ne(&self, other: &MultiFieldsULE) -> bool
This method tests for !=
.
sourceimpl VarULE for MultiFieldsULE
impl VarULE for MultiFieldsULE
sourcefn 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.
sourceunsafe fn from_byte_slice_unchecked(bytes: &[u8]) -> &Self
unsafe fn from_byte_slice_unchecked(bytes: &[u8]) -> &Self
Takes a byte slice, &[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 more
sourcefn parse_byte_slice(bytes: &[u8]) -> Result<&Self, ZeroVecError>
fn parse_byte_slice(bytes: &[u8]) -> Result<&Self, ZeroVecError>
Parses a byte slice, &[u8]
, and return it as &Self
with the same lifetime. Read more
sourcefn as_byte_slice(&self) -> &[u8]ⓘNotable traits for &'_ [u8]impl<'_> Read for &'_ [u8]impl<'_> Write for &'_ mut [u8]
fn as_byte_slice(&self) -> &[u8]ⓘNotable traits for &'_ [u8]impl<'_> Read for &'_ [u8]impl<'_> Write for &'_ mut [u8]
Given &Self
, returns a &[u8]
with the same lifetime. Read more
sourcefn to_boxed(&self) -> Box<Self>ⓘNotable traits for Box<R, Global>impl<R> Read for Box<R, Global> where
R: Read + ?Sized, impl<W> Write for Box<W, Global> where
W: Write + ?Sized, impl<I, A> Iterator for Box<I, A> where
I: Iterator + ?Sized,
A: Allocator, type Item = <I as Iterator>::Item;impl<F, A> Future for Box<F, A> where
F: Future + Unpin + ?Sized,
A: Allocator + 'static, type Output = <F as Future>::Output;
fn to_boxed(&self) -> Box<Self>ⓘNotable traits for Box<R, Global>impl<R> Read for Box<R, Global> where
R: Read + ?Sized, impl<W> Write for Box<W, Global> where
W: Write + ?Sized, impl<I, A> Iterator for Box<I, A> where
I: Iterator + ?Sized,
A: Allocator, type Item = <I as Iterator>::Item;impl<F, A> Future for Box<F, A> where
F: Future + Unpin + ?Sized,
A: Allocator + 'static, type Output = <F as Future>::Output;
R: Read + ?Sized, impl<W> Write for Box<W, Global> where
W: Write + ?Sized, impl<I, A> Iterator for Box<I, A> where
I: Iterator + ?Sized,
A: Allocator, type Item = <I as Iterator>::Item;impl<F, A> Future for Box<F, A> where
F: Future + Unpin + ?Sized,
A: Allocator + 'static, type Output = <F as Future>::Output;
Allocate on the heap as a Box<T>