ttvm 0.4.2

tt64 emulator API for Rust
Documentation
use super::*;

#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord)]
pub struct Bus<T: IO> {
    dev: *mut T,
}

impl<T: IO> Bus<T> {
    pub fn new(dev: &mut T) -> Self {
        Bus { dev }
    }
}

impl<T: IO> IO for Bus<T> {
    fn read(&self, addr: usize, byte: &mut u8) {
        unsafe {
            (*self.dev).read(addr, byte);
        }
    }

    fn write(&mut self, addr: usize, byte: u8) {
        unsafe {
            (*self.dev).write(addr, byte);
        }
    }

    fn capacity(&self) -> usize {
        unsafe { (*self.dev).capacity() }
    }
}