e_utils::system::cmd

Trait CommandTrait

Source
pub trait CommandTrait<Target = Command> {
    // Required methods
    fn arg<S: AsRef<OsStr>>(self, arg: S) -> Self;
    fn args<I, S>(self, args: I) -> Self
       where I: IntoIterator<Item = S>,
             S: AsRef<OsStr>;
    fn envs<I, K, V>(self, vars: I) -> Self
       where I: IntoIterator<Item = (K, V)>,
             K: AsRef<OsStr>,
             V: AsRef<OsStr>;
    fn current_dir<P: AsRef<Path>>(self, dir: P) -> Self;
    fn stdin<T: Into<Stdio>>(self, cfg: T) -> Self;
    fn stdout<T: Into<Stdio>>(self, cfg: T) -> Self;
    fn stderr<T: Into<Stdio>>(self, cfg: T) -> Self;
    fn creation_flags(self, flags: u32) -> Self;
}
Expand description

统一 Command 和 tokio::process::Command 接口的 trait 这个 trait 定义了一组通用的命令配置方法,使得 std::process::Command 和 tokio::process::Command 可以使用相同的接口进行操作。

Required Methods§

Source

fn arg<S: AsRef<OsStr>>(self, arg: S) -> Self

添加单个命令行参数

Source

fn args<I, S>(self, args: I) -> Self
where I: IntoIterator<Item = S>, S: AsRef<OsStr>,

添加多个命令行参数

Source

fn envs<I, K, V>(self, vars: I) -> Self
where I: IntoIterator<Item = (K, V)>, K: AsRef<OsStr>, V: AsRef<OsStr>,

设置环境变量

Source

fn current_dir<P: AsRef<Path>>(self, dir: P) -> Self

设置命令的工作目录

Source

fn stdin<T: Into<Stdio>>(self, cfg: T) -> Self

配置命令的标准输入

Source

fn stdout<T: Into<Stdio>>(self, cfg: T) -> Self

配置命令的标准输出

Source

fn stderr<T: Into<Stdio>>(self, cfg: T) -> Self

配置命令的标准错误输出

Source

fn creation_flags(self, flags: u32) -> Self

设置进程创建标志(主要用于 Windows 系统)

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementations on Foreign Types§

Source§

impl CommandTrait for Command

Source§

fn arg<S: AsRef<OsStr>>(self, arg: S) -> Self

Source§

fn args<I, S>(self, args: I) -> Self
where I: IntoIterator<Item = S>, S: AsRef<OsStr>,

Source§

fn envs<I, K, V>(self, vars: I) -> Self
where I: IntoIterator<Item = (K, V)>, K: AsRef<OsStr>, V: AsRef<OsStr>,

Source§

fn current_dir<P: AsRef<Path>>(self, dir: P) -> Self

Source§

fn stdin<T: Into<Stdio>>(self, cfg: T) -> Self

Source§

fn stdout<T: Into<Stdio>>(self, cfg: T) -> Self

Source§

fn stderr<T: Into<Stdio>>(self, cfg: T) -> Self

Source§

fn creation_flags(self, flags: u32) -> Self

Source§

impl CommandTrait for Command

Source§

fn arg<S: AsRef<OsStr>>(self, arg: S) -> Self

Source§

fn args<I, S>(self, args: I) -> Self
where I: IntoIterator<Item = S>, S: AsRef<OsStr>,

Source§

fn envs<I, K, V>(self, vars: I) -> Self
where I: IntoIterator<Item = (K, V)>, K: AsRef<OsStr>, V: AsRef<OsStr>,

Source§

fn current_dir<P: AsRef<Path>>(self, dir: P) -> Self

Source§

fn stdin<T: Into<Stdio>>(self, cfg: T) -> Self

Source§

fn stdout<T: Into<Stdio>>(self, cfg: T) -> Self

Source§

fn stderr<T: Into<Stdio>>(self, cfg: T) -> Self

Source§

fn creation_flags(self, flags: u32) -> Self

Implementors§