pub trait Addressable {
// Required methods
fn read_tryte(&mut self, addr: Word) -> Result<Tryte, MemoryError>;
fn write_tryte(
&mut self,
addr: Word,
value: Tryte,
) -> Result<(), MemoryError>;
fn read_word(&mut self, addr: Word) -> Result<Word, MemoryError>;
fn write_word(&mut self, addr: Word, value: Word) -> Result<(), MemoryError>;
// Provided methods
fn is_privileged(&self, _addr: Word) -> bool { ... }
fn interrupts(&self) -> Word { ... }
}Expand description
Anything a program can load from and store to.
Reads take &mut self because a device read can have a side effect, such as
consuming a byte from a console input queue.
Required Methods§
Sourcefn read_tryte(&mut self, addr: Word) -> Result<Tryte, MemoryError>
fn read_tryte(&mut self, addr: Word) -> Result<Tryte, MemoryError>
Reads one tryte.
Sourcefn write_tryte(&mut self, addr: Word, value: Tryte) -> Result<(), MemoryError>
fn write_tryte(&mut self, addr: Word, value: Tryte) -> Result<(), MemoryError>
Writes one tryte.
Sourcefn read_word(&mut self, addr: Word) -> Result<Word, MemoryError>
fn read_word(&mut self, addr: Word) -> Result<Word, MemoryError>
Reads a word: three trytes, least significant first.
Sourcefn write_word(&mut self, addr: Word, value: Word) -> Result<(), MemoryError>
fn write_word(&mut self, addr: Word, value: Word) -> Result<(), MemoryError>
Writes a word: three trytes, least significant first.
Provided Methods§
Sourcefn is_privileged(&self, _addr: Word) -> bool
fn is_privileged(&self, _addr: Word) -> bool
True if reaching addr should require supervisor privilege.
Plain memory returns false for everything. A bus that maps devices returns true for their addresses, which is what stops a user program driving hardware directly.
Sourcefn interrupts(&self) -> Word
fn interrupts(&self) -> Word
Which interrupt sources are asserting, one trit per source.
See irq for what each trit means. Zero for anything with no devices
attached.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".