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 glib::object::IsA;
use glib::translate::*;
use std::fmt;

glib::wrapper! {
    #[doc(alias = "FlatpakInstance")]
    pub struct Instance(Object<ffi::FlatpakInstance, ffi::FlatpakInstanceClass>);

    match fn {
        type_ => || ffi::flatpak_instance_get_type(),
    }
}

impl Instance {
    pub const NONE: Option<&'static Instance> = None;

    #[cfg(any(feature = "v1_1", feature = "dox"))]
    #[cfg_attr(feature = "dox", doc(cfg(feature = "v1_1")))]
    #[doc(alias = "flatpak_instance_get_all")]
    #[doc(alias = "get_all")]
    pub fn all() -> Vec<Instance> {
        assert_initialized_main_thread!();
        unsafe { FromGlibPtrContainer::from_glib_full(ffi::flatpak_instance_get_all()) }
    }
}

pub trait InstanceExt: 'static {
    #[cfg(any(feature = "v1_1", feature = "dox"))]
    #[cfg_attr(feature = "dox", doc(cfg(feature = "v1_1")))]
    #[doc(alias = "flatpak_instance_get_app")]
    #[doc(alias = "get_app")]
    fn app(&self) -> Option<glib::GString>;

    #[cfg(any(feature = "v1_1", feature = "dox"))]
    #[cfg_attr(feature = "dox", doc(cfg(feature = "v1_1")))]
    #[doc(alias = "flatpak_instance_get_arch")]
    #[doc(alias = "get_arch")]
    fn arch(&self) -> Option<glib::GString>;

    #[cfg(any(feature = "v1_1", feature = "dox"))]
    #[cfg_attr(feature = "dox", doc(cfg(feature = "v1_1")))]
    #[doc(alias = "flatpak_instance_get_branch")]
    #[doc(alias = "get_branch")]
    fn branch(&self) -> Option<glib::GString>;

    #[cfg(any(feature = "v1_1", feature = "dox"))]
    #[cfg_attr(feature = "dox", doc(cfg(feature = "v1_1")))]
    #[doc(alias = "flatpak_instance_get_child_pid")]
    #[doc(alias = "get_child_pid")]
    fn child_pid(&self) -> i32;

    #[cfg(any(feature = "v1_1", feature = "dox"))]
    #[cfg_attr(feature = "dox", doc(cfg(feature = "v1_1")))]
    #[doc(alias = "flatpak_instance_get_commit")]
    #[doc(alias = "get_commit")]
    fn commit(&self) -> Option<glib::GString>;

    #[cfg(any(feature = "v1_1", feature = "dox"))]
    #[cfg_attr(feature = "dox", doc(cfg(feature = "v1_1")))]
    #[doc(alias = "flatpak_instance_get_id")]
    #[doc(alias = "get_id")]
    fn id(&self) -> Option<glib::GString>;

    #[cfg(any(feature = "v1_1", feature = "dox"))]
    #[cfg_attr(feature = "dox", doc(cfg(feature = "v1_1")))]
    #[doc(alias = "flatpak_instance_get_info")]
    #[doc(alias = "get_info")]
    fn info(&self) -> Option<glib::KeyFile>;

    #[cfg(any(feature = "v1_1", feature = "dox"))]
    #[cfg_attr(feature = "dox", doc(cfg(feature = "v1_1")))]
    #[doc(alias = "flatpak_instance_get_pid")]
    #[doc(alias = "get_pid")]
    fn pid(&self) -> i32;

    #[cfg(any(feature = "v1_1", feature = "dox"))]
    #[cfg_attr(feature = "dox", doc(cfg(feature = "v1_1")))]
    #[doc(alias = "flatpak_instance_get_runtime")]
    #[doc(alias = "get_runtime")]
    fn runtime(&self) -> Option<glib::GString>;

    #[cfg(any(feature = "v1_1", feature = "dox"))]
    #[cfg_attr(feature = "dox", doc(cfg(feature = "v1_1")))]
    #[doc(alias = "flatpak_instance_get_runtime_commit")]
    #[doc(alias = "get_runtime_commit")]
    fn runtime_commit(&self) -> Option<glib::GString>;

    #[doc(alias = "flatpak_instance_is_running")]
    fn is_running(&self) -> bool;
}

