pub enum Command {
Std(Command),
Tokio(Command),
}
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§
Implementations§
Source§impl Command
impl Command
Sourcepub fn std<S: AsRef<OsStr>>(program: S) -> Self
pub fn std<S: AsRef<OsStr>>(program: S) -> Self
Create a new Command
wrapped with std::process::Command
.
Sourcepub fn tokio_default<S: AsRef<OsStr>>(program: S) -> Self
pub fn tokio_default<S: AsRef<OsStr>>(program: S) -> Self
Create a new Command
wrapped with tokio::process::Command
.
Sourcepub fn tokio_config<S: AsRef<OsStr>>(program: S, kill_on_drop: bool) -> Self
pub fn tokio_config<S: AsRef<OsStr>>(program: S, kill_on_drop: bool) -> Self
Create a new Command
wrapped with tokio::process::Command
with kill_on_drop
option.
See:
Sourcepub fn wrapping_std(&self) -> bool
pub fn wrapping_std(&self) -> bool
Check whether Self
is wrapped with std::process::Command
.
Sourcepub fn wrapping_tokio(&self) -> bool
pub fn wrapping_tokio(&self) -> bool
Check whether Self
is wrapped with tokio::process::Command
.
Sourcepub fn as_std(&self) -> &StdCommand
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
.
Sourcepub fn as_std_mut(&mut self) -> &mut StdCommand
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
.
Sourcepub fn as_tokio(&self) -> Option<&TokioCommand>
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
.
Sourcepub fn as_tokio_mut(&mut self) -> Option<&mut TokioCommand>
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
.
Sourcepub fn into_std(self) -> StdCommand
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
.
Sourcepub fn into_tokio(self) -> TokioCommand
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
.
Sourcepub fn convert_to_std(self) -> Self
pub fn convert_to_std(self) -> Self
Consume Self
, convert it to std::process::Command
, and then return a new instance
that wraps it.
Sourcepub fn convert_to_tokio(self) -> Self
pub fn convert_to_tokio(self) -> Self
Consume Self
, convert it to tokio::process::Command
, and then return a new instance
that wraps it.