[][src]Struct intcode::IntcodeVM

pub struct IntcodeVM { /* fields omitted */ }

Methods

impl IntcodeVM[src]

pub fn new<D: Into<Vec<i64>>>(data: D) -> Self[src]

Create a new VM from some existing memory

pub fn from_stdin() -> Result<Self>[src]

Read a comma-separated list of integers from stdin and make it into a VM

pub fn push_input(&mut self, input: i64)[src]

Add a single input value to the end of the input queue

pub fn push_inputs<I: IntoIterator<Item = i64>>(&mut self, input: I)[src]

Add input values from an interator to the end of the input queue

pub fn pop_output(&mut self) -> Option<i64>[src]

Pop values off the front of the output queue

pub fn iter_output<'a>(&'a self) -> impl Iterator<Item = &i64>[src]

Get an interator over the output queue

pub fn current_raw_opcode(&self) -> Result<i64, ExecutionError>[src]

Get the raw opcode value pointed to by the current PC

pub fn get_memory(&self, index: usize) -> Result<i64, ExecutionError>[src]

Get the value of memory at a given index

pub fn set_memory(
    &mut self,
    index: usize,
    value: i64
) -> Result<(), ExecutionError>
[src]

Set the value of memory at a given index

pub fn get_memory_by_pointer(&self, index: usize) -> Result<i64, ExecutionError>[src]

Get the value at the memory location pointed to by the value at the given index

pub fn set_memory_by_pointer(
    &mut self,
    index: usize,
    value: i64
) -> Result<(), ExecutionError>
[src]

Set the value at the memory location pointed to by the value at the given index

pub fn get_parameter(
    &mut self,
    mode: ParameterMode,
    offset: usize
) -> Result<i64, ExecutionError>
[src]

Get the parameter based on the given value and the mode

pub fn set_parameter(
    &mut self,
    mode: ParameterMode,
    offset: usize,
    value: i64
) -> Result<(), ExecutionError>
[src]

Set the parameter based on the given value and the mode

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

Get the entire memory as a slice

pub fn step(&mut self) -> Result<bool, ExecutionError>[src]

Take a single step through the program

Returns true if the program can continue, or false if the program should halt.

If called again on an already halted program, returns Err(AlreadyHalted).

pub fn run_to_end(&mut self) -> Result<(), ExecutionError>[src]

Run the program until it halts

pub fn next_output(&mut self) -> Result<Option<i64>, ExecutionError>[src]

Run the program until it halts or another output is generated

If an output is available immediately, no progress is made in the program.

pub fn halted(&self) -> bool[src]

Check if the VM has halted

Trait Implementations

impl Clone for IntcodeVM[src]

impl Debug for IntcodeVM[src]

impl Iterator for IntcodeVM[src]

type Item = i64

The type of the elements being iterated over.

Auto Trait Implementations

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<I> IntoIterator for I where
    I: Iterator
[src]

type Item = <I as Iterator>::Item

The type of the elements being iterated over.

type IntoIter = I

Which kind of iterator are we turning this into?

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

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

type Error = !

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.