1
1
// Take a look at the license at the top of the repository in the LICENSE file.
2
2
3
3
#[ cfg( any( unix, all( docsrs, unix) ) ) ]
4
- use std:: os:: unix:: io:: IntoRawFd ;
4
+ use std:: os:: unix:: io:: { AsFd , AsRawFd , IntoRawFd , OwnedFd } ;
5
5
6
6
use glib:: translate:: * ;
7
7
@@ -26,40 +26,41 @@ impl SubprocessLauncher {
26
26
#[ cfg( unix) ]
27
27
#[ cfg_attr( docsrs, doc( cfg( unix) ) ) ]
28
28
#[ doc( alias = "g_subprocess_launcher_take_fd" ) ]
29
- pub fn take_fd ( & self , source_fd : impl IntoRawFd , target_fd : impl IntoRawFd ) {
29
+ pub fn take_fd ( & self , source_fd : OwnedFd , target_fd : impl AsFd ) {
30
+ let source_raw_fd = source_fd. into_raw_fd ( ) ;
31
+ let target_raw_fd = target_fd. as_fd ( ) . as_raw_fd ( ) ;
30
32
unsafe {
31
- ffi:: g_subprocess_launcher_take_fd (
32
- self . to_glib_none ( ) . 0 ,
33
- source_fd. into_raw_fd ( ) ,
34
- target_fd. into_raw_fd ( ) ,
35
- ) ;
33
+ ffi:: g_subprocess_launcher_take_fd ( self . to_glib_none ( ) . 0 , source_raw_fd, target_raw_fd) ;
36
34
}
37
35
}
38
36
39
37
#[ cfg( unix) ]
40
38
#[ cfg_attr( docsrs, doc( cfg( unix) ) ) ]
41
39
#[ doc( alias = "g_subprocess_launcher_take_stderr_fd" ) ]
42
- pub fn take_stderr_fd ( & self , fd : impl IntoRawFd ) {
40
+ pub fn take_stderr_fd ( & self , fd : Option < OwnedFd > ) {
43
41
unsafe {
44
- ffi:: g_subprocess_launcher_take_stderr_fd ( self . to_glib_none ( ) . 0 , fd. into_raw_fd ( ) ) ;
42
+ let raw_fd = fd. map_or ( -1 , |fd| fd. into_raw_fd ( ) ) ;
43
+ ffi:: g_subprocess_launcher_take_stderr_fd ( self . to_glib_none ( ) . 0 , raw_fd) ;
45
44
}
46
45
}
47
46
48
47
#[ cfg( unix) ]
49
48
#[ cfg_attr( docsrs, doc( cfg( unix) ) ) ]
50
49
#[ doc( alias = "g_subprocess_launcher_take_stdin_fd" ) ]
51
- pub fn take_stdin_fd ( & self , fd : impl IntoRawFd ) {
50
+ pub fn take_stdin_fd ( & self , fd : Option < OwnedFd > ) {
51
+ let raw_fd = fd. map_or ( -1 , |fd| fd. into_raw_fd ( ) ) ;
52
52
unsafe {
53
- ffi:: g_subprocess_launcher_take_stdin_fd ( self . to_glib_none ( ) . 0 , fd . into_raw_fd ( ) ) ;
53
+ ffi:: g_subprocess_launcher_take_stdin_fd ( self . to_glib_none ( ) . 0 , raw_fd ) ;
54
54
}
55
55
}
56
56
57
57
#[ cfg( unix) ]
58
58
#[ cfg_attr( docsrs, doc( cfg( unix) ) ) ]
59
59
#[ doc( alias = "g_subprocess_launcher_take_stdout_fd" ) ]
60
- pub fn take_stdout_fd ( & self , fd : impl IntoRawFd ) {
60
+ pub fn take_stdout_fd ( & self , fd : Option < OwnedFd > ) {
61
+ let raw_fd = fd. map_or ( -1 , |fd| fd. into_raw_fd ( ) ) ;
61
62
unsafe {
62
- ffi:: g_subprocess_launcher_take_stdout_fd ( self . to_glib_none ( ) . 0 , fd . into_raw_fd ( ) ) ;
63
+ ffi:: g_subprocess_launcher_take_stdout_fd ( self . to_glib_none ( ) . 0 , raw_fd ) ;
63
64
}
64
65
}
65
66
}
0 commit comments