4 use crate::marker::PhantomData;
5 use crate::num::NonZeroI32;
7 use crate::sys::fs::File;
8 use crate::sys::pipe::AnonPipe;
9 use crate::sys::unsupported;
10 use crate::sys_common::process::{CommandEnv, CommandEnvs};
12 pub use crate::ffi::OsString as EnvKey;
14 ////////////////////////////////////////////////////////////////////////////////
16 ////////////////////////////////////////////////////////////////////////////////
22 // passed back to std::process with the pipes connected to the child, if any
24 pub struct StdioPipes {
25 pub stdin: Option<AnonPipe>,
26 pub stdout: Option<AnonPipe>,
27 pub stderr: Option<AnonPipe>,
37 pub fn new(_program: &OsStr) -> Command {
38 Command { env: Default::default() }
41 pub fn arg(&mut self, _arg: &OsStr) {}
43 pub fn env_mut(&mut self) -> &mut CommandEnv {
47 pub fn cwd(&mut self, _dir: &OsStr) {}
49 pub fn stdin(&mut self, _stdin: Stdio) {}
51 pub fn stdout(&mut self, _stdout: Stdio) {}
53 pub fn stderr(&mut self, _stderr: Stdio) {}
55 pub fn get_program(&self) -> &OsStr {
59 pub fn get_args(&self) -> CommandArgs<'_> {
60 CommandArgs { _p: PhantomData }
63 pub fn get_envs(&self) -> CommandEnvs<'_> {
67 pub fn get_current_dir(&self) -> Option<&Path> {
75 ) -> io::Result<(Process, StdioPipes)> {
80 impl From<AnonPipe> for Stdio {
81 fn from(pipe: AnonPipe) -> Stdio {
86 impl From<File> for Stdio {
87 fn from(_file: File) -> Stdio {
92 impl fmt::Debug for Command {
93 fn fmt(&self, _f: &mut fmt::Formatter<'_>) -> fmt::Result {
98 pub struct ExitStatus(!);
101 pub fn exit_ok(&self) -> Result<(), ExitStatusError> {
105 pub fn code(&self) -> Option<i32> {
110 impl Clone for ExitStatus {
111 fn clone(&self) -> ExitStatus {
116 impl Copy for ExitStatus {}
118 impl PartialEq for ExitStatus {
119 fn eq(&self, _other: &ExitStatus) -> bool {
124 impl Eq for ExitStatus {}
126 impl fmt::Debug for ExitStatus {
127 fn fmt(&self, _f: &mut fmt::Formatter<'_>) -> fmt::Result {
132 impl fmt::Display for ExitStatus {
133 fn fmt(&self, _f: &mut fmt::Formatter<'_>) -> fmt::Result {
138 #[derive(PartialEq, Eq, Clone, Copy, Debug)]
139 pub struct ExitStatusError(ExitStatus);
141 impl Into<ExitStatus> for ExitStatusError {
142 fn into(self) -> ExitStatus {
147 impl ExitStatusError {
148 pub fn code(self) -> Option<NonZeroI32> {
153 #[derive(PartialEq, Eq, Clone, Copy, Debug)]
154 pub struct ExitCode(bool);
157 pub const SUCCESS: ExitCode = ExitCode(false);
158 pub const FAILURE: ExitCode = ExitCode(true);
160 pub fn as_i32(&self) -> i32 {
165 impl From<u8> for ExitCode {
166 fn from(code: u8) -> Self {
169 1..=255 => Self::FAILURE,
174 pub struct Process(!);
177 pub fn id(&self) -> u32 {
181 pub fn kill(&mut self) -> io::Result<()> {
185 pub fn wait(&mut self) -> io::Result<ExitStatus> {
189 pub fn try_wait(&mut self) -> io::Result<Option<ExitStatus>> {
194 pub struct CommandArgs<'a> {
195 _p: PhantomData<&'a ()>,
198 impl<'a> Iterator for CommandArgs<'a> {
199 type Item = &'a OsStr;
200 fn next(&mut self) -> Option<&'a OsStr> {
203 fn size_hint(&self) -> (usize, Option<usize>) {
208 impl<'a> ExactSizeIterator for CommandArgs<'a> {}
210 impl<'a> fmt::Debug for CommandArgs<'a> {
211 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
212 f.debug_list().finish()