pub trait StdoutStream: IsTerminal + Send {
// Required method
fn async_stream(&self) -> Box<dyn AsyncWrite + Send + Sync>;
// Provided method
fn p2_stream(&self) -> Box<dyn OutputStream> { ... }
}
Expand description
Similar to StdinStream
, except for output.
This is used both for a guest stdin and a guest stdout.
Note that there are many built-in implementations of this trait for various
types such as [tokio::io::Stdout
], [tokio::io::Empty
], and
p2::pipe::MemoryOutputPipe
.
Required Methods§
Sourcefn async_stream(&self) -> Box<dyn AsyncWrite + Send + Sync>
fn async_stream(&self) -> Box<dyn AsyncWrite + Send + Sync>
Returns a fresh new stream which can write to this output stream.
Note that all output streams should output to the same logical source. This means that it’s possible for each independent stream to acquire a separate “permit” to write and then act on that permit. Note that additionally at this time once a permit is “acquired” there’s no way to release it, for example you can wait for readiness and then never actually write in WASI. This means that acquisition of a permit for one stream cannot discount the size of a permit another stream could obtain.
Implementations must be able to handle this
Provided Methods§
Sourcefn p2_stream(&self) -> Box<dyn OutputStream>
fn p2_stream(&self) -> Box<dyn OutputStream>
Same as Self::async_stream
except that a WASIp2 OutputStream
is
returned.
Note that this has a default implementation which uses
p2::pipe::AsyncWriteStream
as an adapter, but this can be overridden
if there’s a more specialized implementation available.