pub struct FlexibleArrayWrapper<T, S> {
    entries: Vec<T>,
    phantom: PhantomData<S>,
    allocated_len: usize,
}

Fields§

§entries: Vec<T>§phantom: PhantomData<S>§allocated_len: usize

Implementations§

source§

impl<T, S> FlexibleArrayWrapper<T, S>where T: FlexibleArray<S> + Default,

Convenience wrapper for flexible array structs.

The FlexibleArray trait must be implemented for the flexible array struct before using this wrapper.

source

pub fn new(array_len: usize) -> FlexibleArrayWrapper<T, S>

Creates a new FlexibleArrayWrapper for the given flexible array struct type and flexible array type. The flexible array length is set to array_len. vec_with_array_field is used to make sure the resultant wrapper is appropriately sized.

source

fn get_valid_len(&self) -> usize

Mapping the unsized array to a slice is unsafe because the length isn’t known. Using the length we originally allocated with eliminates the possibility of overflow.

source

pub fn entries_slice(&self) -> &[S]

Returns a slice of the flexible array member, for inspecting. To modify, use mut_entries_slice instead.

source

pub fn mut_entries_slice(&mut self) -> &mut [S]

Returns a mutable slice of the flexible array member, for modifying.

source

pub fn as_ptr(&self) -> *const T

Get a pointer so it can be passed to the kernel. Callers must not access the flexible array member. Using this pointer is unsafe.

source

pub fn as_mut_ptr(&mut self) -> *mut T

Get a mutable pointer so it can be passed to the kernel. Callers must not access the flexible array member. Using this pointer is unsafe.

Auto Trait Implementations§

§

impl<T, S> RefUnwindSafe for FlexibleArrayWrapper<T, S>where S: RefUnwindSafe, T: RefUnwindSafe,

§

impl<T, S> Send for FlexibleArrayWrapper<T, S>where S: Send, T: Send,

§

impl<T, S> Sync for FlexibleArrayWrapper<T, S>where S: Sync, T: Sync,

§

impl<T, S> Unpin for FlexibleArrayWrapper<T, S>where S: Unpin, T: Unpin,

§

impl<T, S> UnwindSafe for FlexibleArrayWrapper<T, S>where S: UnwindSafe, T: UnwindSafe,

Blanket Implementations§

source§

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

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

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

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

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

source§

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

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for Twhere U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T, U> TryFrom<U> for Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.