Function stdout
pub fn stdout() -> Stdout
Constructs a new handle to the standard output of the current process.
The returned handle allows writing to standard out from the within the Tokio runtime.
Concurrent writes to stdout must be executed with care: Only individual
writes to this AsyncWrite are guaranteed to be intact. In particular
you should be aware that writes using write_all are not guaranteed
to occur as a single write, so multiple threads writing data with
write_all may result in interleaved output.
Note that unlike std::io::stdout, each call to this stdout()
produces a new writer, so for example, this program does not flush stdout:
# use tokio::io::AsyncWriteExt;
# #[tokio::main]
# async fn main() -> std::io::Result<()> {
tokio::io::stdout().write_all(b"aa").await?;
tokio::io::stdout().flush().await?;
# Ok(())
# }
Examples
use ;
async
The following is an example of using stdio with loop.
use ;
async