Skip to main content

ProgramCounter

Trait ProgramCounter 

Source
pub trait ProgramCounter {
    type Instruction;

    // Required methods
    fn pc(&self) -> u32;
    fn pc_mut(&mut self) -> &mut u32;
    fn get_instruction(&self, pc: u32) -> Result<&Self::Instruction>;

    // Provided methods
    fn peek_instruction(&self) -> Result<&Self::Instruction> { ... }
    fn next_instruction(&mut self) -> Result<&Self::Instruction> { ... }
}

Required Associated Types§

Required Methods§

Source

fn pc(&self) -> u32

Get the current program counter.

Source

fn pc_mut(&mut self) -> &mut u32

Get a mutable reference to the program counter.

Source

fn get_instruction(&self, pc: u32) -> Result<&Self::Instruction>

Get the instruction at the given program counter without advancing it.

Provided Methods§

Source

fn peek_instruction(&self) -> Result<&Self::Instruction>

Peek the current instruction without advancing the program counter.

Source

fn next_instruction(&mut self) -> Result<&Self::Instruction>

Get the current instruction and advance the program counter by 1.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§