4 use crate::marker
::PhantomData
;
6 use crate::sys
::fs
::File
;
7 use crate::sys
::pipe
::AnonPipe
;
8 use crate::sys
::unsupported
;
9 use crate::sys_common
::process
::{CommandEnv, CommandEnvs}
;
11 pub use crate::ffi
::OsString
as EnvKey
;
13 ////////////////////////////////////////////////////////////////////////////////
15 ////////////////////////////////////////////////////////////////////////////////
21 // passed back to std::process with the pipes connected to the child, if any
23 pub struct StdioPipes
{
24 pub stdin
: Option
<AnonPipe
>,
25 pub stdout
: Option
<AnonPipe
>,
26 pub stderr
: Option
<AnonPipe
>,
36 pub fn new(_program
: &OsStr
) -> Command
{
37 Command { env: Default::default() }
40 pub fn arg(&mut self, _arg
: &OsStr
) {}
42 pub fn env_mut(&mut self) -> &mut CommandEnv
{
46 pub fn cwd(&mut self, _dir
: &OsStr
) {}
48 pub fn stdin(&mut self, _stdin
: Stdio
) {}
50 pub fn stdout(&mut self, _stdout
: Stdio
) {}
52 pub fn stderr(&mut self, _stderr
: Stdio
) {}
54 pub fn get_program(&self) -> &OsStr
{
58 pub fn get_args(&self) -> CommandArgs
<'_
> {
59 CommandArgs { _p: PhantomData }
62 pub fn get_envs(&self) -> CommandEnvs
<'_
> {
66 pub fn get_current_dir(&self) -> Option
<&Path
> {
74 ) -> io
::Result
<(Process
, StdioPipes
)> {
79 impl From
<AnonPipe
> for Stdio
{
80 fn from(pipe
: AnonPipe
) -> Stdio
{
85 impl From
<File
> for Stdio
{
86 fn from(_file
: File
) -> Stdio
{
91 impl fmt
::Debug
for Command
{
92 fn fmt(&self, _f
: &mut fmt
::Formatter
<'_
>) -> fmt
::Result
{
97 pub struct ExitStatus(!);
100 pub fn success(&self) -> bool
{
104 pub fn code(&self) -> Option
<i32> {
109 impl Clone
for ExitStatus
{
110 fn clone(&self) -> ExitStatus
{
115 impl Copy
for ExitStatus {}
117 impl PartialEq
for ExitStatus
{
118 fn eq(&self, _other
: &ExitStatus
) -> bool
{
123 impl Eq
for ExitStatus {}
125 impl fmt
::Debug
for ExitStatus
{
126 fn fmt(&self, _f
: &mut fmt
::Formatter
<'_
>) -> fmt
::Result
{
131 impl fmt
::Display
for ExitStatus
{
132 fn fmt(&self, _f
: &mut fmt
::Formatter
<'_
>) -> fmt
::Result
{
137 #[derive(PartialEq, Eq, Clone, Copy, Debug)]
138 pub struct ExitCode(bool
);
141 pub const SUCCESS
: ExitCode
= ExitCode(false);
142 pub const FAILURE
: ExitCode
= ExitCode(true);
144 pub fn as_i32(&self) -> i32 {
149 pub struct Process(!);
152 pub fn id(&self) -> u32 {
156 pub fn kill(&mut self) -> io
::Result
<()> {
160 pub fn wait(&mut self) -> io
::Result
<ExitStatus
> {
164 pub fn try_wait(&mut self) -> io
::Result
<Option
<ExitStatus
>> {
169 pub struct CommandArgs
<'a
> {
170 _p
: PhantomData
<&'
a ()>,
173 impl<'a
> Iterator
for CommandArgs
<'a
> {
174 type Item
= &'a OsStr
;
175 fn next(&mut self) -> Option
<&'a OsStr
> {
180 impl<'a
> ExactSizeIterator
for CommandArgs
<'a
> {}
182 impl<'a
> fmt
::Debug
for CommandArgs
<'a
> {
183 fn fmt(&self, f
: &mut fmt
::Formatter
<'_
>) -> fmt
::Result
{
184 f
.debug_list().finish()