Trait riscv_pac::HartIdNumber
source · pub unsafe trait HartIdNumber: Copy {
const MAX_HART_ID_NUMBER: u16;
// Required methods
fn number(self) -> u16;
fn from_number(value: u16) -> Result<Self, u16>;
}
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 u16
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: u16
const MAX_HART_ID_NUMBER: u16
Highest number assigned to a context.
Required Methods§
sourcefn from_number(value: u16) -> Result<Self, u16>
fn from_number(value: u16) -> Result<Self, u16>
Tries to convert a number to a valid HART ID. If the conversion fails, it returns an error with the number back.
Object Safety§
This trait is not object safe.