File tree 1 file changed +5
-11
lines changed
1 file changed +5
-11
lines changed Original file line number Diff line number Diff line change 1
1
use std:: {
2
2
collections:: BTreeMap ,
3
- error:: Error ,
4
3
fs:: File ,
5
4
os:: fd:: AsRawFd ,
6
5
path:: { Path , PathBuf } ,
@@ -256,10 +255,9 @@ impl Container {
256
255
257
256
/// Run a function inside the container chroot
258
257
#[ inline( always) ]
259
- pub fn run < F , E > ( & mut self , f : F ) -> Result < ( ) , E >
258
+ pub fn run < F , T > ( & mut self , f : F ) -> std :: io :: Result < T >
260
259
where
261
- F : FnOnce ( ) -> Result < ( ) , E > ,
262
- E : Error + From < std:: io:: Error > ,
260
+ F : FnOnce ( ) -> T ,
263
261
{
264
262
// Only mount and chroot if we're not already initialized
265
263
if !self . _initialized {
@@ -269,15 +267,14 @@ impl Container {
269
267
self . chroot ( ) ?;
270
268
}
271
269
tracing:: trace!( "Running function inside container" ) ;
272
- f ( ) ? ;
270
+ let ret = f ( ) ;
273
271
if self . chroot {
274
272
self . exit_chroot ( ) ?;
275
273
}
276
274
if self . _initialized {
277
275
self . umount ( ) ?;
278
276
}
279
-
280
- Ok ( ( ) )
277
+ Ok ( ret)
281
278
}
282
279
283
280
/// Start mounting files inside the container
@@ -388,10 +385,7 @@ mod tests {
388
385
std:: fs:: create_dir_all ( "/tmp/tiffin" ) . unwrap ( ) ;
389
386
let mut container = Container :: new ( PathBuf :: from ( "/tmp/tiffin" ) ) ;
390
387
container
391
- . run ( || {
392
- std:: fs:: create_dir_all ( "/tmp/tiffin/test" ) . unwrap ( ) ;
393
- std:: io:: Result :: Ok ( ( ) )
394
- } )
388
+ . run ( || std:: fs:: create_dir_all ( "/tmp/tiffin/test" ) . unwrap ( ) )
395
389
. unwrap ( ) ;
396
390
}
397
391
}
You can’t perform that action at this time.
0 commit comments