Struct xscript::Cmd

source ·
pub struct Cmd<S: CmdString = OsString>(/* private fields */);
Expand description

A command.

Implementations§

source§

impl<S: CmdString> Cmd<S>

source

pub fn new<P: AsRef<S::Str>>(prog: P) -> Self

Creates a new command for the given program.

source

pub fn prog(&self) -> &S::Str

The program to run.

source

pub fn args(&self) -> impl Iterator<Item = &S::Str>

The arguments to run the program with.

source

pub fn cwd(&self) -> Option<&S::Str>

The directory in which to run the command, if any.

source

pub fn vars(&self) -> Option<&Vars<S>>

The environment variables to run the command with.

source

pub fn stdin(&self) -> Option<&In>

The stdin input to provide to the command.

source

pub fn stdout(&self) -> Option<&Out>

Indicates what to do with the stdout output of the command.

source

pub fn stderr(&self) -> Option<&Out>

Indicates what to do with the stderr output of the command.

source

pub fn may_fail(&self) -> bool

Indicates whether the command may fail.

source

pub fn is_secret(&self) -> bool

Hints that the command may contain secret information.

source

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

Adds an argument to the command.

source

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

Extends the arguments of the command.

source

pub fn with_cwd<P: AsRef<S::Str>>(self, cwd: P) -> Self

Sets the directory in which to run the command.

source

pub fn with_vars(self, vars: Vars<S>) -> Self

Sets the environment variables to run the command with.

source

pub fn with_var<N: AsRef<S::Str>, V: AsRef<S::Str>>( self, name: N, value: V ) -> Self

Sets an environment variable.

source

pub fn with_stdin<T: Into<In>>(self, stdin: T) -> Self

Sets the stdin input to provide to the command.

source

pub fn with_stdout(self, stdout: Out) -> Self

Sets what to do with the stdout output of the command.

source

pub fn with_stderr(self, stderr: Out) -> Self

Sets what to do with the stderr output of the command.

source

pub fn allow_failures(self) -> Self

Do not return an error when the command fails.

source

pub fn make_secret(self) -> Self

Mark the command as secret.

Trait Implementations§

source§

impl<S: CmdString> AsRef<Cmd<S>> for Cmd<S>

source§

fn as_ref(&self) -> &Cmd<S>

Converts this type into a shared reference of the (usually inferred) input type.
source§

impl<S: Clone + CmdString> Clone for Cmd<S>

source§

fn clone(&self) -> Cmd<S>

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<S: Debug + CmdString> Debug for Cmd<S>

source§

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

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

impl<'de, S> Deserialize<'de> for Cmd<S>
where S: Deserialize<'de> + CmdString,

source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
source§

impl<S: CmdString> Display for Cmd<S>

source§

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

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

impl<S> Serialize for Cmd<S>
where S: Serialize + CmdString,

source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more

Auto Trait Implementations§

§

impl<S> RefUnwindSafe for Cmd<S>
where S: RefUnwindSafe,

§

impl<S> Send for Cmd<S>
where S: Send + Sync,

§

impl<S> Sync for Cmd<S>
where S: Send + Sync,

§

impl<S> Unpin for Cmd<S>

§

impl<S> UnwindSafe for Cmd<S>
where S: RefUnwindSafe,

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.

§

impl<T> Instrument for T

§

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

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

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> ToOwned for T
where 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> ToString for T
where T: Display + ?Sized,

source§

default fn to_string(&self) -> String

Converts the given value to a String. Read more
source§

impl<T, U> TryFrom<U> for T
where 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 T
where 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.
§

impl<T> WithSubscriber for T

§

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
§

fn with_current_subscriber(self) -> WithDispatch<Self>

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

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,