impl<O: IsA<Instance>> InstanceExt for O {
    #[cfg(any(feature = "v1_1", feature = "dox"))]
    #[cfg_attr(feature = "dox", doc(cfg(feature = "v1_1")))]
    fn app(&self) -> Option<glib::GString> {
        unsafe {
            from_glib_none(ffi::flatpak_instance_get_app(
                self.as_ref().to_glib_none().0,
            ))
        }
    }

    #[cfg(any(feature = "v1_1", feature = "dox"))]
    #[cfg_attr(feature = "dox", doc(cfg(feature = "v1_1")))]
    fn arch(&self) -> Option<glib::GString> {
        unsafe {
            from_glib_none(ffi::flatpak_instance_get_arch(
                self.as_ref().to_glib_none().0,
            ))
        }
    }

    #[cfg(any(feature = "v1_1", feature = "dox"))]
    #[cfg_attr(feature = "dox", doc(cfg(feature = "v1_1")))]
    fn branch(&self) -> Option<glib::GString> {
        unsafe {
            from_glib_none(ffi::flatpak_instance_get_branch(
                self.as_ref().to_glib_none().0,
            ))
        }
    }

    #[cfg(any(feature = "v1_1", feature = "dox"))]
    #[cfg_attr(feature = "dox", doc(cfg(feature = "v1_1")))]
    fn child_pid(&self) -> i32 {
        unsafe { ffi::flatpak_instance_get_child_pid(self.as_ref().to_glib_none().0) }
    }

    #[cfg(any(feature = "v1_1", feature = "dox"))]
    #[cfg_attr(feature = "dox", doc(cfg(feature = "v1_1")))]
    fn commit(&self) -> Option<glib::GString> {
        unsafe {
            from_glib_none(ffi::flatpak_instance_get_commit(
                self.as_ref().to_glib_none().0,
            ))
        }
    }

    #[cfg(any(feature = "v1_1", feature = "dox"))]
    #[cfg_attr(feature = "dox", doc(cfg(feature = "v1_1")))]
    fn id(&self) -> Option<glib::GString> {
        unsafe { from_glib_none(ffi::flatpak_instance_get_id(self.as_ref().to_glib_none().0)) }
    }

    #[cfg(any(feature = "v1_1", feature = "dox"))]
    #[cfg_attr(feature = "dox", doc(cfg(feature = "v1_1")))]
    fn info(&self) -> Option<glib::KeyFile> {
        unsafe {
            from_glib_full(ffi::flatpak_instance_get_info(
                self.as_ref().to_glib_none().0,
            ))
        }
    }

    #[cfg(any(feature = "v1_1", feature = "dox"))]
    #[cfg_attr(feature = "dox", doc(cfg(feature = "v1_1")))]
    fn pid(&self) -> i32 {
        unsafe { ffi::flatpak_instance_get_pid(self.as_ref().to_glib_none().0) }
    }

    #[cfg(any(feature = "v1_1", feature = "dox"))]
    #[cfg_attr(feature = "dox", doc(cfg(feature = "v1_1")))]
    fn runtime(&self) -> Option<glib::GString> {
        unsafe {
            from_glib_none(ffi::flatpak_instance_get_runtime(
                self.as_ref().to_glib_none().0,
            ))
        }
    }

    #[cfg(any(feature = "v1_1", feature = "dox"))]
    #[cfg_attr(feature = "dox", doc(cfg(feature = "v1_1")))]
    fn runtime_commit(&self) -> Option<glib::GString> {
        unsafe {
            from_glib_none(ffi::flatpak_instance_get_runtime_commit(
                self.as_ref().to_glib_none().0,
            ))
        }
    }

    fn is_running(&self) -> bool {
        unsafe {
            from_glib(ffi::flatpak_instance_is_running(
                self.as_ref().to_glib_none().0,
            ))
        }
    }
}

impl fmt::Display for Instance {
    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
        f.write_str("Instance")
    }
}