pub struct CStructLayout {
pub name: String,
pub fields: Vec<(String, usize, usize)>,
}Expand description
A C-ABI struct layout: a list of fields with names, sizes, and alignments.
Fields§
§name: StringName of the struct.
fields: Vec<(String, usize, usize)>Fields: (name, size, alignment).
Implementations§
Source§impl CStructLayout
impl CStructLayout
Sourcepub fn add_field(
self,
name: impl Into<String>,
size: usize,
align: usize,
) -> Self
pub fn add_field( self, name: impl Into<String>, size: usize, align: usize, ) -> Self
Add a field with the given name, size, and alignment.
Sourcepub fn field_offset(&self, idx: usize) -> usize
pub fn field_offset(&self, idx: usize) -> usize
Compute the byte offset of the n-th field following C ABI rules.
Sourcepub fn total_size(&self) -> usize
pub fn total_size(&self) -> usize
Total size of the struct including trailing padding.
Auto Trait Implementations§
impl Freeze for CStructLayout
impl RefUnwindSafe for CStructLayout
impl Send for CStructLayout
impl Sync for CStructLayout
impl Unpin for CStructLayout
impl UnsafeUnpin for CStructLayout
impl UnwindSafe for CStructLayout
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