pub unsafe trait PlainData: Sized { }Expand description
Marker trait for plain data: a type for which every bit pattern of
size_of::<Self>() bytes is a valid value.
§Safety
A type may implement PlainData only when every bit pattern of its size is
a valid value of the type. In particular, a PlainData type must not
contain bool, char, enum, reference or pointer fields, and code must not
read padding bytes of a PlainData structure as values.
A PlainData type must also have harmless drop glue: writing a payload over
an existing one (*output = ..) drops the bytes the guest supplied, so a
type with a Drop implementation (for example a password buffer that
zeroises itself on drop, like WifiPassword) must not implement
PlainData.
The integer and float primitives, () and arrays of plain data implement
PlainData. Use plain_data! for #[repr(C)]
structures: it implements PlainData only when every field type is itself
plain data and the structure has no padding, which it checks at compile
time.
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.