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

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

A wrapper for FamStruct.

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

Implementations

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.

Errors

When num_elements is greater than the max possible len, it returns Error::SizeLimitExceeded.

Create a new FamStructWrapper from a slice of elements.

Arguments

Errors

When the size of entries is greater than the max possible len, it returns Error::SizeLimitExceeded.

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.

Arguments

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

Safety

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

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

Get a reference to the actual FamStruct instance.

Get a mut reference to the actual FamStruct instance.

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.

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.

Get the elements slice.

Get the mutable elements slice.

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.

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

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Performs the conversion.

This method tests for self and other values to be equal, and is used by ==. Read more

This method tests for !=.

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Performs the conversion.

Performs the conversion.

The resulting type after obtaining ownership.

Creates owned data from borrowed data, usually by cloning. Read more

🔬 This is a nightly-only experimental API. (toowned_clone_into)

recently added

Uses borrowed data to replace owned data, usually by cloning. Read more

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.