1 // Take a look at the license at the top of the repository in the LICENSE file. 2 3 use crate::SubprocessLauncher; 4 #[cfg(any(unix, feature = "dox"))] 5 #[cfg(any(unix, feature = "dox"))] 6 use glib::translate::*; 7 #[cfg(any(unix, all(feature = "dox", unix)))] 8 use std::os::unix::io::IntoRawFd; 9 10 #[cfg(all(feature = "dox", not(unix)))] 11 pub trait IntoRawFd: Sized { into_raw_fd(self) -> i3212 fn into_raw_fd(self) -> i32 { 13 0 14 } 15 } 16 17 impl SubprocessLauncher { 18 #[cfg(any(unix, feature = "dox"))] 19 #[cfg_attr(feature = "dox", doc(cfg(unix)))] 20 #[doc(alias = "g_subprocess_launcher_take_fd")] take_fd<F: IntoRawFd, G: IntoRawFd>(&self, source_fd: F, target_fd: G)21 pub fn take_fd<F: IntoRawFd, G: IntoRawFd>(&self, source_fd: F, target_fd: G) { 22 unsafe { 23 ffi::g_subprocess_launcher_take_fd( 24 self.to_glib_none().0, 25 source_fd.into_raw_fd(), 26 target_fd.into_raw_fd(), 27 ); 28 } 29 } 30 31 #[cfg(any(unix, feature = "dox"))] 32 #[cfg_attr(feature = "dox", doc(cfg(unix)))] 33 #[doc(alias = "g_subprocess_launcher_take_stderr_fd")] take_stderr_fd<F: IntoRawFd>(&self, fd: F)34 pub fn take_stderr_fd<F: IntoRawFd>(&self, fd: F) { 35 unsafe { 36 ffi::g_subprocess_launcher_take_stderr_fd(self.to_glib_none().0, fd.into_raw_fd()); 37 } 38 } 39 40 #[cfg(any(unix, feature = "dox"))] 41 #[cfg_attr(feature = "dox", doc(cfg(unix)))] 42 #[doc(alias = "g_subprocess_launcher_take_stdin_fd")] take_stdin_fd<F: IntoRawFd>(&self, fd: F)43 pub fn take_stdin_fd<F: IntoRawFd>(&self, fd: F) { 44 unsafe { 45 ffi::g_subprocess_launcher_take_stdin_fd(self.to_glib_none().0, fd.into_raw_fd()); 46 } 47 } 48 49 #[cfg(any(unix, feature = "dox"))] 50 #[cfg_attr(feature = "dox", doc(cfg(unix)))] 51 #[doc(alias = "g_subprocess_launcher_take_stdout_fd")] take_stdout_fd<F: IntoRawFd>(&self, fd: F)52 pub fn take_stdout_fd<F: IntoRawFd>(&self, fd: F) { 53 unsafe { 54 ffi::g_subprocess_launcher_take_stdout_fd(self.to_glib_none().0, fd.into_raw_fd()); 55 } 56 } 57 } 58