PipeWriter in std::io - Rust (original) (raw)
pub struct PipeWriter(/* private fields */);
🔬This is a nightly-only experimental API. (anonymous_pipe
#127154)
Expand description
Write end of an anonymous pipe.
🔬This is a nightly-only experimental API. (anonymous_pipe
#127154)
Create a new PipeWriter instance that shares the same underlying file description.
§Examples
#![feature(anonymous_pipe)]
use std::process::Command;
use std::io::{pipe, Read};
let (mut reader, writer) = pipe()?;
// Spawn a process that writes to stdout and stderr.
let mut peer = Command::new("bash")
.args([
"-c",
"echo -n foo\n\
echo -n bar >&2"
])
.stdout(writer.try_clone()?)
.stderr(writer)
.spawn()?;
// Read and check the result.
let mut msg = String::new();
reader.read_to_string(&mut msg)?;
assert_eq!(&msg, "foobar");
peer.wait()?;
Converts to this type from the input type.
Converts to this type from the input type.
Converts to this type from the input type.
Constructs a new instance of Self
from the given raw file descriptor. Read more
Consumes this object, returning the raw underlying file descriptor. Read more
Writes a buffer into this writer, returning how many bytes were written. Read more
Flushes this output stream, ensuring that all intermediately buffered contents reach their destination. Read more
Like write, except that it writes from a slice of buffers. Read more
🔬This is a nightly-only experimental API. (can_vector
#69941)
Attempts to write an entire buffer into this writer. Read more
🔬This is a nightly-only experimental API. (write_all_vectored
#70436)
Attempts to write multiple buffers into this writer. Read more
Writes a formatted string into this writer, returning any error encountered. Read more
Creates a “by reference” adapter for this instance of Write
. Read more
Writes a buffer into this writer, returning how many bytes were written. Read more
Flushes this output stream, ensuring that all intermediately buffered contents reach their destination. Read more
Like write, except that it writes from a slice of buffers. Read more
🔬This is a nightly-only experimental API. (can_vector
#69941)
Attempts to write an entire buffer into this writer. Read more
🔬This is a nightly-only experimental API. (write_all_vectored
#70436)
Attempts to write multiple buffers into this writer. Read more
Writes a formatted string into this writer, returning any error encountered. Read more
Creates a “by reference” adapter for this instance of Write
. Read more