pub struct ChildStdin { /* private fields */ }
Expand description
A handle to a child process’s standard input (stdin).
This struct is used in the stdin
field on Child
.
When an instance of ChildStdin
is dropped, the ChildStdin
’s underlying
file handle will be closed. If the child process was blocked on input prior
to being dropped, it will become unblocked after dropping.
Trait Implementations§
1.63.0 · source§impl AsFd for ChildStdin
Available on Unix only.
impl AsFd for ChildStdin
source§fn as_fd(&self) -> BorrowedFd<'_>
fn as_fd(&self) -> BorrowedFd<'_>
1.63.0 · source§impl AsHandle for ChildStdin
Available on Windows only.
impl AsHandle for ChildStdin
source§fn as_handle(&self) -> BorrowedHandle<'_>
fn as_handle(&self) -> BorrowedHandle<'_>
1.2.0 · source§impl AsRawFd for ChildStdin
Available on Unix only.
impl AsRawFd for ChildStdin
1.2.0 · source§impl AsRawHandle for ChildStdin
Available on Windows only.
impl AsRawHandle for ChildStdin
source§fn as_raw_handle(&self) -> RawHandle
fn as_raw_handle(&self) -> RawHandle
1.16.0 · source§impl Debug for ChildStdin
impl Debug for ChildStdin
1.63.0 · source§impl From<ChildStdin> for OwnedFd
Available on Unix only.
impl From<ChildStdin> for OwnedFd
source§fn from(child_stdin: ChildStdin) -> OwnedFd
fn from(child_stdin: ChildStdin) -> OwnedFd
Takes ownership of a ChildStdin
’s file descriptor.
1.63.0 · source§impl From<ChildStdin> for OwnedHandle
Available on Windows only.
impl From<ChildStdin> for OwnedHandle
source§fn from(child_stdin: ChildStdin) -> OwnedHandle
fn from(child_stdin: ChildStdin) -> OwnedHandle
Takes ownership of a ChildStdin
’s file handle.
1.20.0 · source§impl From<ChildStdin> for Stdio
impl From<ChildStdin> for Stdio
source§fn from(child: ChildStdin) -> Stdio
fn from(child: ChildStdin) -> Stdio
Converts a ChildStdin
into a Stdio
.
§Examples
ChildStdin
will be converted to Stdio
using Stdio::from
under the hood.
use std::process::{Command, Stdio};
let reverse = Command::new("rev")
.stdin(Stdio::piped())
.spawn()
.expect("failed reverse command");
let _echo = Command::new("echo")
.arg("Hello, world!")
.stdout(reverse.stdin.unwrap()) // Converted into a Stdio here
.output()
.expect("failed echo command");
// "!dlrow ,olleH" echoed to console
1.74.0 · source§impl From<OwnedFd> for ChildStdin
Available on Unix only.
impl From<OwnedFd> for ChildStdin
Creates a ChildStdin
from the provided OwnedFd
.
The provided file descriptor must point to a pipe
with the CLOEXEC
flag set.
1.74.0 · source§impl From<OwnedHandle> for ChildStdin
Available on Windows only.
impl From<OwnedHandle> for ChildStdin
Creates a ChildStdin
from the provided OwnedHandle
.
The provided handle must be asynchronous, as reading and writing from and to it is implemented using asynchronous APIs.
source§fn from(handle: OwnedHandle) -> ChildStdin ⓘ
fn from(handle: OwnedHandle) -> ChildStdin ⓘ
1.4.0 · source§impl IntoRawFd for ChildStdin
Available on Unix only.
impl IntoRawFd for ChildStdin
source§fn into_raw_fd(self) -> RawFd
fn into_raw_fd(self) -> RawFd
1.4.0 · source§impl IntoRawHandle for ChildStdin
Available on Windows only.
impl IntoRawHandle for ChildStdin
source§fn into_raw_handle(self) -> RawHandle
fn into_raw_handle(self) -> RawHandle
1.48.0 · source§impl Write for &ChildStdin
impl Write for &ChildStdin
source§fn write(&mut self, buf: &[u8]) -> Result<usize>
fn write(&mut self, buf: &[u8]) -> Result<usize>
source§fn is_write_vectored(&self) -> bool
fn is_write_vectored(&self) -> bool
can_vector
#69941)source§fn flush(&mut self) -> Result<()>
fn flush(&mut self) -> Result<()>
1.0.0 · source§fn write_all(&mut self, buf: &[u8]) -> Result<()>
fn write_all(&mut self, buf: &[u8]) -> Result<()>
source§fn write_all_vectored(&mut self, bufs: &mut [IoSlice<'_>]) -> Result<()>
fn write_all_vectored(&mut self, bufs: &mut [IoSlice<'_>]) -> Result<()>
write_all_vectored
#70436)1.0.0 · source§impl Write for ChildStdin
impl Write for ChildStdin
source§fn write(&mut self, buf: &[u8]) -> Result<usize>
fn write(&mut self, buf: &[u8]) -> Result<usize>
source§fn is_write_vectored(&self) -> bool
fn is_write_vectored(&self) -> bool
can_vector
#69941)source§fn flush(&mut self) -> Result<()>
fn flush(&mut self) -> Result<()>
1.0.0 · source§fn write_all(&mut self, buf: &[u8]) -> Result<()>
fn write_all(&mut self, buf: &[u8]) -> Result<()>
source§fn write_all_vectored(&mut self, bufs: &mut [IoSlice<'_>]) -> Result<()>
fn write_all_vectored(&mut self, bufs: &mut [IoSlice<'_>]) -> Result<()>
write_all_vectored
#70436)