pub struct IoRuntime { /* private fields */ }Expand description
The main I/O runtime that executes IO actions.
Implementations§
Source§impl IoRuntime
impl IoRuntime
Sourcepub fn enable_capture(&mut self)
pub fn enable_capture(&mut self)
Enable output capturing.
Sourcepub fn captured_output(&self) -> Option<&[String]>
pub fn captured_output(&self) -> Option<&[String]>
Get captured output.
Sourcepub fn push_input(&mut self, input: String)
pub fn push_input(&mut self, input: String)
Push input for mocking.
Sourcepub fn exec_println(&mut self, s: &str) -> IoResult<()>
pub fn exec_println(&mut self, s: &str) -> IoResult<()>
Execute a println operation.
Sourcepub fn exec_print(&mut self, s: &str) -> IoResult<()>
pub fn exec_print(&mut self, s: &str) -> IoResult<()>
Execute a print operation.
Sourcepub fn exec_get_line(&mut self) -> IoResult<String>
pub fn exec_get_line(&mut self) -> IoResult<String>
Execute a getLine operation.
Sourcepub fn exec_read_file(&mut self, path: &str) -> IoResult<String>
pub fn exec_read_file(&mut self, path: &str) -> IoResult<String>
Execute a file read operation.
Sourcepub fn exec_write_file(&mut self, path: &str, contents: &str) -> IoResult<()>
pub fn exec_write_file(&mut self, path: &str, contents: &str) -> IoResult<()>
Execute a file write operation.
Sourcepub fn write_ref(&mut self, id: u64, value: RtObject) -> IoResult<()>
pub fn write_ref(&mut self, id: u64, value: RtObject) -> IoResult<()>
Write to a mutable reference.
Sourcepub fn modify_ref(
&mut self,
id: u64,
f: impl FnOnce(RtObject) -> RtObject,
) -> IoResult<()>
pub fn modify_ref( &mut self, id: u64, f: impl FnOnce(RtObject) -> RtObject, ) -> IoResult<()>
Modify a mutable reference with a function.
Sourcepub fn get_env_var(&self, key: &str) -> Option<String>
pub fn get_env_var(&self, key: &str) -> Option<String>
Get an environment variable.
Sourcepub fn get_time_nanos(&self) -> IoResult<u64>
pub fn get_time_nanos(&self) -> IoResult<u64>
Get the current time as nanoseconds since epoch.
Sourcepub fn is_enabled(&self) -> bool
pub fn is_enabled(&self) -> bool
Check if I/O is enabled.
Sourcepub fn set_enabled(&mut self, enabled: bool)
pub fn set_enabled(&mut self, enabled: bool)
Enable or disable I/O.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for IoRuntime
impl RefUnwindSafe for IoRuntime
impl Send for IoRuntime
impl Sync for IoRuntime
impl Unpin for IoRuntime
impl UnsafeUnpin for IoRuntime
impl UnwindSafe for IoRuntime
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