Enum Command

Source
pub enum Command {
    Std(Command),
    Tokio(Command),
}
Available on crate feature process only.
Expand description

An enum that can wrap std::process::Command or tokio::process::Command and can Clone.

Note that Cloning Command is a lossy clone, which will lose platform specific options such as: pre_exec, creation_flags, etc.

See: https://users.rust-lang.org/t/is-there-any-way-to-clone-a-std-command/121905

Variants§

§

Std(Command)

§

Tokio(Command)

Implementations§

Source§

impl Command

Source

pub fn std<S: AsRef<OsStr>>(program: S) -> Self

Create a new Command wrapped with std::process::Command.

See: std::process::Command::new

Source

pub fn tokio_default<S: AsRef<OsStr>>(program: S) -> Self

Create a new Command wrapped with tokio::process::Command.

See: tokio::process::Command::new

Source

pub fn tokio_config<S: AsRef<OsStr>>(program: S, kill_on_drop: bool) -> Self

Source

pub fn wrapping_std(&self) -> bool

Check whether Self is wrapped with std::process::Command.

Source

pub fn wrapping_tokio(&self) -> bool

Check whether Self is wrapped with tokio::process::Command.

Source

pub fn as_std(&self) -> &StdCommand

Cheaply convert to a &std::process::Command for places where the type from the standard library is expected.

This method will return &std::process::Command even if it is wrapping tokio::process::Command.

See: tokio::process::Command::as_std

Source

pub fn as_std_mut(&mut self) -> &mut StdCommand

Cheaply convert to a &mut std::process::Command for places where the type from the standard library is expected.

This method will return &mut std::process::Command even if it is wrapping tokio::process::Command.

See: tokio::process::Command::as_std_mut

Source

pub fn as_tokio(&self) -> Option<&TokioCommand>

If the instance is wrapping tokio::process::Command, it returns Some(&tokio::process::Command), otherwise it returns None.

Source

pub fn as_tokio_mut(&mut self) -> Option<&mut TokioCommand>

If the instance is wrapping tokio::process::Command, it returns Some(&mut tokio::process::Command), otherwise it returns None.

Source

pub fn into_std(self) -> StdCommand

Cheaply convert into a std::process::Command.

Note that if the instance is wrapping tokio::process::Command, Tokio specific options will be lost. Currently, this only applies to kill_on_drop.

See: tokio::process::Command::into_std

Source

pub fn into_tokio(self) -> TokioCommand

Cheaply convert into a tokio::process::Command.

Note that if the instance is wrapping the std::process::Command, kill_on_drop will use the default value of false.

Source

pub fn convert_to_std(self) -> Self

Consume Self, convert it to std::process::Command, and then return a new instance that wraps it.

Source

pub fn convert_to_tokio(self) -> Self

Consume Self, convert it to tokio::process::Command, and then return a new instance that wraps it.

Trait Implementations§

Source§

impl Clone for Command

Source§

fn clone(&self) -> Self

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 Command

Source§

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

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

impl From<Command> for Command

Source§

fn from(value: StdCommand) -> Self

Converts to this type from the input type.
Source§

impl From<Command> for Command

Source§

fn from(value: Command) -> Self

Converts to this type from the input type.
Source§

impl From<Command> for Command

Source§

fn from(value: TokioCommand) -> Self

Converts to this type from the input type.
Source§

impl From<Command> for Command

Source§

fn from(value: Command) -> Self

Converts to this type from the input type.

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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 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,

Source§

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