gio/
subprocess_launcher.rs1#[cfg(any(unix, feature = "dox"))]
2use gio_sys;
3#[cfg(any(unix, feature = "dox"))]
4use glib::translate::*;
5#[cfg(any(unix, all(feature = "dox", unix)))]
6use std::os::unix::io::IntoRawFd;
7use SubprocessLauncher;
8
9#[cfg(all(feature = "dox", not(unix)))]
10pub trait IntoRawFd: Sized {
11 fn into_raw_fd(self) -> i32 {
12 0
13 }
14}
15
16impl SubprocessLauncher {
17 #[cfg(any(unix, feature = "dox"))]
18 pub fn take_fd<F: IntoRawFd, G: IntoRawFd>(&self, source_fd: F, target_fd: G) {
19 unsafe {
20 gio_sys::g_subprocess_launcher_take_fd(
21 self.to_glib_none().0,
22 source_fd.into_raw_fd(),
23 target_fd.into_raw_fd(),
24 );
25 }
26 }
27
28 #[cfg(any(unix, feature = "dox"))]
29 pub fn take_stderr_fd<F: IntoRawFd>(&self, fd: F) {
30 unsafe {
31 gio_sys::g_subprocess_launcher_take_stderr_fd(self.to_glib_none().0, fd.into_raw_fd());
32 }
33 }
34
35 #[cfg(any(unix, feature = "dox"))]
36 pub fn take_stdin_fd<F: IntoRawFd>(&self, fd: F) {
37 unsafe {
38 gio_sys::g_subprocess_launcher_take_stdin_fd(self.to_glib_none().0, fd.into_raw_fd());
39 }
40 }
41
42 #[cfg(any(unix, feature = "dox"))]
43 pub fn take_stdout_fd<F: IntoRawFd>(&self, fd: F) {
44 unsafe {
45 gio_sys::g_subprocess_launcher_take_stdout_fd(self.to_glib_none().0, fd.into_raw_fd());
46 }
47 }
48}