Struct DeviceHandler

Source
pub struct DeviceHandler { /* private fields */ }
Expand description

The central hub for all external devices for the Simulator.

Implementations§

Source§

impl DeviceHandler

Source

pub fn new() -> Self

Creates a new device handler.

Source

pub fn set_keyboard(&mut self, kb: impl ExternalDevice)

Set the keyboard device.

Source

pub fn set_display(&mut self, ds: impl ExternalDevice)

Set the display device.

Source

pub fn add_device<D: ExternalDevice>( &mut self, dev: D, addrs: &[u16], ) -> Result<u16, D>

Add a new device (which is not a keyboard or a display).

This accepts an external device and the addresses which the device should act on. If successful, the ID of the device is returned.

§Errors

If the device cannot be added, it will be returned back to the user.

The cases where the device cannot be added include:

  • The number of devices ever added exceeds u16::MAX.
  • At least one of the addresses provided are already occupied by another device or not an IO port.
Source

pub fn remove_device(&mut self, dev_id: u16)

Removes the device at the given device ID.

Trait Implementations§

Source§

impl Debug for DeviceHandler

Source§

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

Formats the value using the given formatter. Read more
Source§

impl Default for DeviceHandler

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl ExternalDevice for DeviceHandler

Source§

fn io_read(&mut self, addr: u16, effectful: bool) -> Option<u16>

Accesses the IO device mapped to the given address and tries ExternalDevice::io_read on it.

Source§

fn io_write(&mut self, addr: u16, data: u16) -> bool

Accesses the IO device mapped to the given address and tries ExternalDevice::io_write on it.

Source§

fn io_reset(&mut self)

Resets all the devices connected to this handler.

Source§

fn poll_interrupt(&mut self) -> Option<Interrupt>

Checks for interrupts on all devices.

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