Skip to main content

IoRuntime

Struct IoRuntime 

Source
pub struct IoRuntime { /* private fields */ }
Expand description

The main I/O runtime that executes IO actions.

Implementations§

Source§

impl IoRuntime

Source

pub fn new() -> Self

Create a new I/O runtime.

Source

pub fn sandboxed() -> Self

Create a sandboxed I/O runtime (no real I/O).

Source

pub fn enable_capture(&mut self)

Enable output capturing.

Source

pub fn captured_output(&self) -> Option<&[String]>

Get captured output.

Source

pub fn push_input(&mut self, input: String)

Push input for mocking.

Source

pub fn set_args(&mut self, args: Vec<String>)

Set command-line arguments.

Source

pub fn set_env(&mut self, key: String, value: String)

Set an environment variable.

Source

pub fn exec_println(&mut self, s: &str) -> IoResult<()>

Execute a println operation.

Source

pub fn exec_print(&mut self, s: &str) -> IoResult<()>

Execute a print operation.

Source

pub fn exec_get_line(&mut self) -> IoResult<String>

Execute a getLine operation.

Source

pub fn exec_read_file(&mut self, path: &str) -> IoResult<String>

Execute a file read operation.

Source

pub fn exec_write_file(&mut self, path: &str, contents: &str) -> IoResult<()>

Execute a file write operation.

Source

pub fn new_ref(&mut self, value: RtObject) -> u64

Create a new mutable reference.

Source

pub fn read_ref(&mut self, id: u64) -> IoResult<RtObject>

Read a mutable reference.

Source

pub fn write_ref(&mut self, id: u64, value: RtObject) -> IoResult<()>

Write to a mutable reference.

Source

pub fn modify_ref( &mut self, id: u64, f: impl FnOnce(RtObject) -> RtObject, ) -> IoResult<()>

Modify a mutable reference with a function.

Source

pub fn get_env_var(&self, key: &str) -> Option<String>

Get an environment variable.

Source

pub fn get_args(&self) -> &[String]

Get the command-line arguments.

Source

pub fn get_time_nanos(&self) -> IoResult<u64>

Get the current time as nanoseconds since epoch.

Source

pub fn stats(&self) -> &IoStats

Get the statistics.

Source

pub fn is_enabled(&self) -> bool

Check if I/O is enabled.

Source

pub fn set_enabled(&mut self, enabled: bool)

Enable or disable I/O.

Source

pub fn reset(&mut self)

Reset the runtime state.

Trait Implementations§

Source§

impl Debug for IoRuntime

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for IoRuntime

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

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

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.