riscv

Trait InterruptNumber

source
pub unsafe trait InterruptNumber: Copy {
    const MAX_INTERRUPT_NUMBER: usize;

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

Trait for enums of target-specific interrupt numbers.

This trait should be implemented by a peripheral access crate (PAC) on its enum of available interrupts 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 interrupt 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 interrupts.
  • 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 interrupt numbers must be less than or equal to MAX_INTERRUPT_NUMBER.
  • MAX_INTERRUPT_NUMBER must coincide with the highest allowed interrupt number.

Required Associated Constants§

source

const MAX_INTERRUPT_NUMBER: usize

Highest number assigned to an interrupt source.

Required Methods§

source

fn number(self) -> usize

Converts an interrupt source to its corresponding number.

source

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

Tries to convert a number to a valid interrupt.

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§

source§

impl InterruptNumber for riscv::interrupt::machine::Interrupt

SAFETY: Interrupt represents the standard RISC-V interrupts

source§

impl InterruptNumber for riscv::interrupt::supervisor::Interrupt

SAFETY: Interrupt represents the standard RISC-V interrupts