@@ -25,7 +25,7 @@ mod imp;
25
25
// Imports
26
26
use super :: subprocess;
27
27
use glib:: Object ;
28
- use gtk:: { glib, gio , prelude:: ObjectExt } ;
28
+ use gtk:: { gio , glib, prelude:: ObjectExt } ;
29
29
use std:: ffi:: OsStr ;
30
30
31
31
glib:: wrapper! {
@@ -75,7 +75,7 @@ impl Processor {
75
75
obj. set_property ( "call" , base_call. to_string ( ) . clone ( ) ) ;
76
76
obj. set_property ( "tail-call" , tail_call. to_string ( ) ) ;
77
77
78
- return obj;
78
+ obj
79
79
}
80
80
81
81
/*
@@ -98,7 +98,7 @@ impl Processor {
98
98
// Create call stack of program and args
99
99
let tail_call = self . property :: < String > ( "tail-call" ) ;
100
100
let mut call_stack = self . property :: < String > ( "call" ) ;
101
- call_stack. push_str ( " " ) ;
101
+ call_stack. push ( ' ' ) ;
102
102
call_stack. push_str ( tail_call. as_str ( ) ) ;
103
103
104
104
// Turn call stack into bytes and create vector for final call stack
@@ -115,7 +115,7 @@ impl Processor {
115
115
Ok ( result) => {
116
116
//println!("item: {}", result);//TEST
117
117
item_osstr = OsStr :: new ( result)
118
- } ,
118
+ }
119
119
Err ( err) => panic ! ( "{}" , err) ,
120
120
}
121
121
call_stack_items. insert ( call_stack_items. len ( ) , item_osstr) ;
@@ -128,7 +128,7 @@ impl Processor {
128
128
Ok ( result) => {
129
129
//println!("item: {}", result);//TEST
130
130
item_osstr = OsStr :: new ( result)
131
- } ,
131
+ }
132
132
Err ( err) => panic ! ( "{}" , err) ,
133
133
}
134
134
call_stack_items. insert ( call_stack_items. len ( ) , item_osstr) ;
@@ -139,7 +139,12 @@ impl Processor {
139
139
match call_stack_items. len ( ) {
140
140
4 => {
141
141
// Build array
142
- let argv = [ call_stack_items[ 0 ] , call_stack_items[ 1 ] , call_stack_items[ 2 ] , call_stack_items[ 3 ] ] ;
142
+ let argv = [
143
+ call_stack_items[ 0 ] ,
144
+ call_stack_items[ 1 ] ,
145
+ call_stack_items[ 2 ] ,
146
+ call_stack_items[ 3 ] ,
147
+ ] ;
143
148
144
149
// Run process, get output
145
150
match subprocess:: exec_communicate ( & argv, None :: < & gio:: Cancellable > ) {
@@ -148,26 +153,34 @@ impl Processor {
148
153
( None , None ) => return Ok ( None ) ,
149
154
150
155
( None , Some ( stderr_buffer) ) => {
151
- println ! ( "Process failed with error: {}" , String :: from_utf8_lossy( & stderr_buffer) . into_owned( ) ) ;
152
- } ,
156
+ println ! (
157
+ "Process failed with error: {}" ,
158
+ String :: from_utf8_lossy( & stderr_buffer) . into_owned( )
159
+ ) ;
160
+ }
153
161
154
162
( Some ( stdout_buffer) , None ) => {
155
- let stdout_buffer_contents = String :: from_utf8_lossy ( & stdout_buffer) . into_owned ( ) ;
163
+ let stdout_buffer_contents =
164
+ String :: from_utf8_lossy ( & stdout_buffer) . into_owned ( ) ;
156
165
157
166
return Ok ( Some ( self . parse ( & stdout_buffer_contents) ) ) ;
158
- } ,
167
+ }
159
168
160
169
( Some ( stdout_buffer) , Some ( stderr_buffer) ) => {
161
- let stdout_buffer_contents = String :: from_utf8_lossy ( & stdout_buffer) . into_owned ( ) ;
170
+ let stdout_buffer_contents =
171
+ String :: from_utf8_lossy ( & stdout_buffer) . into_owned ( ) ;
162
172
163
- println ! ( "Process failed with error: {}" , String :: from_utf8_lossy( & stderr_buffer) . into_owned( ) ) ;
173
+ println ! (
174
+ "Process failed with error: {}" ,
175
+ String :: from_utf8_lossy( & stderr_buffer) . into_owned( )
176
+ ) ;
164
177
165
178
return Ok ( Some ( self . parse ( & stdout_buffer_contents) ) ) ;
166
- } ,
179
+ }
167
180
} ,
168
181
Err ( err) => return Err ( err) ,
169
182
} ;
170
- } ,
183
+ }
171
184
2 => {
172
185
// Build array
173
186
let argv = [ call_stack_items[ 0 ] , call_stack_items[ 1 ] ] ;
@@ -179,30 +192,38 @@ impl Processor {
179
192
( None , None ) => return Ok ( None ) ,
180
193
181
194
( None , Some ( stderr_buffer) ) => {
182
- println ! ( "Process failed with error: {}" , String :: from_utf8_lossy( & stderr_buffer) . into_owned( ) ) ;
183
- } ,
195
+ println ! (
196
+ "Process failed with error: {}" ,
197
+ String :: from_utf8_lossy( & stderr_buffer) . into_owned( )
198
+ ) ;
199
+ }
184
200
185
201
( Some ( stdout_buffer) , None ) => {
186
- let stdout_buffer_contents = String :: from_utf8_lossy ( & stdout_buffer) . into_owned ( ) ;
202
+ let stdout_buffer_contents =
203
+ String :: from_utf8_lossy ( & stdout_buffer) . into_owned ( ) ;
187
204
188
205
return Ok ( Some ( self . parse ( & stdout_buffer_contents) ) ) ;
189
- } ,
206
+ }
190
207
191
208
( Some ( stdout_buffer) , Some ( stderr_buffer) ) => {
192
- let stdout_buffer_contents = String :: from_utf8_lossy ( & stdout_buffer) . into_owned ( ) ;
209
+ let stdout_buffer_contents =
210
+ String :: from_utf8_lossy ( & stdout_buffer) . into_owned ( ) ;
193
211
194
- println ! ( "Process failed with error: {}" , String :: from_utf8_lossy( & stderr_buffer) . into_owned( ) ) ;
212
+ println ! (
213
+ "Process failed with error: {}" ,
214
+ String :: from_utf8_lossy( & stderr_buffer) . into_owned( )
215
+ ) ;
195
216
196
217
return Ok ( Some ( self . parse ( & stdout_buffer_contents) ) ) ;
197
- } ,
218
+ }
198
219
} ,
199
220
Err ( err) => return Err ( err) ,
200
221
} ;
201
- } ,
222
+ }
202
223
_invalid_size => return Ok ( None ) , // This will only occur via programmer error
203
224
}
204
225
205
- return Ok ( None ) ;
226
+ Ok ( None )
206
227
}
207
228
208
229
/*
@@ -233,11 +254,11 @@ impl Processor {
233
254
* Notes:
234
255
* This function is designed to be overloaded by subclasses
235
256
*/
236
- fn parse ( self , input : & String ) -> String {
257
+ fn parse ( self , input : & str ) -> String {
237
258
//NOTE: leaving this here for future use..
238
259
//let mut output = input.replace("\n", "").to_owned();
239
260
//output.push_str("-FUCK");
240
261
241
- input. replace ( "\n " , "" ) . to_owned ( )
262
+ input. replace ( "\n " , "" )
242
263
}
243
264
}
0 commit comments