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§
Sourcefn current_dir<P: AsRef<Path>>(self, dir: P) -> Self
fn current_dir<P: AsRef<Path>>(self, dir: P) -> Self
设置命令的工作目录
Sourcefn creation_flags(self, flags: u32) -> Self
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".
Implementations on Foreign Types§
Source§impl CommandTrait for Command
impl CommandTrait for Command
fn arg<S: AsRef<OsStr>>(self, arg: S) -> Self
fn args<I, S>(self, args: I) -> Self
fn envs<I, K, V>(self, vars: I) -> Self
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
Source§impl CommandTrait for Command
Available on crate feature tokio only.
impl CommandTrait for Command
Available on crate feature
tokio only.