pub unsafe trait PaddingBane {
type Fields: Copy;
// Required methods
fn get_fields(&self) -> Self::Fields;
unsafe fn init_padding(fields: Self::Fields, bytes: &mut [MaybeUninit<u8>]);
}
Expand description
This trait must be implemented in order to fill padding bytes of an object.
Required Associated Types§
Required Methods§
Sourcefn get_fields(&self) -> Self::Fields
fn get_fields(&self) -> Self::Fields
Return fields metadata.
§Safety
This function must return equal value for any instance of the Self
type.
It exists only because reference to instance is required to
fetch field offsets.
Sourceunsafe fn init_padding(fields: Self::Fields, bytes: &mut [MaybeUninit<u8>])
unsafe fn init_padding(fields: Self::Fields, bytes: &mut [MaybeUninit<u8>])
Fills padding bytes in the bytes array. Padding bytes are bytes where no fields of the struct are stored or padding bytes of the fields.
§Safety
fields
must be created from any instance of Self
.
bytes
must be created by casting &mut Self
or, for a field,
it must be subslice of the parent’s bytes where field is stored.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.