pub struct MemoryLayout {
pub type_name: String,
pub size: usize,
pub align: usize,
}Expand description
A memory layout descriptor for a Rust/C type.
Tracks size, alignment, and stride (size rounded up to alignment).
Fields§
§type_name: StringName of the type.
size: usizeSize of the type in bytes.
align: usizeAlignment of the type in bytes.
Implementations§
Source§impl MemoryLayout
impl MemoryLayout
Sourcepub fn new(type_name: impl Into<String>, size: usize, align: usize) -> Self
pub fn new(type_name: impl Into<String>, size: usize, align: usize) -> Self
Create a new MemoryLayout.
Sourcepub fn is_valid(&self) -> bool
pub fn is_valid(&self) -> bool
Check whether this layout is valid (align is a power of two, size ≤ stride).
Sourcepub fn align_offset(&self, offset: usize) -> usize
pub fn align_offset(&self, offset: usize) -> usize
Compute the offset needed to align offset to this type’s alignment.
Auto Trait Implementations§
impl Freeze for MemoryLayout
impl RefUnwindSafe for MemoryLayout
impl Send for MemoryLayout
impl Sync for MemoryLayout
impl Unpin for MemoryLayout
impl UnsafeUnpin for MemoryLayout
impl UnwindSafe for MemoryLayout
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more