11// Take a look at the license at the top of the repository in the LICENSE file.
22
33#[ cfg( any( unix, all( docsrs, unix) ) ) ]
4- use std:: os:: unix:: io:: IntoRawFd ;
4+ use std:: os:: unix:: io:: { AsFd , AsRawFd , IntoRawFd , OwnedFd } ;
55
66use glib:: translate:: * ;
77
@@ -26,40 +26,41 @@ impl SubprocessLauncher {
2626 #[ cfg( unix) ]
2727 #[ cfg_attr( docsrs, doc( cfg( unix) ) ) ]
2828 #[ 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 ( ) ;
3032 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) ;
3634 }
3735 }
3836
3937 #[ cfg( unix) ]
4038 #[ cfg_attr( docsrs, doc( cfg( unix) ) ) ]
4139 #[ 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 > ) {
4341 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) ;
4544 }
4645 }
4746
4847 #[ cfg( unix) ]
4948 #[ cfg_attr( docsrs, doc( cfg( unix) ) ) ]
5049 #[ 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 ( ) ) ;
5252 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 ) ;
5454 }
5555 }
5656
5757 #[ cfg( unix) ]
5858 #[ cfg_attr( docsrs, doc( cfg( unix) ) ) ]
5959 #[ 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 ( ) ) ;
6162 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 ) ;
6364 }
6465 }
6566}
0 commit comments