riscv_pac

Trait ExceptionNumber

source
pub unsafe trait ExceptionNumber: Copy {
    const MAX_EXCEPTION_NUMBER: usize;

    // Required methods
    fn number(self) -> usize;
    fn from_number(value: usize) -> Result<Self>;
}
Expand description

Trait for enums of target-specific exception numbers.

This trait should be implemented by a peripheral access crate (PAC) on its enum of available exceptions for a specific device. Alternatively, the riscv crate provides a default implementation for the RISC-V ISA. Each variant must convert to a usize of its exception number.

§Safety

  • This trait must only be implemented on the riscv crate or on a PAC of a RISC-V target.
  • This trait must only be implemented on enums of exceptions.
  • Each enum variant must represent a distinct value (no duplicates are permitted),
  • Each enum variant must always return the same value (do not change at runtime).
  • All the exception numbers must be less than or equal to MAX_EXCEPTION_NUMBER.
  • MAX_EXCEPTION_NUMBER must coincide with the highest allowed exception number.

Required Associated Constants§

source

const MAX_EXCEPTION_NUMBER: usize

Highest number assigned to an exception.

Required Methods§

source

fn number(self) -> usize

Converts an exception to its corresponding number.

source

fn from_number(value: usize) -> Result<Self>

Tries to convert a number to a valid exception.

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.

Implementors§