// GENERATED — DO NOT EDIT
///|
/// [Upstream documentation](https://docs.gtk.org/gio/iface.AsyncInitable.html).
pub type AsyncInitable
///|
pub(open) trait IAsyncInitable {
fn as_async_initable(Self) -> AsyncInitable
fn new_finish(Self, &IAsyncResult) -> @gobject.Object raise @glib.Error_ = _
fn init_async(Self, Int, &ICancellable?, (Result[Bool, @glib.Error_]) -> Unit) -> Unit = _
}
///|
pub impl IAsyncInitable for AsyncInitable with fn as_async_initable(self) {
self
}
///|
#borrow(self_, res, error)
extern "c" fn moonbit_g_async_initable_new_finish(
self_ : AsyncInitable,
res : AsyncResult,
error : Ref[@glib.Nullable[@glib.Error_]],
) -> @gobject.Object = "moonbit_g_async_initable_new_finish"
///|
/// [Upstream documentation](https://docs.gtk.org/gio/method.AsyncInitable.new_finish.html).
pub fn AsyncInitable::new_finish(
self : AsyncInitable,
res : &IAsyncResult,
) -> @gobject.Object raise @glib.Error_ {
let error_ : Ref[@glib.Nullable[@glib.Error_]] = Ref(@glib.Nullable::null())
let result = moonbit_g_async_initable_new_finish(
self,
res.as_async_result(),
error_,
)
match error_.val.to_option() {
Some(e) => raise e
None => ()
}
result
}
///|
#borrow(self_, cancellable)
extern "c" fn g_async_initable_init_async(
self_ : AsyncInitable,
io_priority : Int,
cancellable : @glib.Nullable[Cancellable],
function : FuncRef[
(
Bool,
@glib.Nullable[@glib.Error_],
(Bool, @glib.Nullable[@glib.Error_]) -> Unit,
) -> Unit,
],
closure : (Bool, @glib.Nullable[@glib.Error_]) -> Unit,
) = "moonbit_g_async_initable_init_async"
///|
/// [Upstream documentation](https://docs.gtk.org/gio/method.AsyncInitable.init_async.html).
pub fn AsyncInitable::init_async(
self : AsyncInitable,
io_priority : Int,
cancellable : &ICancellable?,
callback : (Result[Bool, @glib.Error_]) -> Unit,
) -> Unit {
g_async_initable_init_async(
self,
io_priority,
match cancellable {
Some(v) => @glib.Nullable::some(v.as_cancellable())
None => @glib.Nullable::null()
},
fn(result, error, f) { f(result, error) },
fn(result, error) {
match error.to_option() {
Some(e) => callback(Err(e))
None => callback(Ok(result))
}
},
)
}
///|
impl IAsyncInitable with fn new_finish(self, res) -> @gobject.Object raise @glib.Error_ {
self.as_async_initable().new_finish(res)
}
///|
impl IAsyncInitable with fn init_async(self, io_priority, cancellable, callback) -> Unit {
self.as_async_initable().init_async(io_priority, cancellable, callback)
}