]> git.lizzy.rs Git - rust.git/blob - src/libstd/sys/wasm/process.rs
f3f5de350f176bdb2f71f15a5422a8737ab9d39e
[rust.git] / src / libstd / sys / wasm / process.rs
1 // Copyright 2017 The Rust Project Developers. See the COPYRIGHT
2 // file at the top-level directory of this distribution and at
3 // http://rust-lang.org/COPYRIGHT.
4 //
5 // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6 // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7 // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8 // option. This file may not be copied, modified, or distributed
9 // except according to those terms.
10
11 use ffi::OsStr;
12 use fmt;
13 use io;
14 use sys::fs::File;
15 use sys::pipe::AnonPipe;
16 use sys::{unsupported, Void};
17 use sys_common::process::{CommandEnv, DefaultEnvKey};
18
19 ////////////////////////////////////////////////////////////////////////////////
20 // Command
21 ////////////////////////////////////////////////////////////////////////////////
22
23 pub struct Command {
24     env: CommandEnv<DefaultEnvKey>
25 }
26
27 // passed back to std::process with the pipes connected to the child, if any
28 // were requested
29 pub struct StdioPipes {
30     pub stdin: Option<AnonPipe>,
31     pub stdout: Option<AnonPipe>,
32     pub stderr: Option<AnonPipe>,
33 }
34
35 pub enum Stdio {
36     Inherit,
37     Null,
38     MakePipe,
39 }
40
41 impl Command {
42     pub fn new(_program: &OsStr) -> Command {
43         Command {
44             env: Default::default()
45         }
46     }
47
48     pub fn arg(&mut self, _arg: &OsStr) {
49     }
50
51     pub fn env_mut(&mut self) -> &mut CommandEnv<DefaultEnvKey> {
52         &mut self.env
53     }
54
55     pub fn cwd(&mut self, _dir: &OsStr) {
56     }
57
58     pub fn stdin(&mut self, _stdin: Stdio) {
59     }
60
61     pub fn stdout(&mut self, _stdout: Stdio) {
62     }
63
64     pub fn stderr(&mut self, _stderr: Stdio) {
65     }
66
67     pub fn spawn(&mut self, _default: Stdio, _needs_stdin: bool)
68         -> io::Result<(Process, StdioPipes)> {
69         unsupported()
70     }
71 }
72
73 impl From<AnonPipe> for Stdio {
74     fn from(pipe: AnonPipe) -> Stdio {
75         pipe.diverge()
76     }
77 }
78
79 impl From<File> for Stdio {
80     fn from(file: File) -> Stdio {
81         file.diverge()
82     }
83 }
84
85 impl fmt::Debug for Command {
86     fn fmt(&self, _f: &mut fmt::Formatter) -> fmt::Result {
87         Ok(())
88     }
89 }
90
91 pub struct ExitStatus(Void);
92
93 impl ExitStatus {
94     pub fn success(&self) -> bool {
95         match self.0 {}
96     }
97
98     pub fn code(&self) -> Option<i32> {
99         match self.0 {}
100     }
101 }
102
103 impl Clone for ExitStatus {
104     fn clone(&self) -> ExitStatus {
105         match self.0 {}
106     }
107 }
108
109 impl Copy for ExitStatus {}
110
111 impl PartialEq for ExitStatus {
112     fn eq(&self, _other: &ExitStatus) -> bool {
113         match self.0 {}
114     }
115 }
116
117 impl Eq for ExitStatus {
118 }
119
120 impl fmt::Debug for ExitStatus {
121     fn fmt(&self, _f: &mut fmt::Formatter) -> fmt::Result {
122         match self.0 {}
123     }
124 }
125
126 impl fmt::Display for ExitStatus {
127     fn fmt(&self, _f: &mut fmt::Formatter) -> fmt::Result {
128         match self.0 {}
129     }
130 }
131
132 pub struct Process(Void);
133
134 impl Process {
135     pub fn id(&self) -> u32 {
136         match self.0 {}
137     }
138
139     pub fn kill(&mut self) -> io::Result<()> {
140         match self.0 {}
141     }
142
143     pub fn wait(&mut self) -> io::Result<ExitStatus> {
144         match self.0 {}
145     }
146
147     pub fn try_wait(&mut self) -> io::Result<Option<ExitStatus>> {
148         match self.0 {}
149     }
150 }