pub unsafe trait Flat:
FlatBase
+ FlatUnsized
+ FlatValidate { }
Expand description
Flat type.
If you want to implement this type for your custom type it’s recommended to use safe #[flat]
attribute macro instead.
§Safety
By implementing this trait by yourself you guarantee:
Self
has stable binary representation that will not change in future. (But the representation could be differ across different platforms. If you need stronger guarantees consider usingPortable
types.)Self
don’t own any resources outside of it.Self
could be trivially copied as bytes. (We cannot requireSelf:
Copy
because it?Sized
.)- All methods of dependent traits have proper implementation and will not cause an UB.
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.