pub struct NullIoProvider;Expand description
A no-op I/O provider that silently discards all output and returns
IoErrorKind::Unsupported for reads.
Useful as a default when no I/O back-end is configured.
Trait Implementations§
Source§impl IoProvider for NullIoProvider
impl IoProvider for NullIoProvider
Source§fn read_char(&mut self, _port: PortId) -> Result<char, IoErrorKind>
fn read_char(&mut self, _port: PortId) -> Result<char, IoErrorKind>
Read a single character from the specified input port.
Source§fn peek_char(&mut self, _port: PortId) -> Result<char, IoErrorKind>
fn peek_char(&mut self, _port: PortId) -> Result<char, IoErrorKind>
Peek at the next character without consuming it.
Source§fn char_ready(&mut self, _port: PortId) -> Result<bool, IoErrorKind>
fn char_ready(&mut self, _port: PortId) -> Result<bool, IoErrorKind>
Return
true if a character is ready on the input port.Source§fn write_char(&mut self, _port: PortId, _c: char) -> Result<(), IoErrorKind>
fn write_char(&mut self, _port: PortId, _c: char) -> Result<(), IoErrorKind>
Write a single character to the specified output port.
Source§fn write_str(&mut self, _port: PortId, _s: &str) -> Result<(), IoErrorKind>
fn write_str(&mut self, _port: PortId, _s: &str) -> Result<(), IoErrorKind>
Write a string slice to the specified output port.
Source§fn flush(&mut self, _port: PortId) -> Result<(), IoErrorKind>
fn flush(&mut self, _port: PortId) -> Result<(), IoErrorKind>
Flush the specified output port.
Source§fn close_port(&mut self, _port: PortId) -> Result<(), IoErrorKind>
fn close_port(&mut self, _port: PortId) -> Result<(), IoErrorKind>
Close the specified port.
Source§fn is_input_port(&self, _port: PortId) -> bool
fn is_input_port(&self, _port: PortId) -> bool
Return
true if the port is an input port.Source§fn is_output_port(&self, _port: PortId) -> bool
fn is_output_port(&self, _port: PortId) -> bool
Return
true if the port is an output port.Source§fn is_port_open(&self, _port: PortId) -> bool
fn is_port_open(&self, _port: PortId) -> bool
Return
true if the port is still open.
Default: returns true (assumes ports are open unless overridden).Source§fn is_textual_port(&self, port: PortId) -> bool
fn is_textual_port(&self, port: PortId) -> bool
Return
true if the port is a textual port.
Default: returns true for any valid input or output port.Source§fn is_binary_port(&self, _port: PortId) -> bool
fn is_binary_port(&self, _port: PortId) -> bool
Return
true if the port is a binary port.
Default: returns false (all ports are textual by default).Source§fn open_input_string(&mut self, _s: &str) -> Result<PortId, IoErrorKind>
fn open_input_string(&mut self, _s: &str) -> Result<PortId, IoErrorKind>
Open an input port that reads from the given string. Read more
Source§fn open_output_string(&mut self) -> Result<PortId, IoErrorKind>
fn open_output_string(&mut self) -> Result<PortId, IoErrorKind>
Open an output port that accumulates characters into a string buffer. Read more
Source§fn get_output_string(&self, _port: PortId) -> Result<&str, IoErrorKind>
fn get_output_string(&self, _port: PortId) -> Result<&str, IoErrorKind>
Retrieve the accumulated string from an output string port. Read more
Source§fn file_exists(&self, _path: &str) -> Result<bool, IoErrorKind>
fn file_exists(&self, _path: &str) -> Result<bool, IoErrorKind>
Check whether a file exists at the given path.
Default: returns
IoErrorKind::Unsupported.Source§fn delete_file(&mut self, _path: &str) -> Result<(), IoErrorKind>
fn delete_file(&mut self, _path: &str) -> Result<(), IoErrorKind>
Delete the file at the given path.
Default: returns
IoErrorKind::Unsupported.Source§fn read_file(&mut self, _path: &str) -> Result<&str, IoErrorKind>
fn read_file(&mut self, _path: &str) -> Result<&str, IoErrorKind>
Read the entire contents of a file as a string.
Default: returns
IoErrorKind::Unsupported.Source§fn command_line_count(&self) -> Result<usize, IoErrorKind>
fn command_line_count(&self) -> Result<usize, IoErrorKind>
Return the number of command-line arguments.
Default: returns
IoErrorKind::Unsupported.Source§fn command_line_arg(&self, _index: usize) -> Result<&str, IoErrorKind>
fn command_line_arg(&self, _index: usize) -> Result<&str, IoErrorKind>
Return the command-line argument at the given index.
Default: returns
IoErrorKind::Unsupported.Source§fn get_environment_variable(
&mut self,
_name: &str,
) -> Result<Option<&str>, IoErrorKind>
fn get_environment_variable( &mut self, _name: &str, ) -> Result<Option<&str>, IoErrorKind>
Retrieve the value of an environment variable by name.
Returns
Ok(Some(value)) if found, Ok(None) if not set.
Default: returns IoErrorKind::Unsupported.Source§fn environment_variables_count(&mut self) -> Result<usize, IoErrorKind>
fn environment_variables_count(&mut self) -> Result<usize, IoErrorKind>
Return the number of environment variables.
Must be called before
environment_variable_at
to snapshot the current environment.
Default: returns IoErrorKind::Unsupported.Source§fn environment_variable_at(
&self,
_index: usize,
) -> Result<(&str, &str), IoErrorKind>
fn environment_variable_at( &self, _index: usize, ) -> Result<(&str, &str), IoErrorKind>
Return the environment variable name and value at the given index.
environment_variables_count must be
called first to snapshot the environment.
Default: returns IoErrorKind::Unsupported.Source§fn exit_process(&mut self, _code: i32) -> Result<(), IoErrorKind>
fn exit_process(&mut self, _code: i32) -> Result<(), IoErrorKind>
Exit the process with the given status code.
Default: returns
IoErrorKind::Unsupported.Source§fn emergency_exit_process(&mut self, _code: i32) -> Result<(), IoErrorKind>
fn emergency_exit_process(&mut self, _code: i32) -> Result<(), IoErrorKind>
Emergency exit the process (no cleanup) with the given status code.
Default: returns
IoErrorKind::Unsupported.Auto Trait Implementations§
impl Freeze for NullIoProvider
impl RefUnwindSafe for NullIoProvider
impl Send for NullIoProvider
impl Sync for NullIoProvider
impl Unpin for NullIoProvider
impl UnwindSafe for NullIoProvider
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