pub struct DeviceHandler { /* private fields */ }
Expand description
The central hub for all external devices for the Simulator.
Implementations§
Source§impl DeviceHandler
impl DeviceHandler
Sourcepub fn set_keyboard(&mut self, kb: impl ExternalDevice)
pub fn set_keyboard(&mut self, kb: impl ExternalDevice)
Set the keyboard device.
Sourcepub fn set_display(&mut self, ds: impl ExternalDevice)
pub fn set_display(&mut self, ds: impl ExternalDevice)
Set the display device.
Sourcepub fn add_device<D: ExternalDevice>(
&mut self,
dev: D,
addrs: &[u16],
) -> Result<u16, D>
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.
Sourcepub fn remove_device(&mut self, dev_id: u16)
pub fn remove_device(&mut self, dev_id: u16)
Removes the device at the given device ID.
Trait Implementations§
Source§impl Debug for DeviceHandler
impl Debug for DeviceHandler
Source§impl Default for DeviceHandler
impl Default for DeviceHandler
Source§impl ExternalDevice for DeviceHandler
impl ExternalDevice for DeviceHandler
Source§fn io_read(&mut self, addr: u16, effectful: bool) -> Option<u16>
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
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 poll_interrupt(&mut self) -> Option<Interrupt>
fn poll_interrupt(&mut self) -> Option<Interrupt>
Checks for interrupts on all devices.
Auto Trait Implementations§
impl Freeze for DeviceHandler
impl !RefUnwindSafe for DeviceHandler
impl Send for DeviceHandler
impl Sync for DeviceHandler
impl Unpin for DeviceHandler
impl !UnwindSafe for DeviceHandler
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more