Struct ExecSpecBuilder

Source
pub struct ExecSpecBuilder {
    pub working_dir: Option<PathBuf>,
    pub executable: Option<OsString>,
    pub clargs: Vec<OsString>,
    pub env: HashMap<String, String>,
    /* private fields */
}
Expand description

Builds exec specs

Fields§

§working_dir: Option<PathBuf>

The working directory to run the executable in

§executable: Option<OsString>

The executable

§clargs: Vec<OsString>

The command line args for the executable

§env: HashMap<String, String>

The environment variables for the executable. By default, the exec spec will inherit from the parent process.

§Warning

ONLY The environment variables in this map will be passed to the executable.

Implementations§

Source§

impl ExecSpecBuilder

Source

pub fn new() -> Self

Create a new ExecSpecBuilder.

Source

pub fn default_env() -> HashMap<String, String>

The default environment variables

Source

pub fn with_env<I: IntoIterator<Item = (String, String)>>( &mut self, env: I, ) -> &mut Self

Changes the environment variables to the contents of this map.

§Warning

This will clear all previously set values in the environment map

Source

pub fn extend_env<I: IntoIterator<Item = (String, String)>>( &mut self, env: I, ) -> &mut Self

Adds variables to the environment

Source

pub fn add_env<'a>( &mut self, env: &str, value: impl Into<Option<&'a str>>, ) -> &mut Self

Adds variables to the environment

Source

pub fn arg<S: AsRef<OsStr>>(&mut self, arg: S) -> &mut Self

Add an arg to the command

Source

pub fn args<I, S: AsRef<OsStr>>(&mut self, args: I) -> &mut Self
where I: IntoIterator<Item = S>,

Add many args to the command

Source

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

Add an arg to the command

Source

pub fn with_args<I, S: AsRef<OsStr>>(self, args: I) -> Self
where I: IntoIterator<Item = S>,

Add many args to the command

Source

pub fn exec<E: AsRef<OsStr>>(&mut self, exec: E) -> &mut Self

Set the executable for the exec spec

Source

pub fn with_exec<E: AsRef<OsStr>>(self, exec: E) -> Self

Set the executable for the exec spec

Source

pub fn working_dir<P: AsRef<Path>>(&mut self, path: P) -> &mut Self

Set the working directory for the exec spec. If the path is relative, it will be resolved to the project directory.

Source

pub fn stdin<In>(&mut self, input: In) -> &mut Self
where In: Into<Input>,

Set the standard input for the executable. doesn’t need to be set

Source

pub fn with_stdin<In>(self, input: In) -> Self
where In: Into<Input>,

Set the standard input for the executable. doesn’t need to be set

Source

pub fn stdout<O>(&mut self, output: O) -> &mut Self
where O: Into<Output>,

Sets the output type for this exec spec

Source

pub fn with_stdout<O>(self, output: O) -> Self
where O: Into<Output>,

Sets the output type for this exec spec

Source

pub fn stderr<O>(&mut self, output: O) -> &mut Self
where O: Into<Output>,

Sets the output type for this exec spec

Source

pub fn with_stderr<O>(self, output: O) -> Self
where O: Into<Output>,

Sets the output type for this exec spec

Source

pub fn build(self) -> Result<ExecSpec, ExecSpecBuilderError>

Build the exec spec from the builder

§Error

Will return an error if the working directory or the executable isn’t set.

Auto Trait Implementations§

Blanket Implementations§

Source§

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

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

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

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where 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> InstanceOf for T
where T: Any + ?Sized,

Source§

fn instance_of<T>(&self) -> bool
where T: Any + ?Sized,

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where 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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> IntoNamed for T

Source§

fn named<S>(self, name: S) -> Named<Self>
where S: AsRef<str>,

Add a name to this object
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

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

Source§

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 T
where U: TryFrom<T>,

Source§

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.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

impl<T> ErasedDestructor for T
where T: 'static,

Source§

impl<E> Extension for E
where E: 'static + Send + Sync,

Source§

impl<T> MaybeSendSync for T