diff --git a/Gir.toml b/Gir.toml index ca817bee..90c2a2e8 100644 --- a/Gir.toml +++ b/Gir.toml @@ -582,9 +582,6 @@ status = "generate" [[object.function]] name = "communicate_utf8_async" ignore = true - [[object.function]] - name = "communicate_utf8_async_future" - ignore = true [[object]] name = "Gio.SubprocessLauncher" diff --git a/src/subprocess.rs b/src/subprocess.rs index a9c88e1c..a985af76 100644 --- a/src/subprocess.rs +++ b/src/subprocess.rs @@ -4,13 +4,24 @@ use Subprocess; use Cancellable; #[cfg(any(feature = "v2_40", feature = "dox"))] use Error; +#[cfg(any(feature = "v2_40", feature = "dox"))] use ffi; +#[cfg(any(feature = "v2_40", feature = "dox"))] use glib; +#[cfg(any(feature = "v2_40", feature = "dox"))] use glib::object::IsA; +#[cfg(any(feature = "v2_40", feature = "dox"))] use glib::translate::*; +#[cfg(any(feature = "v2_40", feature = "dox"))] use glib_ffi; +#[cfg(any(feature = "v2_40", feature = "dox"))] use gobject_ffi; +#[cfg(any(feature = "v2_40", feature = "dox"))] use std::ptr; +#[cfg(feature = "futures")] +use futures_core; +#[cfg(feature = "futures")] +use std::boxed::Box as Box_; pub trait SubprocessExtManual { #[cfg(any(feature = "v2_40", feature = "dox"))] @@ -18,7 +29,8 @@ pub trait SubprocessExtManual { #[cfg(feature = "futures")] #[cfg(any(feature = "v2_40", feature = "dox"))] - fn communicate_utf8_async_future>>(&self, stdin_buf: P) -> Box_>; + fn communicate_utf8_async_future>>(&self, stdin_buf: P) -> Box_> + where Self: Sized; } #[cfg(any(feature = "v2_40", feature = "dox"))] @@ -26,10 +38,10 @@ impl + IsA + Clone + 'static> Subproces #[cfg(any(feature = "v2_40", feature = "dox"))] fn communicate_utf8_async<'a, P: Into>, Q: Into>, R: FnOnce(Result<(String, String), Error>) + Send + 'static>(&self, stdin_buf: P, cancellable: Q, callback: R) { let stdin_buf = stdin_buf.into(); - let stdin_buf = stdin_buf.to_glib_none(); + let stdin_buf = stdin_buf.to_glib_full(); let cancellable = cancellable.into(); let cancellable = cancellable.to_glib_none(); - let user_data: Box> = Box::new(Box::new((callback, stdin_buf.0))); + let user_data: Box> = Box::new(Box::new((callback, stdin_buf))); unsafe extern "C" fn communicate_utf8_async_trampoline) + Send + 'static>(_source_object: *mut gobject_ffi::GObject, res: *mut ffi::GAsyncResult, user_data: glib_ffi::gpointer) { callback_guard!(); @@ -44,24 +56,24 @@ impl + IsA + Clone + 'static> Subproces } let callback = communicate_utf8_async_trampoline::; unsafe { - ffi::g_subprocess_communicate_utf8_async(self.to_glib_none().0, stdin_buf.0, cancellable.0, Some(callback), Box::into_raw(user_data) as *mut _); + ffi::g_subprocess_communicate_utf8_async(self.to_glib_none().0, stdin_buf, cancellable.0, Some(callback), Box::into_raw(user_data) as *mut _); } } #[cfg(feature = "futures")] #[cfg(any(feature = "v2_40", feature = "dox"))] - fn communicate_utf8_async_future>>(&self, stdin_buf: P) -> Box_> { + fn communicate_utf8_async_future>>(&self, stdin_buf: P) -> Box_> + where Self: Sized { use GioFuture; use send_cell::SendCell; let stdin_buf = stdin_buf.into(); - let stdin_buf = stdin_buf.map(ToOwned::to_owned); GioFuture::new(self, move |obj, send| { let cancellable = Cancellable::new(); let send = SendCell::new(send); let obj_clone = SendCell::new(obj.clone()); obj.communicate_utf8_async( - stdin_buf.as_ref().map(::std::borrow::Borrow::borrow), + stdin_buf, Some(&cancellable), move |res| { let obj = obj_clone.into_inner();