[][src]Struct rdcl_aoc_helpers::machine::Machine

pub struct Machine<I: MachineInstruction, R: MachineRegister, O: OutputReceiver<R>> {
    pub register: R,
    pub output_receiver: O,
    // some fields omitted
}

A machine which can run instructions.

Fields

register: Routput_receiver: O

Implementations

impl<I: MachineInstruction> Machine<I, HashMapRegister, NoopOutputReceiver>[src]

pub fn new_simple_machine(
    instructions: &[I]
) -> Machine<I, HashMapRegister, NoopOutputReceiver>
[src]

Constructs a new machine which uses a HashMapRegister and the NoopOutputReceiver.

impl<I, R, O> Machine<I, R, O> where
    I: MachineInstruction,
    R: MachineRegister,
    O: OutputReceiver<R>, 
[src]

pub fn new_machine(
    instructions: &[I],
    register: R,
    output_receiver: O
) -> Machine<I, R, O>
[src]

Constructs a new machine where you specify your own register and output receiver.

pub fn run<H: PreExecuteHook<I>>(&mut self, pre_execute_hook: &mut H)[src]

Let the program run.

pub fn get_counter(&self) -> i64[src]

Returns the program counter.

pub fn get_instruction(&self, idx: i64) -> Option<(usize, I)>[src]

Fetch the instruction at position idx, if any.

pub fn set_instruction(&mut self, idx: i64, new_instruction: &I)[src]

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
[src]

impl<I, R, O> Send for Machine<I, R, O> where
    I: Send,
    O: Send,
    R: Send
[src]

impl<I, R, O> Sync for Machine<I, R, O> where
    I: Sync,
    O: Sync,
    R: Sync
[src]

impl<I, R, O> Unpin for Machine<I, R, O> where
    I: Unpin,
    O: Unpin,
    R: Unpin
[src]

impl<I, R, O> UnwindSafe for Machine<I, R, O> where
    I: UnwindSafe,
    O: UnwindSafe,
    R: UnwindSafe
[src]

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.