Skip to main content

CommandExtra

Trait CommandExtra 

Source
pub trait CommandExtra: Sized {
    // Required methods
    fn with_current_dir(self, dir: impl AsRef<Path>) -> Self;
    fn with_env(self, key: impl AsRef<OsStr>, value: impl AsRef<OsStr>) -> Self;
    fn without_env(self, key: impl AsRef<OsStr>) -> Self;
    fn with_no_env(self) -> Self;
    fn with_arg(self, arg: impl AsRef<OsStr>) -> Self;
    fn with_stdin(self, stdio: Stdio) -> Self;
    fn with_stdout(self, stdio: Stdio) -> Self;
    fn with_stderr(self, stdio: Stdio) -> Self;

    // Provided methods
    fn with_args<Args>(self, args: Args) -> Self
       where Args: IntoIterator,
             Args::Item: AsRef<OsStr> { ... }
    fn with_envs<Envs, Key, Value>(self, envs: Envs) -> Self
       where Envs: IntoIterator<Item = (Key, Value)>,
             Key: AsRef<OsStr>,
             Value: AsRef<OsStr> { ... }
    fn without_envs<Keys>(self, keys: Keys) -> Self
       where Keys: IntoIterator,
             Keys::Item: AsRef<OsStr> { ... }
}
Expand description

Builder-style methods for Command that take self and return Self.

Required Methods§

Source

fn with_current_dir(self, dir: impl AsRef<Path>) -> Self

Sets the working directory.

Corresponds to Command::current_dir.

Source

fn with_env(self, key: impl AsRef<OsStr>, value: impl AsRef<OsStr>) -> Self

Sets an environment variable.

Corresponds to Command::env.

Source

fn without_env(self, key: impl AsRef<OsStr>) -> Self

Removes an environment variable.

Corresponds to Command::env_remove.

Source

fn with_no_env(self) -> Self

Clears all environment variables.

Corresponds to Command::env_clear.

Source

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

Adds one argument.

Corresponds to Command::arg.

Source

fn with_stdin(self, stdio: Stdio) -> Self

Configures stdin.

Corresponds to Command::stdin.

Source

fn with_stdout(self, stdio: Stdio) -> Self

Configures stdout.

Corresponds to Command::stdout.

Source

fn with_stderr(self, stdio: Stdio) -> Self

Configures stderr.

Corresponds to Command::stderr.

Provided Methods§

Source

fn with_args<Args>(self, args: Args) -> Self
where Args: IntoIterator, Args::Item: AsRef<OsStr>,

Adds multiple arguments.

Corresponds to Command::args.

Source

fn with_envs<Envs, Key, Value>(self, envs: Envs) -> Self
where Envs: IntoIterator<Item = (Key, Value)>, Key: AsRef<OsStr>, Value: AsRef<OsStr>,

Sets multiple environment variables.

Corresponds to Command::envs.

Source

fn without_envs<Keys>(self, keys: Keys) -> Self
where Keys: IntoIterator, Keys::Item: AsRef<OsStr>,

Removes multiple environment variables.

Equivalent to repeated Command::env_remove; no direct inherent method.

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 CommandExtra for Command

Source§

fn with_current_dir(self, dir: impl AsRef<Path>) -> Self

Source§

fn with_env(self, key: impl AsRef<OsStr>, value: impl AsRef<OsStr>) -> Self

Source§

fn without_env(self, key: impl AsRef<OsStr>) -> Self

Source§

fn with_no_env(self) -> Self

Source§

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

Source§

fn with_stdin(self, stdio: Stdio) -> Self

Source§

fn with_stdout(self, stdio: Stdio) -> Self

Source§

fn with_stderr(self, stdio: Stdio) -> Self

Implementors§