pub unsafe trait ImmutableFromIntoBytes: Sealed { }Expand description
A type that is can be safely converted to an initialized sequence of bytes, from an arbitrary initialized sequence of bytes, and does not feature interior mutability.
The requirements on implementors of this trait are effectively the same
as the combination of zerocopy’s FromBytes,
IntoBytes, and Immutable
traits.
This trait is only implemented for a few select primitives, intended to be used for DMA operations. It is sealed; all extensions to future types must ensure they conform to the above trait’s requirements and are safe for DMA operations.
§Safety
Types that implement ImmutableFromIntoBytes must:
- no_uninit: Not contain any uninitialized bytes (such as padding)
- no_interior_mut: Not have any interior mutability
- any_init_pattern: Be valid for all initialized byte patterns of the correct length and alignment.
These guarantees effectively allow &mut [T] references to be converted
into &mut [u8] references, mutated, and then converted back into &mut [T] references.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".