pub struct SubProcOperation { /* private fields */ }
Expand description

This structure represents a single command to run as a sub-process, the command’s arguments, and the input and output files for that sub-process. The structure itself is public but the fields are private (i.e. implementation specific); the impl section below defines the visible operations that can be performed on this structure.

Implementations§

source§

impl SubProcOperation

source

pub fn new(executing: &Executable) -> SubProcOperation

This is the primary method of initializing a SubProcOperation.

source

pub fn set_executable<T>(&mut self, exe: T) -> &mut Selfwhere T: Into<PathBuf>,

Changes the name of the command to execute.

source

pub fn clear_env(&mut self) -> &mut Self

Clears all environment variable settings for the environment in which this operation executes. Any previous environment variable settings are discarded.

By default, the current environment is inherited by the operation.

source

pub fn set_env<N, V>(&mut self, var_name: N, var_value: V) -> &mut Selfwhere N: Into<String>, V: Into<String>,

Specifies an environment variable value to be set in the environment for executing this operation. This can be used multiple times to set multiple environment variables; subsequent settings of the same variable will override previous settings.

The first argument is the environment variable name and the second argument is the value to set for that variable.

source

pub fn prepend_env<N, V, S>(&mut self, var: N, value: V, sep: S) -> &mut Selfwhere N: Into<String>, V: Into<String>, S: Into<String>,

Extends the operations environment by prepending a value to an environment variable. If the environment variable was not previously set, this becomes the new value for that variable. This can be used multiple times to extend the environment variable with multiple values.

The first argument is the environment variable name and the second argument is the value to prepend to that variable, and the third value is the separator between the prepended value and the existing value.

source

pub fn append_env<N, V, S>(&mut self, var: N, value: V, sep: S) -> &mut Selfwhere N: Into<String>, V: Into<String>, S: Into<String>,

Extends the operations environment by appending a value to an environment variable. If the environment variable was not previously set, this becomes the new value for that variable. This can be used multiple times to extend the environment variable with multiple values.

The first argument is the environment variable name and the second argument is the value to append to that variable, and the third value is the separator between the appended value and the existing value.

source

pub fn unset_env<N>(&mut self, var_name: N) -> &mut Selfwhere N: Into<String>,

Removes the specified environment variable from the environment in which the operation executes. Has no effect but does not fail if the environment variable does not exist.

source

pub fn push_arg<T>(&mut self, arg: T) -> &mut Selfwhere T: Into<OsString>,

Adds an argument to use when executing the operation. This can, for example, be used for specifying command-line option arguments when running a subprocess Executable operation. Each operation type and instance can determine how it will handle any specified arguments.

Trait Implementations§

source§

impl Clone for SubProcOperation

source§

fn clone(&self) -> SubProcOperation

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl Debug for SubProcOperation

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl FilesPrep for SubProcOperation

source§

fn set_dir<T>(&mut self, tgtdir: T) -> &mut Selfwhere T: AsRef<Path>,

Sets the directory from which the operation will be performed. The caller is responsible for ensuring any FileArg::Loc paths are valid when operating from that directory. This directory is usually a relative directory and is interpreted from the current working directory or the directory provided to the OpInterface::execute method.
source§

fn set_input_file(&mut self, fname: &FileArg) -> &mut Self

Sets the input file for the operation, overriding any previous input file specification.
source§

fn add_input_file(&mut self, fname: &FileArg) -> &mut Self

Appends the additional input file to the list of input files for this operation.
source§

fn has_input_file(&self) -> bool

Returns true if one or more input files have been specified for this operation.
source§

fn set_output_file(&mut self, fname: &FileArg) -> &mut Self

Sets the output file for the command, overriding any previous output file specification.
source§

fn has_explicit_output_file(&self) -> bool

Returns true if the output file has been explicitly specified as a location (instead of being a TBD, a Glob match, or a Temp file).
source§

impl OpInterface for SubProcOperation

source§

fn label(&self) -> String

Returns a short identifier of this operation, usually used for user-presented identification purposes.
source§

fn set_label(&mut self, new_label: &str) -> &mut Self

Allows the label for an operation to be updated. The label is usually used for user-presentation identification purposes.
source§

fn execute<Exec, P>( &mut self, executor: &Exec, cwd: &Option<P> ) -> Result<ActualFile>where P: AsRef<Path>, Exec: OsRun,

Executes this command in a subprocess in the specified directory (via the OsRun execution provided). The input and output files will be determined and added to the command-line as indicated by their NamedFile values. The successful result specifies the output file written (if any). Read more
source§

fn execute_here(&mut self, executor: &impl OsRun) -> Result<ActualFile>

Convenience method to execute an operation with a given crate::Executor in the current directory.

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for Twhere U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> ToOwned for Twhere T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T, U> TryFrom<U> for Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere U: TryFrom<T>,

§

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

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.