Module safe_transmute::trivial
source · Expand description
Transmutation of trivial objects
Functions in this module are guarded from out-of-bounds memory access and
from unsafe transmutation target types through the use of the
TriviallyTransmutable
) trait.
If a certain type can be safely constructed out of any byte combination,
then it may implement this trait. This is the case for primitive integer
types (e.g. i32
, u32
, i64
), arrays of other trivially transmutable
types, and repr(C)
structs composed of trivially transmutable values.
However, they are still not entirely safe because the source data may not be correctly aligned for reading and writing a value of the target type. The effects of this range from less performance (e.g. x86) to trapping or address flooring (e.g. ARM), but this is undefined behavior nonetheless.
Traits§
- Type that can be constructed from any combination of bytes.
Functions§
- Transmute the slice to a slice of another type, ensuring alignment of the types is maintained.
- Transmute the slice to a slice of another type, ensuring alignment of the types is maintained.
- guarded_transmute_pod_many_pedantic⚠DeprecatedView a byte slice as a slice of a trivially transmutable type.
- guarded_transmute_pod_many_permissive⚠DeprecatedView a byte slice as a slice of a trivially transmutable type.
- Transmute a byte slice into a single instance of a trivially transmutable type.
- Transmute a byte slice into a single instance of a trivially transmutable type.
- Transmute a byte slice into a single instance of a trivially transmutable type.
- Transmute a byte slice into a single instance of a trivially transmutable type.
- Transform a vector into a vector of another element type.