libappstream 0.4.0

Rust bindings for appstream
Documentation
// 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::{ffi, BundleKind};
use glib::{prelude::*, translate::*};

glib::wrapper! {
    #[doc(alias = "AsBundle")]
    pub struct Bundle(Object<ffi::AsBundle, ffi::AsBundleClass>);

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

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

    #[doc(alias = "as_bundle_new")]
    pub fn new() -> Bundle {
        assert_initialized_main_thread!();
        unsafe { from_glib_full(ffi::as_bundle_new()) }
    }
}

impl Default for Bundle {
    fn default() -> Self {
        Self::new()
    }
}

pub trait BundleExt: IsA<Bundle> + 'static {
    #[doc(alias = "as_bundle_get_id")]
    #[doc(alias = "get_id")]
    fn id(&self) -> Option<glib::GString> {
        unsafe { from_glib_none(ffi::as_bundle_get_id(self.as_ref().to_glib_none().0)) }
    }

    #[doc(alias = "as_bundle_get_kind")]
    #[doc(alias = "get_kind")]
    fn kind(&self) -> BundleKind {
        unsafe { from_glib(ffi::as_bundle_get_kind(self.as_ref().to_glib_none().0)) }
    }

    #[doc(alias = "as_bundle_set_id")]
    fn set_id(&self, id: &str) {
        unsafe {
            ffi::as_bundle_set_id(self.as_ref().to_glib_none().0, id.to_glib_none().0);
        }
    }

    #[doc(alias = "as_bundle_set_kind")]
    fn set_kind(&self, kind: BundleKind) {
        unsafe {
            ffi::as_bundle_set_kind(self.as_ref().to_glib_none().0, kind.into_glib());
        }
    }
}

impl<O: IsA<Bundle>> BundleExt for O {}