On this page
Struct std::process::ChildStdin
pub struct ChildStdin { /* private fields */ }
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
impl AsFd for ChildStdinAvailable on Unix only.
impl AsHandle for ChildStdinAvailable on Windows only.
impl AsRawFd for ChildStdinAvailable on Unix only.
impl AsRawHandle for ChildStdinAvailable on Windows only.
impl Debug for ChildStdin
fn fmt(&self, f: &mut Formatter<'_>) -> Result
impl From<ChildStdin> for OwnedFdAvailable on Unix only.
fn from(child_stdin: ChildStdin) -> OwnedFd
impl From<ChildStdin> for OwnedHandleAvailable on Windows only.
fn from(child_stdin: ChildStdin) -> OwnedHandle
impl From<ChildStdin> for 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
impl From<OwnedFd> for ChildStdinAvailable on Unix only.
Create a ChildStdin
from the provided OwnedFd
.
The provided file descriptor must point to a pipe with the CLOEXEC
flag set.
fn from(fd: OwnedFd) -> ChildStdin ⓘ
impl From<OwnedHandle> for ChildStdinAvailable on Windows only.
Create 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.
fn from(handle: OwnedHandle) -> ChildStdin ⓘ
impl IntoRawFd for ChildStdinAvailable on Unix only.
fn into_raw_fd(self) -> RawFd
impl IntoRawHandle for ChildStdinAvailable on Windows only.
fn into_raw_handle(self) -> RawHandle
impl Write for &ChildStdin
fn write(&mut self, buf: &[u8]) -> Result<usize>
fn write_vectored(&mut self, bufs: &[IoSlice<'_>]) -> Result<usize>
fn is_write_vectored(&self) -> bool
can_vector
#69941)
fn flush(&mut self) -> Result<()>
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, fmt: Arguments<'_>) -> Result<()>
fn by_ref(&mut self) -> &mut Self
where
Self: Sized,
Write
. Read more
impl Write for ChildStdin
fn write(&mut self, buf: &[u8]) -> Result<usize>
fn write_vectored(&mut self, bufs: &[IoSlice<'_>]) -> Result<usize>
fn is_write_vectored(&self) -> bool
can_vector
#69941)
fn flush(&mut self) -> Result<()>
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, fmt: Arguments<'_>) -> Result<()>
fn by_ref(&mut self) -> &mut Self
where
Self: Sized,
Write
. Read more
Auto Trait Implementations
impl RefUnwindSafe for ChildStdin
impl Send for ChildStdin
impl Sync for ChildStdin
impl Unpin for ChildStdin
impl UnwindSafe for ChildStdin
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.ChildStdin.html