pub struct PipeWriter(/* private fields */);
Write end of an anonymous pipe.
impl PipeWriter
pub fn try_clone(&self) -> Result<Self>
Creates a new PipeWriter instance that shares the same underlying file description.
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()?;impl AsFd for PipeWriterAvailable on (Unix or HermitCore or target_os=trusty or WASI or target_os=motor) and non-target_os=trusty only.
impl AsHandle for PipeWriterAvailable on Windows only.
impl AsRawFd for PipeWriterAvailable on (Unix or HermitCore or target_os=trusty or WASI or target_os=motor) and non-target_os=trusty only.
impl AsRawHandle for PipeWriterAvailable on Windows only.
impl Debug for PipeWriter
fn fmt(&self, f: &mut Formatter<'_>) -> Result
impl From<OwnedFd> for PipeWriterAvailable on (Unix or HermitCore or target_os=trusty or WASI or target_os=motor) and non-target_os=trusty only.
fn from(owned_fd: OwnedFd) -> Self
impl From<OwnedHandle> for PipeWriterAvailable on Windows only.
fn from(owned_handle: OwnedHandle) -> Self
impl From<PipeWriter> for OwnedFdAvailable on (Unix or HermitCore or target_os=trusty or WASI or target_os=motor) and non-target_os=trusty only.
fn from(pipe: PipeWriter) -> Self
impl From<PipeWriter> for OwnedHandleAvailable on Windows only.
fn from(pipe: PipeWriter) -> Self
impl From<PipeWriter> for Stdio
fn from(pipe: PipeWriter) -> Self
impl FromRawFd for PipeWriterAvailable on (Unix or HermitCore or target_os=trusty or WASI or target_os=motor) and non-target_os=trusty only.
unsafe fn from_raw_fd(raw_fd: RawFd) -> Self
Self from the given raw file descriptor. Read more
impl FromRawHandle for PipeWriterAvailable on Windows only.
unsafe fn from_raw_handle(raw_handle: RawHandle) -> Self
impl IntoRawFd for PipeWriterAvailable on (Unix or HermitCore or target_os=trusty or WASI or target_os=motor) and non-target_os=trusty only.
fn into_raw_fd(self) -> RawFd
impl IntoRawHandle for PipeWriterAvailable on Windows only.
fn into_raw_handle(self) -> RawHandle
impl Write for &PipeWriter
fn write(&mut self, buf: &[u8]) -> Result<usize>
fn flush(&mut self) -> Result<()>
fn write_vectored(&mut self, bufs: &[IoSlice<'_>]) -> Result<usize>
fn is_write_vectored(&self) -> bool
can_vector #69941)
fn write_all(&mut self, buf: &[u8]) -> Result<()>
fn write_all_vectored(&mut self, bufs: &mut [IoSlice<'_>]) -> Result<()>
write_all_vectored #70436)
fn write_fmt(&mut self, args: Arguments<'_>) -> Result<()>
fn by_ref(&mut self) -> &mut Selfwhere
Self: Sized,Write. Read more
impl Write for PipeWriter
fn write(&mut self, buf: &[u8]) -> Result<usize>
fn flush(&mut self) -> Result<()>
fn write_vectored(&mut self, bufs: &[IoSlice<'_>]) -> Result<usize>
fn is_write_vectored(&self) -> bool
can_vector #69941)
fn write_all(&mut self, buf: &[u8]) -> Result<()>
fn write_all_vectored(&mut self, bufs: &mut [IoSlice<'_>]) -> Result<()>
write_all_vectored #70436)
fn write_fmt(&mut self, args: Arguments<'_>) -> Result<()>
fn by_ref(&mut self) -> &mut Selfwhere
Self: Sized,Write. Read more
impl Freeze for PipeWriter
impl RefUnwindSafe for PipeWriter
impl Send for PipeWriter
impl Sync for PipeWriter
impl Unpin for PipeWriter
impl UnwindSafe for PipeWriter
impl<T> Any for Twhere
T: 'static + ?Sized,impl<T> Borrow<T> for Twhere
T: ?Sized,impl<T> BorrowMut<T> for Twhere
T: ?Sized,impl<T> From<T> for T
fn from(t: T) -> T
Returns the argument unchanged.
impl<T, U> Into<U> for Twhere
U: From<T>,fn into(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<U> for Twhere
U: Into<T>,type Error = Infallible
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
impl<T, U> TryInto<U> for Twhere
U: TryFrom<T>,
© 2010 The Rust Project Developers
Licensed under the Apache License, Version 2.0 or the MIT license, at your option.
https://doc.rust-lang.org/std/io/struct.PipeWriter.html