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:: { IntoRawFd , OwnedFd } ;
5
5
6
6
#[ cfg( unix) ]
7
7
use glib:: translate:: * ;
@@ -19,40 +19,41 @@ impl SubprocessLauncher {
19
19
#[ cfg( unix) ]
20
20
#[ cfg_attr( docsrs, doc( cfg( unix) ) ) ]
21
21
#[ doc( alias = "g_subprocess_launcher_take_fd" ) ]
22
- pub fn take_fd ( & self , source_fd : impl IntoRawFd , target_fd : impl IntoRawFd ) {
22
+ pub fn take_fd ( & self , source_fd : Option < OwnedFd > , target_fd : Option < OwnedFd > ) {
23
+ let source_raw_fd = source_fd. map_or ( -1 , |fd| fd. into_raw_fd ( ) ) ;
24
+ let target_raw_fd = target_fd. map_or ( -1 , |fd| fd. into_raw_fd ( ) ) ;
23
25
unsafe {
24
- ffi:: g_subprocess_launcher_take_fd (
25
- self . to_glib_none ( ) . 0 ,
26
- source_fd. into_raw_fd ( ) ,
27
- target_fd. into_raw_fd ( ) ,
28
- ) ;
26
+ ffi:: g_subprocess_launcher_take_fd ( self . to_glib_none ( ) . 0 , source_raw_fd, target_raw_fd) ;
29
27
}
30
28
}
31
29
32
30
#[ cfg( unix) ]
33
31
#[ cfg_attr( docsrs, doc( cfg( unix) ) ) ]
34
32
#[ doc( alias = "g_subprocess_launcher_take_stderr_fd" ) ]
35
- pub fn take_stderr_fd ( & self , fd : impl IntoRawFd ) {
33
+ pub fn take_stderr_fd ( & self , fd : Option < OwnedFd > ) {
36
34
unsafe {
37
- ffi:: g_subprocess_launcher_take_stderr_fd ( self . to_glib_none ( ) . 0 , fd. into_raw_fd ( ) ) ;
35
+ let raw_fd = fd. map_or ( -1 , |fd| fd. into_raw_fd ( ) ) ;
36
+ ffi:: g_subprocess_launcher_take_stderr_fd ( self . to_glib_none ( ) . 0 , raw_fd) ;
38
37
}
39
38
}
40
39
41
40
#[ cfg( unix) ]
42
41
#[ cfg_attr( docsrs, doc( cfg( unix) ) ) ]
43
42
#[ doc( alias = "g_subprocess_launcher_take_stdin_fd" ) ]
44
- pub fn take_stdin_fd ( & self , fd : impl IntoRawFd ) {
43
+ pub fn take_stdin_fd ( & self , fd : Option < OwnedFd > ) {
44
+ let raw_fd = fd. map_or ( -1 , |fd| fd. into_raw_fd ( ) ) ;
45
45
unsafe {
46
- ffi:: g_subprocess_launcher_take_stdin_fd ( self . to_glib_none ( ) . 0 , fd . into_raw_fd ( ) ) ;
46
+ ffi:: g_subprocess_launcher_take_stdin_fd ( self . to_glib_none ( ) . 0 , raw_fd ) ;
47
47
}
48
48
}
49
49
50
50
#[ cfg( unix) ]
51
51
#[ cfg_attr( docsrs, doc( cfg( unix) ) ) ]
52
52
#[ doc( alias = "g_subprocess_launcher_take_stdout_fd" ) ]
53
- pub fn take_stdout_fd ( & self , fd : impl IntoRawFd ) {
53
+ pub fn take_stdout_fd ( & self , fd : Option < OwnedFd > ) {
54
+ let raw_fd = fd. map_or ( -1 , |fd| fd. into_raw_fd ( ) ) ;
54
55
unsafe {
55
- ffi:: g_subprocess_launcher_take_stdout_fd ( self . to_glib_none ( ) . 0 , fd . into_raw_fd ( ) ) ;
56
+ ffi:: g_subprocess_launcher_take_stdout_fd ( self . to_glib_none ( ) . 0 , raw_fd ) ;
56
57
}
57
58
}
58
59
}
0 commit comments