pub struct FamStructWrapper<T: Default + FamStruct> { /* private fields */ }
Expand description
Implementations§
Source§impl<T: Default + FamStruct> FamStructWrapper<T>
impl<T: Default + FamStruct> FamStructWrapper<T>
Sourcepub fn new(num_elements: usize) -> Result<FamStructWrapper<T>, Error>
pub fn new(num_elements: usize) -> Result<FamStructWrapper<T>, Error>
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
.
Sourcepub fn from_entries(entries: &[T::Entry]) -> Result<FamStructWrapper<T>, Error>
pub fn from_entries(entries: &[T::Entry]) -> Result<FamStructWrapper<T>, Error>
Create a new FamStructWrapper from a slice of elements.
§Arguments
entries
- The slice ofFamStruct::Entry
entries.
§Errors
When the size of entries
is greater than the max possible len, it returns
Error::SizeLimitExceeded
.
Sourcepub unsafe fn from_raw(content: Vec<T>) -> Self
pub unsafe fn from_raw(content: Vec<T>) -> Self
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 asVec[T]
.
§Safety
This function is unsafe because the caller needs to ensure that the raw content is correctly layed out.
Sourcepub fn into_raw(self) -> Vec<T>
pub fn into_raw(self) -> Vec<T>
Consume the FamStructWrapper and return the raw content as Vec<T>
.
Sourcepub fn as_fam_struct_ref(&self) -> &T
pub fn as_fam_struct_ref(&self) -> &T
Get a reference to the actual FamStruct
instance.
Sourcepub fn as_mut_fam_struct(&mut self) -> &mut T
pub fn as_mut_fam_struct(&mut self) -> &mut T
Get a mut reference to the actual FamStruct
instance.
Sourcepub fn as_fam_struct_ptr(&self) -> *const T
pub fn as_fam_struct_ptr(&self) -> *const T
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.
Sourcepub fn as_mut_fam_struct_ptr(&mut self) -> *mut T
pub fn as_mut_fam_struct_ptr(&mut self) -> *mut T
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.
Sourcepub fn as_mut_slice(&mut self) -> &mut [T::Entry]
pub fn as_mut_slice(&mut self) -> &mut [T::Entry]
Get the mutable elements slice.