On this page
Struct std::process::ChildStderr
pub struct ChildStderr { /* private fields */ }
A handle to a child process’s stderr.
This struct is used in the stderr
field on Child
.
When an instance of ChildStderr
is dropped, the ChildStderr
’s underlying file handle will be closed.
Trait Implementations
impl AsFd for ChildStderrAvailable on Unix only.
impl AsHandle for ChildStderrAvailable on Windows only.
impl AsRawFd for ChildStderrAvailable on Unix only.
impl AsRawHandle for ChildStderrAvailable on Windows only.
impl Debug for ChildStderr
fn fmt(&self, f: &mut Formatter<'_>) -> Result
impl From<ChildStderr> for OwnedFdAvailable on Unix only.
fn from(child_stderr: ChildStderr) -> OwnedFd
impl From<ChildStderr> for OwnedHandleAvailable on Windows only.
fn from(child_stderr: ChildStderr) -> OwnedHandle
impl From<ChildStderr> for Stdio
fn from(child: ChildStderr) -> Stdio
Converts a ChildStderr
into a Stdio
.
Examples
use std::process::{Command, Stdio};
let reverse = Command::new("rev")
.arg("non_existing_file.txt")
.stderr(Stdio::piped())
.spawn()
.expect("failed reverse command");
let cat = Command::new("cat")
.arg("-")
.stdin(reverse.stderr.unwrap()) // Converted into a Stdio here
.output()
.expect("failed echo command");
assert_eq!(
String::from_utf8_lossy(&cat.stdout),
"rev: cannot open non_existing_file.txt: No such file or directory\n"
);
impl From<OwnedFd> for ChildStderrAvailable on Unix only.
Create a ChildStderr
from the provided OwnedFd
.
The provided file descriptor must point to a pipe with the CLOEXEC
flag set.
fn from(fd: OwnedFd) -> ChildStderr ⓘ
impl From<OwnedHandle> for ChildStderrAvailable on Windows only.
Create a ChildStderr
from the provided OwnedHandle
.
The provided handle must be asynchronous, as reading and writing from and to it is implemented using asynchronous APIs.
fn from(handle: OwnedHandle) -> ChildStderr ⓘ
impl IntoRawFd for ChildStderrAvailable on Unix only.
fn into_raw_fd(self) -> RawFd
impl IntoRawHandle for ChildStderrAvailable on Windows only.
fn into_raw_handle(self) -> RawHandle
impl Read for ChildStderr
fn read(&mut self, buf: &mut [u8]) -> Result<usize>
fn read_buf(&mut self, buf: BorrowedCursor<'_>) -> Result<()>
read_buf
#78485)
fn read_vectored(&mut self, bufs: &mut [IoSliceMut<'_>]) -> Result<usize>
read
, except that it reads into a slice of buffers. Read more
fn is_read_vectored(&self) -> bool
can_vector
#69941)
fn read_to_end(&mut self, buf: &mut Vec<u8>) -> Result<usize>
buf
. Read more
fn read_to_string(&mut self, buf: &mut String) -> Result<usize>
buf
. Read more
fn read_exact(&mut self, buf: &mut [u8]) -> Result<()>
buf
. Read more
fn read_buf_exact(&mut self, cursor: BorrowedCursor<'_>) -> Result<()>
read_buf
#78485)
cursor
. Read more
fn by_ref(&mut self) -> &mut Self
where
Self: Sized,
Read
. Read more
fn bytes(self) -> Bytes<Self> ⓘ
where
Self: Sized,
fn chain<R: Read>(self, next: R) -> Chain<Self, R> ⓘ
where
Self: Sized,
fn take(self, limit: u64) -> Take<Self> ⓘ
where
Self: Sized,
limit
bytes from it. Read more
Auto Trait Implementations
impl RefUnwindSafe for ChildStderr
impl Send for ChildStderr
impl Sync for ChildStderr
impl Unpin for ChildStderr
impl UnwindSafe for ChildStderr
Blanket Implementations
impl<T> Any for T
where
T: 'static + ?Sized,
impl<T> Borrow<T> for T
where
T: ?Sized,
impl<T> BorrowMut<T> for T
where
T: ?Sized,
impl<T> From<T> for T
fn from(t: T) -> T
Returns the argument unchanged.
impl<T, U> Into<U> for T
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 T
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 T
where
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
© 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/process/struct.ChildStderr.html