#[cfg(any(feature = "v3_6", feature = "dox"))]
use Error;
#[cfg(feature = "futures")]
#[cfg(any(feature = "v3_6", feature = "dox"))]
use futures::future;
#[cfg(any(feature = "v3_6", feature = "dox"))]
use gio;
#[cfg(any(feature = "v3_6", feature = "dox"))]
use gio_sys;
#[cfg(any(feature = "v3_6", feature = "dox"))]
use glib::GString;
use glib::object::IsA;
use glib::translate::*;
#[cfg(any(feature = "v3_6", feature = "dox"))]
use glib_sys;
use goa_sys;
#[cfg(any(feature = "v3_6", feature = "dox"))]
use gobject_sys;
#[cfg(feature = "futures")]
#[cfg(any(feature = "v3_6", feature = "dox"))]
use std::boxed::Box as Box_;
use std::fmt;
#[cfg(any(feature = "v3_6", feature = "dox"))]
use std::ptr;
glib_wrapper! {
pub struct PasswordBased(Interface<goa_sys::GoaPasswordBased>);
match fn {
get_type => || goa_sys::goa_password_based_get_type(),
}
}
impl PasswordBased {
}
pub const NONE_PASSWORD_BASED: Option<&PasswordBased> = None;
pub trait PasswordBasedExt: 'static {
#[cfg(any(feature = "v3_6", feature = "dox"))]
fn call_get_password<P: IsA<gio::Cancellable>, Q: FnOnce(Result<GString, Error>) + Send + 'static>(&self, arg_id: &str, cancellable: Option<&P>, callback: Q);
#[cfg(feature = "futures")]
#[cfg(any(feature = "v3_6", feature = "dox"))]
fn call_get_password_future(&self, arg_id: &str) -> Box_<dyn future::Future<Output = Result<GString, Error>> + std::marker::Unpin>;
#[cfg(any(feature = "v3_6", feature = "dox"))]
fn call_get_password_sync<P: IsA<gio::Cancellable>>(&self, arg_id: &str, cancellable: Option<&P>) -> Result<GString, Error>;
}
impl<O: IsA<PasswordBased>> PasswordBasedExt for O {
#[cfg(any(feature = "v3_6", feature = "dox"))]
fn call_get_password<P: IsA<gio::Cancellable>, Q: FnOnce(Result<GString, Error>) + Send + 'static>(&self, arg_id: &str, cancellable: Option<&P>, callback: Q) {
let user_data: Box<Q> = Box::new(callback);
unsafe extern "C" fn call_get_password_trampoline<Q: FnOnce(Result<GString, Error>) + Send + 'static>(_source_object: *mut gobject_sys::GObject, res: *mut gio_sys::GAsyncResult, user_data: glib_sys::gpointer) {
let mut error = ptr::null_mut();
let mut out_password = ptr::null_mut();
let _ = goa_sys::goa_password_based_call_get_password_finish(_source_object as *mut _, &mut out_password, res, &mut error);
let result = if error.is_null() { Ok(from_glib_full(out_password)) } else { Err(from_glib_full(error)) };
let callback: Box<Q> = Box::from_raw(user_data as *mut _);
callback(result);
}
let callback = call_get_password_trampoline::<Q>;
unsafe {
goa_sys::goa_password_based_call_get_password(self.as_ref().to_glib_none().0, arg_id.to_glib_none().0, cancellable.map(|p| p.as_ref()).to_glib_none().0, Some(callback), Box::into_raw(user_data) as *mut _);
}
}
#[cfg(feature = "futures")]
#[cfg(any(feature = "v3_6", feature = "dox"))]
fn call_get_password_future(&self, arg_id: &str) -> Box_<dyn future::Future<Output = Result<GString, Error>> + std::marker::Unpin> {
use gio::GioFuture;
use fragile::Fragile;
let arg_id = String::from(arg_id);
GioFuture::new(self, move |obj, send| {
let cancellable = gio::Cancellable::new();
let send = Fragile::new(send);
obj.call_get_password(
&arg_id,
Some(&cancellable),
move |res| {
let _ = send.into_inner().send(res);
},
);
cancellable
})
}
#[cfg(any(feature = "v3_6", feature = "dox"))]
fn call_get_password_sync<P: IsA<gio::Cancellable>>(&self, arg_id: &str, cancellable: Option<&P>) -> Result<GString, Error> {
unsafe {
let mut out_password = ptr::null_mut();
let mut error = ptr::null_mut();
let _ = goa_sys::goa_password_based_call_get_password_sync(self.as_ref().to_glib_none().0, arg_id.to_glib_none().0, &mut out_password, cancellable.map(|p| p.as_ref()).to_glib_none().0, &mut error);
if error.is_null() { Ok(from_glib_full(out_password)) } else { Err(from_glib_full(error)) }
}
}
}
impl fmt::Display for PasswordBased {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "PasswordBased")
}
}