[][src]Struct cargo::util::process_builder::ProcessBuilder

pub struct ProcessBuilder { /* fields omitted */ }

A builder object for an external process, similar to std::process::Command.

Methods

impl ProcessBuilder[src]

pub fn program<T: AsRef<OsStr>>(&mut self, program: T) -> &mut ProcessBuilder[src]

(chainable) Set the executable for the process.

pub fn arg<T: AsRef<OsStr>>(&mut self, arg: T) -> &mut ProcessBuilder[src]

(chainable) Add an arg to the args list.

pub fn args<T: AsRef<OsStr>>(&mut self, arguments: &[T]) -> &mut ProcessBuilder[src]

(chainable) Add many args to the args list.

pub fn args_replace<T: AsRef<OsStr>>(
    &mut self,
    arguments: &[T]
) -> &mut ProcessBuilder
[src]

(chainable) Replace args with new args list

pub fn cwd<T: AsRef<OsStr>>(&mut self, path: T) -> &mut ProcessBuilder[src]

(chainable) Set the current working directory of the process

pub fn env<T: AsRef<OsStr>>(&mut self, key: &str, val: T) -> &mut ProcessBuilder[src]

(chainable) Set an environment variable for the process.

pub fn env_remove(&mut self, key: &str) -> &mut ProcessBuilder[src]

(chainable) Unset an environment variable for the process.

pub fn get_program(&self) -> &OsString[src]

Get the executable name.

pub fn get_args(&self) -> &[OsString][src]

Get the program arguments

pub fn get_cwd(&self) -> Option<&Path>[src]

Get the current working directory for the process

pub fn get_env(&self, var: &str) -> Option<OsString>[src]

Get an environment variable as the process will see it (will inherit from environment unless explicitally unset).

pub fn get_envs(&self) -> &HashMap<String, Option<OsString>>[src]

Get all environment variables explicitly set or unset for the process (not inherited vars).

pub fn inherit_jobserver(&mut self, jobserver: &Client) -> &mut Self[src]

Set the make jobserver. See the jobserver crate for more information.

pub fn display_env_vars(&mut self) -> &mut Self[src]

Enable environment variable display

pub fn exec(&self) -> CargoResult<()>[src]

Run the process, waiting for completion, and mapping non-success exit codes to an error.

pub fn exec_replace(&self) -> CargoResult<()>[src]

Replaces the current process with the target process.

On Unix, this executes the process using the unix syscall execvp, which will block this process, and will only return if there is an error.

On Windows this isn't technically possible. Instead we emulate it to the best of our ability. One aspect we fix here is that we specify a handler for the ctrl-c handler. In doing so (and by effectively ignoring it) we should emulate proxying ctrl-c handling to the application at hand, which will either terminate or handle it itself. According to microsoft's documentation at: https://docs.microsoft.com/en-us/windows/console/ctrl-c-and-ctrl-break-signals the ctrl-c signal is sent to all processes attached to a terminal, which should include our child process. If the child terminates then we'll reap them in Cargo pretty quickly, and if the child handles the signal then we won't terminate (and we shouldn't!) until the process itself later exits.

pub fn exec_with_output(&self) -> CargoResult<Output>[src]

Execute the process, returning the stdio output, or an error if non-zero exit status.

pub fn exec_with_streaming(
    &self,
    on_stdout_line: &mut dyn FnMut(&str) -> CargoResult<()>,
    on_stderr_line: &mut dyn FnMut(&str) -> CargoResult<()>,
    capture_output: bool
) -> CargoResult<Output>
[src]

Execute a command, passing each line of stdout and stderr to the supplied callbacks, which can mutate the string data.

If any invocations of these function return an error, it will be propagated.

Optionally, output can be passed to errors using print_output

pub fn build_command(&self) -> Command[src]

Converts ProcessBuilder into a std::process::Command, and handles the jobserver if present.

Trait Implementations

impl Clone for ProcessBuilder[src]

fn clone_from(&mut self, source: &Self)
1.0.0
[src]

Performs copy-assignment from source. Read more

impl Display for ProcessBuilder[src]

impl Debug for ProcessBuilder[src]

Auto Trait Implementations

Blanket Implementations

impl<T, U> Into for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

impl<T> ToString for T where
    T: Display + ?Sized
[src]

impl<T> From for T[src]

impl<T, U> TryFrom for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T> Borrow for T where
    T: ?Sized
[src]

impl<T> BorrowMut for T where
    T: ?Sized
[src]

impl<T, U> TryInto for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Same for T

type Output = T

Should always be Self