[−][src]Struct intcodeint::Machine
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]
I: IntoIterator<Item = isize>,
O: FnMut(isize),
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]
I: IntoIterator<Item = isize> + Send + 'static,
O: FnMut(isize) + Send + 'static,
Trait Implementations
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]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,