Skip to main content

StdIoProvider

Struct StdIoProvider 

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

An IoProvider implementation backed by Rust’s standard I/O.

Supports the three well-known ports:

PortIdDirectionBacking
STDINinputstd::io::stdin()
STDOUToutputstd::io::stdout()
STDERRoutputstd::io::stderr()

Additionally supports dynamically opened string ports.

Implementations§

Source§

impl StdIoProvider

Source

pub fn new() -> Self

Create a new StdIoProvider.

Trait Implementations§

Source§

impl Default for StdIoProvider

Source§

fn default() -> Self

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

impl IoProvider for StdIoProvider

Source§

fn read_char(&mut self, port: PortId) -> IoResult<char>

Read a single character from the specified input port.
Source§

fn peek_char(&mut self, port: PortId) -> IoResult<char>

Peek at the next character without consuming it.
Source§

fn char_ready(&mut self, port: PortId) -> IoResult<bool>

Return true if a character is ready on the input port.
Source§

fn write_char(&mut self, port: PortId, c: char) -> IoResult<()>

Write a single character to the specified output port.
Source§

fn write_str(&mut self, port: PortId, s: &str) -> IoResult<()>

Write a string slice to the specified output port.
Source§

fn flush(&mut self, port: PortId) -> IoResult<()>

Flush the specified output port.
Source§

fn close_port(&mut self, port: PortId) -> IoResult<()>

Close the specified port.
Source§

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

Return true if the port is an output port.
Source§

fn open_input_string(&mut self, s: &str) -> IoResult<PortId>

Open an input port that reads from the given string. Read more
Source§

fn open_output_string(&mut self) -> IoResult<PortId>

Open an output port that accumulates characters into a string buffer. Read more
Source§

fn get_output_string(&self, port: PortId) -> IoResult<&str>

Retrieve the accumulated string from an output string port. 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.