Trait data_model::flexible_array::FlexibleArray
source · pub trait FlexibleArray<S> {
// Required methods
fn set_len(&mut self, len: usize);
fn get_len(&self) -> usize;
unsafe fn get_slice(&self, len: usize) -> &[S];
unsafe fn get_mut_slice(&mut self, len: usize) -> &mut [S];
}Expand description
A collection of methods that are required by the FlexibleArrayWrapper type.
When implemented for T, this trait allows the caller to set number of S entries and
retrieve a slice of S entries. Trait methods must only be called by the FlexibleArrayWrapper
type. Don’t implement this trait directly, use the flexible_array! macro to avoid duplication.
Required Methods§
sourcefn set_len(&mut self, len: usize)
fn set_len(&mut self, len: usize)
Implementations must set flexible array length in the flexible array struct to the value
specified by len. Appropriate conversions (i.e, usize to u32) are allowed so long as
they don’t overflow or underflow.
sourcefn get_len(&self) -> usize
fn get_len(&self) -> usize
Implementations must return the length of the flexible array member. Appropriate conversions (i.e, usize to u32) are allowed so long as they don’t overflow or underflow.
sourceunsafe fn get_slice(&self, len: usize) -> &[S]
unsafe fn get_slice(&self, len: usize) -> &[S]
Implementations must return a slice of flexible array member of length len.
§Safety
Do not use this function directly, as the FlexibleArrayWrapper will guarantee safety.
sourceunsafe fn get_mut_slice(&mut self, len: usize) -> &mut [S]
unsafe fn get_mut_slice(&mut self, len: usize) -> &mut [S]
Implementations must return a mutable slice of flexible array member of length len.
§Safety
Do not use this function directly, as the FlexibleArrayWrapper will guarantee safety.