[][src]Trait pir_8_emu::vm::PortHandler

pub trait PortHandler: Downcast {
    fn port_count(&self) -> NonZeroU8;
fn init(&mut self, ports: &[u8]);
fn uninit(&mut self);
fn handle_read(&mut self, port: u8) -> u8;
fn handle_write(&mut self, port: u8, byte: u8); }

A handler for any number of exclusively-allocated ports

Required methods

fn port_count(&self) -> NonZeroU8

Get the amount of ports this handler handles

fn init(&mut self, ports: &[u8])

Initialise the handler to use the specified ports

When called through Ports::install_handler(), the length of the specified port set will be equal to what was last returned by port_count()

fn uninit(&mut self)

Deinitialise the handler

Called during Ports::uninstall_handler() or during Ports' destructor

fn handle_read(&mut self, port: u8) -> u8

Handle reading the returned byte from the specified port

When called through Ports::read(), the specified port is guaranteed to have been contained within the port set specified during the init() call, which is guaranteed to have run before this

fn handle_write(&mut self, port: u8, byte: u8)

Handle writing the specified byte to the specified port

When called through Ports::write(), the specified port is guaranteed to have been contained within the port set specified during the init() call, which is guaranteed to have run before this

Loading content...

Methods

impl dyn PortHandler

pub fn is<__T: PortHandler>(&self) -> bool

Returns true if the trait object wraps an object of type __T.

pub fn downcast<__T: PortHandler>(
    self: Box<Self>
) -> Result<Box<__T>, Box<Self>>

Returns a boxed object from a boxed trait object if the underlying object is of type __T. Returns the original boxed trait if it isn't.

pub fn downcast_rc<__T: PortHandler>(
    self: Rc<Self>
) -> Result<Rc<__T>, Rc<Self>>

Returns an Rc-ed object from an Rc-ed trait object if the underlying object is of type __T. Returns the original Rc-ed trait if it isn't.

pub fn downcast_ref<__T: PortHandler>(&self) -> Option<&__T>

Returns a reference to the object within the trait object if it is of type __T, or None if it isn't.

pub fn downcast_mut<__T: PortHandler>(&mut self) -> Option<&mut __T>

Returns a mutable reference to the object within the trait object if it is of type __T, or None if it isn't.

Implementors

impl PortHandler for NativePortHandler[src]

Loading content...