Struct cargo::util::process_builder::ProcessBuilder [−][src]
A builder object for an external process, similar to std::process::Command
.
Implementations
impl ProcessBuilder
[src]
pub fn program<T: AsRef<OsStr>>(&mut self, program: T) -> &mut ProcessBuilder
[src]
(chainable) Sets the executable for the process.
pub fn arg<T: AsRef<OsStr>>(&mut self, arg: T) -> &mut ProcessBuilder
[src]
(chainable) Adds arg
to the args list.
pub fn args<T: AsRef<OsStr>>(&mut self, args: &[T]) -> &mut ProcessBuilder
[src]
(chainable) Adds multiple args
to the args list.
pub fn args_replace<T: AsRef<OsStr>>(
&mut self,
args: &[T]
) -> &mut ProcessBuilder
[src]
&mut self,
args: &[T]
) -> &mut ProcessBuilder
(chainable) Replaces the args list with the given args
.
pub fn cwd<T: AsRef<OsStr>>(&mut self, path: T) -> &mut ProcessBuilder
[src]
(chainable) Sets the current working directory of the process.
pub fn env<T: AsRef<OsStr>>(&mut self, key: &str, val: T) -> &mut ProcessBuilder
[src]
(chainable) Sets an environment variable for the process.
pub fn env_remove(&mut self, key: &str) -> &mut ProcessBuilder
[src]
(chainable) Unsets an environment variable for the process.
pub fn get_program(&self) -> &OsString
[src]
Gets the executable name.
pub fn get_args(&self) -> &[OsString]
[src]
Gets the program arguments.
pub fn get_cwd(&self) -> Option<&Path>
[src]
Gets the current working directory for the process.
pub fn get_env(&self, var: &str) -> Option<OsString>
[src]
Gets 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]
Gets all environment variables explicitly set or unset for the process (not inherited vars).
pub fn inherit_jobserver(&mut self, jobserver: &Client) -> &mut Self
[src]
Sets the make
jobserver. See the jobserver crate for
more information.
pub fn display_env_vars(&mut self) -> &mut Self
[src]
Enables environment variable display.
pub fn exec(&self) -> CargoResult<()>
[src]
Runs 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]
Executes 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]
&self,
on_stdout_line: &mut dyn FnMut(&str) -> CargoResult<()>,
on_stderr_line: &mut dyn FnMut(&str) -> CargoResult<()>,
capture_output: bool
) -> CargoResult<Output>
Executes 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.
If capture_output
is true, then all the output will also be buffered
and stored in the returned Output
object. If it is false, no caching
is done, and the callbacks are solely responsible for handling the
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(&self) -> ProcessBuilder
[src]
pub fn clone_from(&mut self, source: &Self)
1.0.0[src]
impl Debug for ProcessBuilder
[src]
impl Display for ProcessBuilder
[src]
Auto Trait Implementations
impl RefUnwindSafe for ProcessBuilder
impl Send for ProcessBuilder
impl Sync for ProcessBuilder
impl Unpin for ProcessBuilder
impl UnwindSafe for ProcessBuilder
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> Same<T> for T
[src]
type Output = T
Should always be Self
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
pub fn to_owned(&self) -> T
[src]
pub fn clone_into(&self, target: &mut T)
[src]
impl<T> ToString for T where
T: Display + ?Sized,
[src]
T: Display + ?Sized,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
pub fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
[src]
V: MultiLane<T>,