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