pub unsafe trait HartIdNumber: Copy {
const MAX_HART_ID_NUMBER: usize;
// Required methods
fn number(self) -> usize;
fn from_number(value: usize) -> Result<Self>;
}
Expand description
Trait for enums of HART identifiers.
This trait should be implemented by a peripheral access crate (PAC) on its enum of available
HARTs for a specific device. Each variant must convert to a usize
of its HART ID number.
§Safety
- This trait must only be implemented on a PAC of a RISC-V target.
- This trait must only be implemented on enums of HART IDs.
- Each enum variant must represent a distinct value (no duplicates are permitted),
- Each anum variant must always return the same value (do not change at runtime).
- All the HART ID numbers must be less than or equal to
MAX_HART_ID_NUMBER
. MAX_HART_ID_NUMBER
must coincide with the highest allowed HART ID number.
Required Associated Constants§
sourceconst MAX_HART_ID_NUMBER: usize
const MAX_HART_ID_NUMBER: usize
Highest number assigned to a context.
Required Methods§
sourcefn from_number(value: usize) -> Result<Self>
fn from_number(value: usize) -> Result<Self>
Tries to convert a number to a valid HART ID.
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.