libflatpak 0.2.0

libflatpak bindings
// This file was generated by gir (https://github.com/gtk-rs/gir)
// from
// from gir-files (https://github.com/gtk-rs/gir-files.git)
// DO NOT EDIT

use crate::Installation;
use glib::object::IsA;
use glib::translate::*;
use std::ptr;

#[doc(alias = "flatpak_get_default_arch")]
#[doc(alias = "get_default_arch")]
pub fn default_arch() -> Option<glib::GString> {
    assert_initialized_main_thread!();
    unsafe { from_glib_none(ffi::flatpak_get_default_arch()) }
}

#[doc(alias = "flatpak_get_supported_arches")]
#[doc(alias = "get_supported_arches")]
pub fn supported_arches() -> Vec<glib::GString> {
    assert_initialized_main_thread!();
    unsafe { FromGlibPtrContainer::from_glib_none(ffi::flatpak_get_supported_arches()) }
}

#[doc(alias = "flatpak_get_system_installations")]
#[doc(alias = "get_system_installations")]
pub fn system_installations(
    cancellable: Option<&impl IsA<gio::Cancellable>>,
) -> Result<Vec<Installation>, glib::Error> {
    assert_initialized_main_thread!();
    unsafe {
        let mut error = ptr::null_mut();
        let ret = ffi::flatpak_get_system_installations(
            cancellable.map(|p| p.as_ref()).to_glib_none().0,
            &mut error,
        );
        if error.is_null() {
            Ok(FromGlibPtrContainer::from_glib_container(ret))
        } else {
            Err(from_glib_full(error))
        }
    }
}