pub struct IoContext { /* private fields */ }Expand description
File descriptor table for the REPL session.
Lives in the binary layer and is passed into eval_with_io.
File descriptors 1 (stdout) and 2 (stderr) are virtual — not stored here,
handled by write_to_fd directly. User-opened files start at fd 3.
Implementations§
Source§impl IoContext
impl IoContext
Sourcepub fn fopen(&mut self, path: &str, mode: &str) -> i32
pub fn fopen(&mut self, path: &str, mode: &str) -> i32
Opens a file and returns a new file descriptor, or -1 on failure.
Supported modes: "r", "w", "a", "r+".
Sourcepub fn fclose(&mut self, fd: i32) -> i32
pub fn fclose(&mut self, fd: i32) -> i32
Closes a file descriptor. Returns 0 on success, -1 if fd is unknown.
Sourcepub fn fclose_all(&mut self)
pub fn fclose_all(&mut self)
Closes all open file handles.
Sourcepub fn fgetl(&mut self, fd: i32) -> Option<String>
pub fn fgetl(&mut self, fd: i32) -> Option<String>
Reads one line from fd, stripping the trailing newline (fgetl semantics).
Returns None at EOF or on error.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for IoContext
impl RefUnwindSafe for IoContext
impl Send for IoContext
impl Sync for IoContext
impl Unpin for IoContext
impl UnsafeUnpin for IoContext
impl UnwindSafe for IoContext
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