Trait StdinStream

Source
pub trait StdinStream: IsTerminal + Send {
    // Required method
    fn async_stream(&self) -> Box<dyn AsyncRead + Send + Sync>;

    // Provided method
    fn p2_stream(&self) -> Box<dyn InputStream> { ... }
}
Expand description

A trait used to represent the standard input to a guest program.

Note that there are many built-in implementations of this trait for various types such as [tokio::io::Stdin], [tokio::io::Empty], and p2::pipe::MemoryInputPipe.

Required Methods§

Source

fn async_stream(&self) -> Box<dyn AsyncRead + Send + Sync>

Creates a fresh stream which is reading stdin.

Note that the returned stream must share state with all other streams previously created. Guests may create multiple handles to the same stdin and they should all be synchronized in their progress through the program’s input.

Note that this means that if one handle becomes ready for reading they all become ready for reading. Subsequently if one is read from it may mean that all the others are no longer ready for reading. This is basically a consequence of the way the WIT APIs are designed today.

Provided Methods§

Source

fn p2_stream(&self) -> Box<dyn InputStream>

Same as Self::async_stream except that a WASIp2 InputStream is returned.

Note that this has a default implementation which uses p2::pipe::AsyncReadStream as an adapter, but this can be overridden if there’s a more specialized implementation available.

Implementations on Foreign Types§

Source§

impl StdinStream for Stdin

Source§

fn p2_stream(&self) -> Box<dyn InputStream>

Source§

fn async_stream(&self) -> Box<dyn AsyncRead + Send + Sync>

Source§

impl StdinStream for Empty

Source§

fn p2_stream(&self) -> Box<dyn InputStream>

Source§

fn async_stream(&self) -> Box<dyn AsyncRead + Send + Sync>

Source§

impl StdinStream for Empty

Source§

fn p2_stream(&self) -> Box<dyn InputStream>

Source§

fn async_stream(&self) -> Box<dyn AsyncRead + Send + Sync>

Source§

impl StdinStream for Stdin

Source§

fn p2_stream(&self) -> Box<dyn InputStream>

Source§

fn async_stream(&self) -> Box<dyn AsyncRead + Send + Sync>

Source§

impl<T: ?Sized + StdinStream + Sync> StdinStream for &T

Source§

fn p2_stream(&self) -> Box<dyn InputStream>

Source§

fn async_stream(&self) -> Box<dyn AsyncRead + Send + Sync>

Source§

impl<T: ?Sized + StdinStream + Sync> StdinStream for &mut T

Source§

fn p2_stream(&self) -> Box<dyn InputStream>

Source§

fn async_stream(&self) -> Box<dyn AsyncRead + Send + Sync>

Source§

impl<T: ?Sized + StdinStream + Sync> StdinStream for Box<T>

Source§

fn p2_stream(&self) -> Box<dyn InputStream>

Source§

fn async_stream(&self) -> Box<dyn AsyncRead + Send + Sync>

Source§

impl<T: ?Sized + StdinStream + Sync> StdinStream for Arc<T>

Source§

fn p2_stream(&self) -> Box<dyn InputStream>

Source§

fn async_stream(&self) -> Box<dyn AsyncRead + Send + Sync>

Implementors§