Struct PipeWriter

struct PipeWriter(_)

Write end of an anonymous pipe.

Implementations

impl PipeWriter

fn try_clone(self: &Self) -> Result<Self>

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

Examples

# #[cfg(miri)] fn main() {}
# #[cfg(not(miri))]
# fn main() -> std::io::Result<()> {
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()?;
# Ok(())
# }

impl AsFd for PipeWriter

fn as_fd(self: &Self) -> BorrowedFd<'_>

impl AsHandle for PipeWriter

fn as_handle(self: &Self) -> BorrowedHandle<'_>

impl AsRawFd for PipeWriter

fn as_raw_fd(self: &Self) -> RawFd

impl AsRawHandle for PipeWriter

fn as_raw_handle(self: &Self) -> RawHandle

impl Debug for PipeWriter

fn fmt(self: &Self, f: &mut Formatter<'_>) -> Result

impl Freeze for PipeWriter

impl From for PipeWriter

fn from(owned_fd: OwnedFd) -> Self

impl From for PipeWriter

fn from(owned_handle: OwnedHandle) -> Self

impl FromRawFd for PipeWriter

unsafe fn from_raw_fd(raw_fd: RawFd) -> Self

impl FromRawHandle for PipeWriter

unsafe fn from_raw_handle(raw_handle: RawHandle) -> Self

impl IntoRawFd for PipeWriter

fn into_raw_fd(self: Self) -> RawFd

impl IntoRawHandle for PipeWriter

fn into_raw_handle(self: Self) -> RawHandle

impl RefUnwindSafe for PipeWriter

impl Send for PipeWriter

impl Sync for PipeWriter

impl Unpin for PipeWriter

impl UnsafeUnpin for PipeWriter

impl UnwindSafe for PipeWriter

impl Write for PipeWriter

fn write(self: &mut Self, buf: &[u8]) -> Result<usize>
fn flush(self: &mut Self) -> Result<()>
fn write_vectored(self: &mut Self, bufs: &[IoSlice<'_>]) -> Result<usize>
fn is_write_vectored(self: &Self) -> bool

impl<T> Any for PipeWriter

fn type_id(self: &Self) -> TypeId

impl<T> Borrow for PipeWriter

fn borrow(self: &Self) -> &T

impl<T> BorrowMut for PipeWriter

fn borrow_mut(self: &mut Self) -> &mut T

impl<T> From for PipeWriter

fn from(t: T) -> T

Returns the argument unchanged.

impl<T, U> Into for PipeWriter

fn into(self: Self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of [From]<T> for U chooses to do.

impl<T, U> TryFrom for PipeWriter

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

impl<T, U> TryInto for PipeWriter

fn try_into(self: Self) -> Result<U, <U as TryFrom<T>>::Error>