devela::sys::mem

Trait MemAligned

Source
pub trait MemAligned: Sealed {
    // Required methods
    fn is_compatible() -> bool;
    fn assert_compatibility();
}
Expand description

Marker trait to verify memory alignment between two types.

This trait ensures that a value of the Candidate type can be safely placed into a storage medium designed for the Requirement type, adhering to alignment requirements.

Required Methods§

Source

fn is_compatible() -> bool

Checks if the Candidate’s alignment is compatible with the Requirement’s alignment.

Returns true if Candidate type’s alignment is less than or equal to the Requirement type’s alignment.

Alignment represents the byte boundary to which a type must be aligned in memory. It is crucial to ensure that types are placed in memory locations that respect their alignment requirements.

Source

fn assert_compatibility()

Asserts that the memory alignment of the Candidate type meets or exceeds the Requirement type’s alignment.

§Panics

Panics if the Candidate type’s alignment is greater than the Requirement type’s alignment, indicating an incompatibility that could lead to undefined behavior or performance penalties.

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.

Implementations on Foreign Types§

Source§

impl<Candidate, Requirement> MemAligned for (Candidate, Requirement)

Implementors§