[][src]Struct vmm_sys_util::fam::FamStructWrapper

pub struct FamStructWrapper<T: Default + FamStruct> { /* fields omitted */ }

A wrapper for FamStruct.

It helps in treating a FamStruct similarly to an actual Vec.

Methods

impl<T: Default + FamStruct> FamStructWrapper<T>[src]

pub fn new(num_elements: usize) -> FamStructWrapper<T>[src]

Create a new FamStructWrapper with num_elements elements.

The elements will be zero-initialized. The type of the elements will be FamStruct::Entry.

Arguments

  • num_elements - The number of elements in the FamStructWrapper.

pub fn from_entries(entries: &[T::Entry]) -> FamStructWrapper<T>[src]

Create a new FamStructWrapper from a slice of elements.

Arguments

pub unsafe fn from_raw(content: Vec<T>) -> Self[src]

Create a new FamStructWrapper from the raw content represented as Vec<T>.

Sometimes we already have the raw content of an FAM struct represented as Vec<T>, and want to use the FamStructWrapper as accessors.

This function is unsafe because the caller needs to ensure that the raw content is correctly layed out.

Arguments

  • content - The raw content represented as Vec[T].

pub fn into_raw(self) -> Vec<T>[src]

Consume the FamStructWrapper and return the raw content as Vec<T>.

pub fn as_fam_struct_ref(&self) -> &T[src]

Get a reference to the actual FamStruct instance.

pub fn as_mut_fam_struct(&mut self) -> &mut T[src]

Get a mut reference to the actual FamStruct instance.

pub fn as_fam_struct_ptr(&self) -> *const T[src]

Get a pointer to the FamStruct instance.

The caller must ensure that the fam_struct outlives the pointer this function returns, or else it will end up pointing to garbage.

Modifying the container referenced by this pointer may cause its buffer to be reallocated, which would also make any pointers to it invalid.

pub fn as_mut_fam_struct_ptr(&mut self) -> *mut T[src]

Get a mutable pointer to the FamStruct instance.

The caller must ensure that the fam_struct outlives the pointer this function returns, or else it will end up pointing to garbage.

Modifying the container referenced by this pointer may cause its buffer to be reallocated, which would also make any pointers to it invalid.

pub fn as_slice(&self) -> &[T::Entry][src]

Get the elements slice.

pub fn as_mut_slice(&mut self) -> &mut [T::Entry][src]

Get the mutable elements slice.

pub fn push(&mut self, entry: T::Entry) -> Result<(), Error>[src]

Append an element.

Arguments

  • entry - The element that will be appended to the end of the collection.

Errors

When len is already equal to max possible len it returns Error::SizeLimitExceeded.

pub fn retain<P>(&mut self, f: P) where
    P: FnMut(&T::Entry) -> bool
[src]

Retain only the elements specified by the predicate.

Arguments

  • f - The function used to evaluate whether an entry will be kept or not. When f returns true the entry is kept.

Trait Implementations

impl<T: Default + FamStruct + Clone> From<Vec<T>> for FamStructWrapper<T>[src]

impl<T: Default + FamStruct + Clone> Clone for FamStructWrapper<T>[src]

impl<T: Default + FamStruct> PartialEq<FamStructWrapper<T>> for FamStructWrapper<T>[src]

Auto Trait Implementations

impl<T> Send for FamStructWrapper<T> where
    T: Send

impl<T> Sync for FamStructWrapper<T> where
    T: Sync

impl<T> Unpin for FamStructWrapper<T> where
    T: Unpin

impl<T> UnwindSafe for FamStructWrapper<T> where
    T: UnwindSafe

impl<T> RefUnwindSafe for FamStructWrapper<T> where
    T: RefUnwindSafe

Blanket Implementations

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> From<T> for T[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> Any for T where
    T: 'static + ?Sized
[src]