Struct PipeWriter

pub struct PipeWriter(pub(crate) FileDesc);

Write end of an anonymous pipe.

Fields

0: FileDesc

Implementations

impl PipeWriter

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

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

Examples

# 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(())
# }

Trait Implementations

impl AsFd for PipeWriter

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

impl AsHandle for PipeWriter

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

impl AsRawFd for PipeWriter

fn as_raw_fd(&self) -> RawFd

impl AsRawHandle for PipeWriter

fn as_raw_handle(&self) -> RawHandle

impl CopyWrite for PipeWriter

fn properties(&self) -> CopyParams

impl Debug for PipeWriter

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

impl From<OwnedFd> for PipeWriter

fn from(owned_fd: OwnedFd) -> Self

impl From<OwnedHandle> for PipeWriter

fn from(owned_handle: OwnedHandle) -> Self

impl FromInner<FileDesc> for PipeWriter

fn from_inner(inner: FileDesc) -> 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 IntoInner<FileDesc> for PipeWriter

fn into_inner(self) -> FileDesc

impl IntoRawFd for PipeWriter

fn into_raw_fd(self) -> RawFd

impl IntoRawHandle for PipeWriter

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

Auto Trait Implementations

impl Freeze for PipeWriter

impl RefUnwindSafe for PipeWriter

impl Send for PipeWriter

impl Sync for PipeWriter

impl Unpin for PipeWriter

impl UnsafeUnpin for PipeWriter

impl UnwindSafe for PipeWriter

Blanket Implementations

impl<T> Any for PipeWriter where T: 'static + ?Sized,

fn type_id(&self) -> TypeId

impl<T> Borrow<T> for PipeWriter where T: ?Sized,

fn borrow(&self) -> &T

impl<T> BorrowMut<T> for PipeWriter where T: ?Sized,

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

impl<T> From<T> for PipeWriter

fn from(t: T) -> T

Returns the argument unchanged.

impl<T> SizeHint for PipeWriter where T: ?Sized,

fn lower_bound(&self) -> usize
fn upper_bound(&self) -> Option<usize>

impl<T> SizedTypeProperties for PipeWriter

impl<T, U> Into<U> for PipeWriter where 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 PipeWriter where U: Into<T>,

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

impl<T, U> TryInto<U> for PipeWriter where U: TryFrom<T>,

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