@@ -23,14 +23,14 @@ pub mod terminalsource;
23
23
/// Allows concrete types for the currentprocess abstraction.
24
24
#[ derive( Clone , Debug ) ]
25
25
pub enum Process {
26
- OSProcess ( OSProcess ) ,
26
+ Os ( OSProcess ) ,
27
27
#[ cfg( feature = "test" ) ]
28
- TestProcess ( TestProcess ) ,
28
+ Test ( TestProcess ) ,
29
29
}
30
30
31
31
impl Process {
32
32
pub fn os ( ) -> Self {
33
- Self :: OSProcess ( OSProcess :: new ( ) )
33
+ Self :: Os ( OSProcess :: new ( ) )
34
34
}
35
35
36
36
pub fn name ( & self ) -> Option < String > {
@@ -48,9 +48,9 @@ impl Process {
48
48
49
49
pub fn var ( & self , key : & str ) -> Result < String , env:: VarError > {
50
50
match self {
51
- Process :: OSProcess ( _) => env:: var ( key) ,
51
+ Process :: Os ( _) => env:: var ( key) ,
52
52
#[ cfg( feature = "test" ) ]
53
- Process :: TestProcess ( p) => match p. vars . get ( key) {
53
+ Process :: Test ( p) => match p. vars . get ( key) {
54
54
Some ( val) => Ok ( val. to_owned ( ) ) ,
55
55
None => Err ( env:: VarError :: NotPresent ) ,
56
56
} ,
@@ -59,100 +59,100 @@ impl Process {
59
59
60
60
pub ( crate ) fn var_os ( & self , key : & str ) -> Option < OsString > {
61
61
match self {
62
- Process :: OSProcess ( _) => env:: var_os ( key) ,
62
+ Process :: Os ( _) => env:: var_os ( key) ,
63
63
#[ cfg( feature = "test" ) ]
64
- Process :: TestProcess ( p) => p. vars . get ( key) . map ( OsString :: from) ,
64
+ Process :: Test ( p) => p. vars . get ( key) . map ( OsString :: from) ,
65
65
}
66
66
}
67
67
68
68
pub ( crate ) fn args ( & self ) -> Box < dyn Iterator < Item = String > + ' _ > {
69
69
match self {
70
- Process :: OSProcess ( _) => Box :: new ( env:: args ( ) ) ,
70
+ Process :: Os ( _) => Box :: new ( env:: args ( ) ) ,
71
71
#[ cfg( feature = "test" ) ]
72
- Process :: TestProcess ( p) => Box :: new ( p. args . iter ( ) . cloned ( ) ) ,
72
+ Process :: Test ( p) => Box :: new ( p. args . iter ( ) . cloned ( ) ) ,
73
73
}
74
74
}
75
75
76
76
pub ( crate ) fn args_os ( & self ) -> Box < dyn Iterator < Item = OsString > + ' _ > {
77
77
match self {
78
- Process :: OSProcess ( _) => Box :: new ( env:: args_os ( ) ) ,
78
+ Process :: Os ( _) => Box :: new ( env:: args_os ( ) ) ,
79
79
#[ cfg( feature = "test" ) ]
80
- Process :: TestProcess ( p) => Box :: new ( p. args . iter ( ) . map ( OsString :: from) ) ,
80
+ Process :: Test ( p) => Box :: new ( p. args . iter ( ) . map ( OsString :: from) ) ,
81
81
}
82
82
}
83
83
84
84
pub ( crate ) fn stdin ( & self ) -> Box < dyn filesource:: Stdin > {
85
85
match self {
86
- Process :: OSProcess ( _) => Box :: new ( io:: stdin ( ) ) ,
86
+ Process :: Os ( _) => Box :: new ( io:: stdin ( ) ) ,
87
87
#[ cfg( feature = "test" ) ]
88
- Process :: TestProcess ( p) => Box :: new ( filesource:: TestStdin ( p. stdin . clone ( ) ) ) ,
88
+ Process :: Test ( p) => Box :: new ( filesource:: TestStdin ( p. stdin . clone ( ) ) ) ,
89
89
}
90
90
}
91
91
92
92
pub ( crate ) fn stdout ( & self ) -> Box < dyn filesource:: Writer > {
93
93
match self {
94
- Process :: OSProcess ( _) => Box :: new ( io:: stdout ( ) ) ,
94
+ Process :: Os ( _) => Box :: new ( io:: stdout ( ) ) ,
95
95
#[ cfg( feature = "test" ) ]
96
- Process :: TestProcess ( p) => Box :: new ( filesource:: TestWriter ( p. stdout . clone ( ) ) ) ,
96
+ Process :: Test ( p) => Box :: new ( filesource:: TestWriter ( p. stdout . clone ( ) ) ) ,
97
97
}
98
98
}
99
99
100
100
pub ( crate ) fn stderr ( & self ) -> Box < dyn filesource:: Writer > {
101
101
match self {
102
- Process :: OSProcess ( _) => Box :: new ( io:: stderr ( ) ) ,
102
+ Process :: Os ( _) => Box :: new ( io:: stderr ( ) ) ,
103
103
#[ cfg( feature = "test" ) ]
104
- Process :: TestProcess ( p) => Box :: new ( filesource:: TestWriter ( p. stderr . clone ( ) ) ) ,
104
+ Process :: Test ( p) => Box :: new ( filesource:: TestWriter ( p. stderr . clone ( ) ) ) ,
105
105
}
106
106
}
107
107
108
108
pub ( crate ) fn current_dir ( & self ) -> io:: Result < PathBuf > {
109
109
match self {
110
- Process :: OSProcess ( _) => env:: current_dir ( ) ,
110
+ Process :: Os ( _) => env:: current_dir ( ) ,
111
111
#[ cfg( feature = "test" ) ]
112
- Process :: TestProcess ( p) => Ok ( p. cwd . clone ( ) ) ,
112
+ Process :: Test ( p) => Ok ( p. cwd . clone ( ) ) ,
113
113
}
114
114
}
115
115
116
116
#[ cfg( test) ]
117
117
fn id ( & self ) -> u64 {
118
118
match self {
119
- Process :: OSProcess ( _) => std:: process:: id ( ) as u64 ,
119
+ Process :: Os ( _) => std:: process:: id ( ) as u64 ,
120
120
#[ cfg( feature = "test" ) ]
121
- Process :: TestProcess ( p) => p. id ,
121
+ Process :: Test ( p) => p. id ,
122
122
}
123
123
}
124
124
}
125
125
126
126
impl home:: env:: Env for Process {
127
127
fn home_dir ( & self ) -> Option < PathBuf > {
128
128
match self {
129
- Process :: OSProcess ( _) => self . var ( "HOME" ) . ok ( ) . map ( |v| v. into ( ) ) ,
129
+ Process :: Os ( _) => self . var ( "HOME" ) . ok ( ) . map ( |v| v. into ( ) ) ,
130
130
#[ cfg( feature = "test" ) ]
131
- Process :: TestProcess ( _) => home:: env:: OS_ENV . home_dir ( ) ,
131
+ Process :: Test ( _) => home:: env:: OS_ENV . home_dir ( ) ,
132
132
}
133
133
}
134
134
135
135
fn current_dir ( & self ) -> Result < PathBuf , io:: Error > {
136
136
match self {
137
- Process :: OSProcess ( _) => self . current_dir ( ) ,
137
+ Process :: Os ( _) => self . current_dir ( ) ,
138
138
#[ cfg( feature = "test" ) ]
139
- Process :: TestProcess ( _) => home:: env:: OS_ENV . current_dir ( ) ,
139
+ Process :: Test ( _) => home:: env:: OS_ENV . current_dir ( ) ,
140
140
}
141
141
}
142
142
143
143
fn var_os ( & self , key : & str ) -> Option < OsString > {
144
144
match self {
145
- Process :: OSProcess ( _) => self . var_os ( key) ,
145
+ Process :: Os ( _) => self . var_os ( key) ,
146
146
#[ cfg( feature = "test" ) ]
147
- Process :: TestProcess ( _) => self . var_os ( key) ,
147
+ Process :: Test ( _) => self . var_os ( key) ,
148
148
}
149
149
}
150
150
}
151
151
152
152
#[ cfg( feature = "test" ) ]
153
153
impl From < TestProcess > for Process {
154
154
fn from ( p : TestProcess ) -> Self {
155
- Self :: TestProcess ( p)
155
+ Self :: Test ( p)
156
156
}
157
157
}
158
158
0 commit comments