lc3_ensemble::sim::device

Struct Interrupt

source
pub struct Interrupt { /* private fields */ }
Expand description

An interrupt.

This is output by an implementation of ExternalDevice::poll_interrupt if an interrupt should occur.

Implementations§

source§

impl Interrupt

source

pub fn vectored(vect: u8, priority: u8) -> Self

Creates a new vectored interrupt.

Note that the priority is truncated to 3 bits.

source

pub fn external(e: impl Error + Send + Sync + 'static) -> Self

Creates a new external interrupt (one not handled by the OS).

When this type of interrupt is raised, the simulator raises SimErr::Interrupt which can be used to handle the resulting InterruptErr.

One example where this is used is in Python bindings. In that case, we want to be able to halt the Simulator on a KeyboardInterrupt. However, by default, Python cannot signal to the Rust library that a KeyboardInterrupt has occurred. Thus, we can add a signal handler as an external interrupt to allow the KeyboardInterrupt to be handled properly.

source

pub fn priority(&self) -> Option<u8>

Calculates the priority for a given interrupt.

  • For all vectored interrupts, this is the three least-significant bits of the priority value.
  • For external interrupts, this is None

Trait Implementations§

source§

impl Debug for Interrupt

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

source§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

source§

fn vzip(self) -> V