Struct std::process::ChildStdin

1.0.0 · source ·
pub struct ChildStdin { /* private fields */ }
Expand description

子进程的标准输入 (stdin) 的句柄。

该结构体用于 Childstdin 字段中。

ChildStdin 的实例被 丢弃 时,ChildStdin 的底层文件句柄将关闭。 如果子进程在丢弃之前已在输入上被阻止,则子进程将在丢弃后变为未阻止状态。

Trait Implementations§

1.63.0 · source§

impl AsFd for ChildStdin

Available on Unix only.
source§

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

借用文件描述符。 Read more
1.63.0 · source§

impl AsHandle for ChildStdin

Available on Windows only.
source§

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

借用句柄。 Read more
1.2.0 · source§

impl AsRawFd for ChildStdin

Available on Unix only.
source§

fn as_raw_fd(&self) -> RawFd

提取原始文件描述符。 Read more
1.2.0 · source§

impl AsRawHandle for ChildStdin

Available on Windows only.
source§

fn as_raw_handle(&self) -> RawHandle

提取原始句柄。 Read more
1.16.0 · source§

impl Debug for ChildStdin

source§

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

使用给定的格式化程序格式化该值。 Read more
1.63.0 · source§

impl From<ChildStdin> for OwnedFd

Available on Unix only.
source§

fn from(child_stdin: ChildStdin) -> OwnedFd

从输入类型转换为此类型。
1.63.0 · source§

impl From<ChildStdin> for OwnedHandle

Available on Windows only.
source§

fn from(child_stdin: ChildStdin) -> OwnedHandle

从输入类型转换为此类型。
1.20.0 · source§

impl From<ChildStdin> for Stdio

source§

fn from(child: ChildStdin) -> Stdio

ChildStdin 转换为 Stdio

Examples

ChildStdin 将在引擎盖下使用 Stdio::from 转换为 Stdio

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()) // 在此处转换为 Stdio
    .output()
    .expect("failed echo command");

// "!dlrow ,olleH" 回显到控制台
Run
1.4.0 · source§

impl IntoRawFd for ChildStdin

Available on Unix only.
source§

fn into_raw_fd(self) -> RawFd

消费这个对象,返回原始的底层文件描述符。 Read more
1.4.0 · source§

impl IntoRawHandle for ChildStdin

Available on Windows only.
source§

fn into_raw_handle(self) -> RawHandle

消耗此对象,返回原始底层句柄。 Read more
1.48.0 · source§

impl Write for &ChildStdin

source§

fn write(&mut self, buf: &[u8]) -> Result<usize>

在此 writer 中写入一个缓冲区,返回写入的字节数。 Read more
source§

fn write_vectored(&mut self, bufs: &[IoSlice<'_>]) -> Result<usize>

类似于 write,不同之处在于它是从缓冲区切片中写入数据的。 Read more
source§

fn is_write_vectored(&self) -> bool

🔬This is a nightly-only experimental API. (can_vector #69941)
确定此 Writer 是否具有有效的 write_vectored 实现。 Read more
source§

fn flush(&mut self) -> Result<()>

刷新此输出流,确保所有中间缓冲的内容均到达其目的地。 Read more
source§

fn write_all(&mut self, buf: &[u8]) -> Result<()>

尝试将整个缓冲区写入此 writer。 Read more
source§

fn write_all_vectored(&mut self, bufs: &mut [IoSlice<'_>]) -> Result<()>

🔬This is a nightly-only experimental API. (write_all_vectored #70436)
尝试将多个缓冲区写入此 writer。 Read more
source§

fn write_fmt(&mut self, fmt: Arguments<'_>) -> Result<()>

将格式化的字符串写入此 writer,返回遇到的任何错误。 Read more
source§

fn by_ref(&mut self) -> &mut Selfwhere Self: Sized,

为这个 Write 实例创建一个 “by reference” 适配器。 Read more
source§

impl Write for ChildStdin

source§

fn write(&mut self, buf: &[u8]) -> Result<usize>

在此 writer 中写入一个缓冲区,返回写入的字节数。 Read more
source§

fn write_vectored(&mut self, bufs: &[IoSlice<'_>]) -> Result<usize>

类似于 write,不同之处在于它是从缓冲区切片中写入数据的。 Read more
source§

fn is_write_vectored(&self) -> bool

🔬This is a nightly-only experimental API. (can_vector #69941)
确定此 Writer 是否具有有效的 write_vectored 实现。 Read more
source§

fn flush(&mut self) -> Result<()>

刷新此输出流,确保所有中间缓冲的内容均到达其目的地。 Read more
source§

fn write_all(&mut self, buf: &[u8]) -> Result<()>

尝试将整个缓冲区写入此 writer。 Read more
source§

fn write_all_vectored(&mut self, bufs: &mut [IoSlice<'_>]) -> Result<()>

🔬This is a nightly-only experimental API. (write_all_vectored #70436)
尝试将多个缓冲区写入此 writer。 Read more
source§

fn write_fmt(&mut self, fmt: Arguments<'_>) -> Result<()>

将格式化的字符串写入此 writer,返回遇到的任何错误。 Read more
source§

fn by_ref(&mut self) -> &mut Selfwhere Self: Sized,

为这个 Write 实例创建一个 “by reference” 适配器。 Read more

Auto Trait Implementations§

Blanket Implementations§

source§

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

source§

fn type_id(&self) -> TypeId

获取 selfTypeIdRead more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

source§

fn borrow(&self) -> &T

从拥有的值中一成不变地借用。 Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

source§

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

从拥有的值中借用。 Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

返回未更改的参数。

source§

impl<T, U> Into<U> for Twhere U: From<T>,

source§

fn into(self) -> U

调用 U::from(self)

也就是说,这种转换是 From<T> for U 实现选择执行的任何操作。

source§

impl<T, U> TryFrom<U> for Twhere U: Into<T>,

§

type Error = Infallible

发生转换错误时返回的类型。
source§

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

执行转换。
source§

impl<T, U> TryInto<U> for Twhere U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

发生转换错误时返回的类型。
source§

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

执行转换。