PipeWriter in std::io - Rust (original) (raw)

Struct PipeWriter

1.87.0 · Source

pub struct PipeWriter(/* private fields */);

Expand description

Write end of an anonymous pipe.

Source§

1.87.0 · Source

Creates a new PipeWriter instance that shares the same underlying file description.

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

1.87.0 · Source§

1.87.0 · Source§

Available on Windows only.

1.87.0 · Source§

1.87.0 · Source§

Available on Windows only.

1.87.0 · Source§

1.87.0 · Source§

Source§

Converts to this type from the input type.

1.87.0 · Source§

Available on Windows only.

Source§

Converts to this type from the input type.

1.87.0 · Source§

Source§

Converts to this type from the input type.

1.87.0 · Source§

Available on Windows only.

Source§

Converts to this type from the input type.

1.87.0 · Source§

Source§

Converts to this type from the input type.

1.87.0 · Source§

Source§

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

1.87.0 · Source§

Available on Windows only.

1.87.0 · Source§

Source§

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

1.87.0 · Source§

Available on Windows only.

1.87.0 · 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

1.87.0 · 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

§

§

§

§

§

§