Skip to main content

Addressable

Trait Addressable 

Source
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§

Source

fn read_tryte(&mut self, addr: Word) -> Result<Tryte, MemoryError>

Reads one tryte.

Source

fn write_tryte(&mut self, addr: Word, value: Tryte) -> Result<(), MemoryError>

Writes one tryte.

Source

fn read_word(&mut self, addr: Word) -> Result<Word, MemoryError>

Reads a word: three trytes, least significant first.

Source

fn write_word(&mut self, addr: Word, value: Word) -> Result<(), MemoryError>

Writes a word: three trytes, least significant first.

Provided Methods§

Source

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.

Source

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".

Implementors§