Struct rdcl_aoc_helpers::machine::Machine
source · pub struct Machine<I: MachineInstruction, R: MachineRegister, O: OutputReceiver<R>> {
pub register: R,
pub output_receiver: O,
/* private fields */
}
Expand description
A machine which can run instructions.
Fields
register: R
output_receiver: O
Implementations
sourceimpl<I: MachineInstruction> Machine<I, HashMapRegister, NoopOutputReceiver>
impl<I: MachineInstruction> Machine<I, HashMapRegister, NoopOutputReceiver>
sourcepub fn new_simple_machine(
instructions: &[I]
) -> Machine<I, HashMapRegister, NoopOutputReceiver>
pub fn new_simple_machine(
instructions: &[I]
) -> Machine<I, HashMapRegister, NoopOutputReceiver>
Constructs a new machine which uses a HashMapRegister and the NoopOutputReceiver.
sourceimpl<I, R, O> Machine<I, R, O>where
I: MachineInstruction,
R: MachineRegister,
O: OutputReceiver<R>,
impl<I, R, O> Machine<I, R, O>where
I: MachineInstruction,
R: MachineRegister,
O: OutputReceiver<R>,
sourcepub fn new_machine(
instructions: &[I],
register: R,
output_receiver: O
) -> Machine<I, R, O>
pub fn new_machine(
instructions: &[I],
register: R,
output_receiver: O
) -> Machine<I, R, O>
Constructs a new machine where you specify your own register and output receiver.
sourcepub fn run<H: PreExecuteHook<I>>(&mut self, pre_execute_hook: &mut H)
pub fn run<H: PreExecuteHook<I>>(&mut self, pre_execute_hook: &mut H)
Let the program run.
sourcepub fn get_counter(&self) -> i64
pub fn get_counter(&self) -> i64
Returns the program counter.
sourcepub fn get_instruction(&self, idx: i64) -> Option<(usize, I)>
pub fn get_instruction(&self, idx: i64) -> Option<(usize, I)>
Fetch the instruction at position idx
, if any.
sourcepub fn set_instruction(&mut self, idx: i64, new_instruction: &I)
pub fn set_instruction(&mut self, idx: i64, new_instruction: &I)
Replaces the instruction at position idx
, if any.
Auto Trait Implementations
impl<I, R, O> RefUnwindSafe for Machine<I, R, O>where
I: RefUnwindSafe,
O: RefUnwindSafe,
R: RefUnwindSafe,
impl<I, R, O> Send for Machine<I, R, O>where
I: Send,
O: Send,
R: Send,
impl<I, R, O> Sync for Machine<I, R, O>where
I: Sync,
O: Sync,
R: Sync,
impl<I, R, O> Unpin for Machine<I, R, O>where
I: Unpin,
O: Unpin,
R: Unpin,
impl<I, R, O> UnwindSafe for Machine<I, R, O>where
I: UnwindSafe,
O: UnwindSafe,
R: UnwindSafe,
Blanket Implementations
sourceimpl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more