pub struct Machine { /* private fields */ }
Expand description
An instance of an Intcode virtual machine.
Implementations§
Source§impl Machine
impl Machine
Sourcepub fn new() -> Machine
pub fn new() -> Machine
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
Sourcepub fn reserve(&mut self, size: usize)
pub fn reserve(&mut self, size: usize)
Ensures that memory locations 0..size
are valid, extending memory with zeroes if needed.
Sourcepub fn copy(&mut self, start: usize, values: &[isize])
pub fn copy(&mut self, start: usize, values: &[isize])
Copies the given slice into memory at the given location.
Sourcepub fn step(&mut self, input: Option<isize>) -> Result<(), Exit>
pub fn step(&mut self, input: Option<isize>) -> Result<(), Exit>
Executes a single instruction.
Sourcepub fn resume(&mut self, input: Option<isize>) -> Exit
pub fn resume(&mut self, input: Option<isize>) -> Exit
Runs the program until the first error is encountered.
Sourcepub fn run<I, O>(&mut self, input: I, output: O) -> Exit
pub fn run<I, O>(&mut self, input: I, output: O) -> Exit
Runs the program using the given I/O interfaces.
pub fn spawn<I, O>(self, input: I, output: O) -> JoinHandle<(Machine, Exit)>
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Machine
impl RefUnwindSafe for Machine
impl Send for Machine
impl Sync for Machine
impl Unpin for Machine
impl UnwindSafe for Machine
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more