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.

Source§

Source

🔬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()?;

Source§

Source§

Source§

Source§

Source§

Converts to this type from the input type.

Source§

Source§

Converts to this type from the input type.

Source§

Source§

Converts to this type from the input type.

Source§

Source§

Constructs a new instance of Self from the given raw file descriptor. Read more

Source§

Source§

Consumes this object, returning the raw underlying file descriptor. Read more

Source§

Source§

Writes a buffer into this writer, returning how many bytes were written. Read more

Source§

Flushes this output stream, ensuring that all intermediately buffered contents reach their destination. Read more

Source§

Like write, except that it writes from a slice of buffers. Read more

Source§

🔬This is a nightly-only experimental API. (can_vector #69941)

1.0.0 · Source§

Attempts to write an entire buffer into this writer. Read more

Source§

🔬This is a nightly-only experimental API. (write_all_vectored #70436)

Attempts to write multiple buffers into this writer. Read more

1.0.0 · Source§

Writes a formatted string into this writer, returning any error encountered. Read more

1.0.0 · Source§

Creates a “by reference” adapter for this instance of Write. Read more

Source§

Source§

Writes a buffer into this writer, returning how many bytes were written. Read more

Source§

Flushes this output stream, ensuring that all intermediately buffered contents reach their destination. Read more

Source§

Like write, except that it writes from a slice of buffers. Read more

Source§

🔬This is a nightly-only experimental API. (can_vector #69941)

1.0.0 · Source§

Attempts to write an entire buffer into this writer. Read more

Source§

🔬This is a nightly-only experimental API. (write_all_vectored #70436)

Attempts to write multiple buffers into this writer. Read more

1.0.0 · Source§

Writes a formatted string into this writer, returning any error encountered. Read more

1.0.0 · Source§

Creates a “by reference” adapter for this instance of Write. Read more

§

§

§

§

§

§