pub struct AnyByLayout(/* private fields */);Implementations§
Source§impl AnyByLayout
impl AnyByLayout
pub const NONE: &mut Self
Sourcepub unsafe fn from_raw_parts<'a>(data: *mut u8, size: usize) -> &'a mut Self
pub unsafe fn from_raw_parts<'a>(data: *mut u8, size: usize) -> &'a mut Self
Creates an AnyByLayout from raw parts.
§Safety
This function is unsafe because it creates a reference from a raw pointer.
The caller must ensure that the pointer is valid for reads and writes
for size bytes and properly aligned.
Sourcepub const fn from_mutable<T: PlainData>(argument: &mut T) -> &mut Self
pub const fn from_mutable<T: PlainData>(argument: &mut T) -> &mut Self
Views a plain-data value as raw bytes.
T must be PlainData, so the bytes can always be read back as a
valid T (for example through AnyByLayout::cast); with a bool or
enum T, safe code could write an invalid value such as 2 for a
bool through AnyByLayout::as_mutable_bytes.
Sourcepub fn from<T: PlainData>(argument: &T) -> &Self
pub fn from<T: PlainData>(argument: &T) -> &Self
Views a plain-data value as raw bytes; see AnyByLayout::from_mutable
for the T: PlainData requirement.
Sourcepub fn cast_mutable<T: PlainData>(&mut self) -> Option<&mut T>
pub fn cast_mutable<T: PlainData>(&mut self) -> Option<&mut T>
Returns the payload as a T only when it is an exact fit: the payload
length equals size_of::<T>() and its address is aligned for T.
T must be PlainData, so every payload byte pattern is a valid T;
a bool or enum payload can never hold an invalid value this way.
Sourcepub fn cast<T: PlainData>(&self) -> Option<&T>
pub fn cast<T: PlainData>(&self) -> Option<&T>
Returns the payload as a T only when it is an exact fit: the payload
length equals size_of::<T>() and its address is aligned for T.
T must be PlainData, so every payload byte pattern is a valid T;
a bool or enum payload can never hold an invalid value this way.
pub fn get_size(&self) -> usize
pub fn get_alignment(&self) -> usize
pub fn as_mutable_bytes(&mut self) -> &mut [u8] ⓘ
Trait Implementations§
Source§impl Debug for AnyByLayout
impl Debug for AnyByLayout
Source§impl PartialEq for AnyByLayout
impl PartialEq for AnyByLayout
Source§fn eq(&self, other: &AnyByLayout) -> bool
fn eq(&self, other: &AnyByLayout) -> bool
self and other values to be equal, and is used by ==.