pub struct ChildStdin {
inner: FileDesc,
}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.
Fields§
§inner: FileDescTrait Implementations§
1.63.0 · Source§impl AsFd for ChildStdin
Available on non-Hermit and (Unix) and not ((WebAssembly and non-WASI, or Fortanix and SGX)) only.
impl AsFd for ChildStdin
Available on non-Hermit and (Unix) and not ((WebAssembly and non-WASI, or Fortanix and SGX)) only.
Source§fn as_fd(&self) -> BorrowedFd<'_>
fn as_fd(&self) -> BorrowedFd<'_>
Available on Unix or Hermit or Trusty or WASI or Motor OS only.
Borrows the file descriptor. Read more
1.2.0 · Source§impl AsRawFd for ChildStdin
Available on non-Hermit and (Unix) and not ((WebAssembly and non-WASI, or Fortanix and SGX)) only.
impl AsRawFd for ChildStdin
Available on non-Hermit and (Unix) and not ((WebAssembly and non-WASI, or Fortanix and SGX)) only.
Source§impl CopyWrite for ChildStdin
impl CopyWrite for ChildStdin
Source§fn properties(&self) -> CopyParams
fn properties(&self) -> CopyParams
Extracts the file descriptor and hints/metadata, delegating through wrappers if necessary.
1.16.0 · Source§impl Debug for ChildStdin
impl Debug for ChildStdin
1.63.0 · Source§impl From<ChildStdin> for OwnedFd
Available on non-Hermit and (Unix) and not ((WebAssembly and non-WASI, or Fortanix and SGX)) only.
impl From<ChildStdin> for OwnedFd
Available on non-Hermit and (Unix) and not ((WebAssembly and non-WASI, or Fortanix and SGX)) only.
Source§fn from(child_stdin: ChildStdin) -> OwnedFd
fn from(child_stdin: ChildStdin) -> OwnedFd
Takes ownership of a ChildStdin’s file descriptor.
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 console1.74.0 · Source§impl From<OwnedFd> for ChildStdin
Available on non-Hermit and (Unix) and not ((WebAssembly and non-WASI, or Fortanix and SGX)) only.Creates a ChildStdin from the provided OwnedFd.
impl From<OwnedFd> for ChildStdin
Available on non-Hermit and (Unix) and not ((WebAssembly and non-WASI, or Fortanix and SGX)) only.
Creates a ChildStdin from the provided OwnedFd.
The provided file descriptor must point to a pipe
with the CLOEXEC flag set.
Source§impl FromInner<FileDesc> for ChildStdin
impl FromInner<FileDesc> for ChildStdin
fn from_inner(pipe: FileDesc) -> ChildStdin ⓘ
Source§impl IntoInner<FileDesc> for ChildStdin
impl IntoInner<FileDesc> for ChildStdin
fn into_inner(self) -> FileDesc ⓘ
1.4.0 · Source§impl IntoRawFd for ChildStdin
Available on non-Hermit and (Unix) and not ((WebAssembly and non-WASI, or Fortanix and SGX)) only.
impl IntoRawFd for ChildStdin
Available on non-Hermit and (Unix) and not ((WebAssembly and non-WASI, or Fortanix and SGX)) only.
Source§fn into_raw_fd(self) -> RawFd
fn into_raw_fd(self) -> RawFd
Available on Unix or Hermit or Trusty or WASI or Motor OS only.
Consumes this object, returning the raw underlying file descriptor. Read more
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>
Writes a buffer into this writer, returning how many bytes were written. Read more
Source§fn is_write_vectored(&self) -> bool
fn is_write_vectored(&self) -> bool
🔬This is a nightly-only experimental API. (
can_vector #69941)Source§fn flush(&mut self) -> Result<()>
fn flush(&mut self) -> Result<()>
Flushes this output stream, ensuring that all intermediately buffered
contents reach their destination. Read more
1.0.0 · Source§fn write_all(&mut self, buf: &[u8]) -> Result<()>
fn write_all(&mut self, buf: &[u8]) -> Result<()>
Attempts to write an entire buffer into this writer. Read more
Source§fn write_all_vectored(&mut self, bufs: &mut [IoSlice<'_>]) -> Result<()>
fn write_all_vectored(&mut self, bufs: &mut [IoSlice<'_>]) -> Result<()>
🔬This is a nightly-only experimental API. (
write_all_vectored #70436)Attempts to write multiple buffers into this writer. Read more
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>
Writes a buffer into this writer, returning how many bytes were written. Read more
Source§fn is_write_vectored(&self) -> bool
fn is_write_vectored(&self) -> bool
🔬This is a nightly-only experimental API. (
can_vector #69941)Source§fn flush(&mut self) -> Result<()>
fn flush(&mut self) -> Result<()>
Flushes this output stream, ensuring that all intermediately buffered
contents reach their destination. Read more
1.0.0 · Source§fn write_all(&mut self, buf: &[u8]) -> Result<()>
fn write_all(&mut self, buf: &[u8]) -> Result<()>
Attempts to write an entire buffer into this writer. Read more
Source§fn write_all_vectored(&mut self, bufs: &mut [IoSlice<'_>]) -> Result<()>
fn write_all_vectored(&mut self, bufs: &mut [IoSlice<'_>]) -> Result<()>
🔬This is a nightly-only experimental API. (
write_all_vectored #70436)Attempts to write multiple buffers into this writer. Read more
Auto Trait Implementations§
impl Freeze for ChildStdin
impl RefUnwindSafe for ChildStdin
impl Send for ChildStdin
impl Sync for ChildStdin
impl Unpin for ChildStdin
impl UnsafeUnpin for ChildStdin
impl UnwindSafe for ChildStdin
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> SizedTypeProperties for T
impl<T> SizedTypeProperties for T
Source§#[doc(hidden)]const SIZE: usize = _
#[doc(hidden)]const SIZE: usize = _
🔬This is a nightly-only experimental API. (
sized_type_properties)Source§#[doc(hidden)]const ALIGN: usize = _
#[doc(hidden)]const ALIGN: usize = _
🔬This is a nightly-only experimental API. (
sized_type_properties)Source§#[doc(hidden)]const ALIGNMENT: Alignment = _
#[doc(hidden)]const ALIGNMENT: Alignment = _
🔬This is a nightly-only experimental API. (
ptr_alignment_type #102070)Source§#[doc(hidden)]const IS_ZST: bool = _
#[doc(hidden)]const IS_ZST: bool = _
🔬This is a nightly-only experimental API. (
sized_type_properties)Source§#[doc(hidden)]const LAYOUT: Layout = _
#[doc(hidden)]const LAYOUT: Layout = _
🔬This is a nightly-only experimental API. (
sized_type_properties)Source§#[doc(hidden)]const MAX_SLICE_LEN: usize = _
#[doc(hidden)]const MAX_SLICE_LEN: usize = _
🔬This is a nightly-only experimental API. (
sized_type_properties)The largest safe length for a
[Self]. Read more