[][src]Struct intcodeint::Machine

pub struct Machine { /* fields omitted */ }

An instance of an Intcode virtual machine.

Methods

impl Machine[src]

pub fn new() -> Machine[src]

Constructs a new machine with the initial state:

  • empty mem;
  • ip pointing to zero;
  • base set at zero.

pub fn with_program(program: &[isize]) -> Machine[src]

pub fn mem(&self) -> &[isize][src]

An immutable view into the virtual machine's memory.

pub fn mem_mut(&mut self) -> &mut [isize][src]

A mutable view into the virtual machine's memory.

pub fn reserve(&mut self, size: usize)[src]

Ensures that memory locations 0..size are valid, extending memory with zeroes if needed.

pub fn copy(&mut self, start: usize, values: &[isize])[src]

Copies the given slice into memory at the given location.

pub fn step(&mut self, input: Option<isize>) -> Result<(), Exit>[src]

Executes a single instruction.

pub fn resume(&mut self, input: Option<isize>) -> Exit[src]

Runs the program until the first error is encountered.

pub fn run<I, O>(&mut self, input: I, output: O) -> Exit where
    I: IntoIterator<Item = isize>,
    O: FnMut(isize), 
[src]

Runs the program using the given I/O interfaces.

pub fn spawn<I, O>(self, input: I, output: O) -> JoinHandle<(Machine, Exit)> where
    I: IntoIterator<Item = isize> + Send + 'static,
    O: FnMut(isize) + Send + 'static, 
[src]

Trait Implementations

impl Debug for Machine[src]

Auto Trait Implementations

impl RefUnwindSafe for Machine

impl Send for Machine

impl Sync for Machine

impl Unpin for Machine

impl UnwindSafe for Machine

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.