appstream-glib 0.0.1

The sys part of the rust bindings for appstream-glib
// This file was generated by gir (https://github.com/gtk-rs/gir)
// from gir-files (https://github.com/gtk-rs/gir-files)
// DO NOT EDIT

#[cfg(any(feature = "v0_5_12", feature = "dox"))]
use ContentRatingValue;
use app_stream_glib_sys;
#[cfg(any(feature = "v0_5_12", feature = "dox"))]
use glib::GString;
use glib::object::IsA;
use glib::translate::*;
use std::fmt;

glib_wrapper! {
    pub struct ContentRating(Object<app_stream_glib_sys::AsContentRating, app_stream_glib_sys::AsContentRatingClass, ContentRatingClass>);

    match fn {
        get_type => || app_stream_glib_sys::as_content_rating_get_type(),
    }
}

impl ContentRating {
    #[cfg(any(feature = "v0_5_12", feature = "dox"))]
    pub fn new() -> ContentRating {
        unsafe {
            from_glib_full(app_stream_glib_sys::as_content_rating_new())
        }
    }

    #[cfg(any(feature = "v0_7_15", feature = "dox"))]
    pub fn attribute_to_csm_age(id: &str, value: ContentRatingValue) -> u32 {
        unsafe {
            app_stream_glib_sys::as_content_rating_attribute_to_csm_age(id.to_glib_none().0, value.to_glib())
        }
    }

    #[cfg(any(feature = "v0_7_15", feature = "dox"))]
    pub fn get_all_rating_ids() -> Vec<GString> {
        unsafe {
            FromGlibPtrContainer::from_glib_container(app_stream_glib_sys::as_content_rating_get_all_rating_ids())
        }
    }

    #[cfg(any(feature = "v0_5_12", feature = "dox"))]
    pub fn value_from_string(value: &str) -> ContentRatingValue {
        unsafe {
            from_glib(app_stream_glib_sys::as_content_rating_value_from_string(value.to_glib_none().0))
        }
    }

    #[cfg(any(feature = "v0_5_12", feature = "dox"))]
    pub fn value_to_string(value: ContentRatingValue) -> Option<GString> {
        unsafe {
            from_glib_none(app_stream_glib_sys::as_content_rating_value_to_string(value.to_glib()))
        }
    }
}

#[cfg(any(feature = "v0_5_12", feature = "dox"))]
impl Default for ContentRating {
    fn default() -> Self {
        Self::new()
    }
}

pub const NONE_CONTENT_RATING: Option<&ContentRating> = None;

pub trait ContentRatingExt: 'static {
    #[cfg(any(feature = "v0_7_14", feature = "dox"))]
    fn add_attribute(&self, id: &str, value: ContentRatingValue);

    #[cfg(any(feature = "v0_5_12", feature = "dox"))]
    fn get_kind(&self) -> Option<GString>;

    #[cfg(any(feature = "v0_5_12", feature = "dox"))]
    fn get_minimum_age(&self) -> u32;

    #[cfg(any(feature = "v0_7_15", feature = "dox"))]
    fn get_rating_ids(&self) -> Vec<GString>;

    #[cfg(any(feature = "v0_6_4", feature = "dox"))]
    fn get_value(&self, id: &str) -> ContentRatingValue;

    #[cfg(any(feature = "v0_5_12", feature = "dox"))]
    fn set_kind(&self, kind: &str);
}

impl<O: IsA<ContentRating>> ContentRatingExt for O {
    #[cfg(any(feature = "v0_7_14", feature = "dox"))]
    fn add_attribute(&self, id: &str, value: ContentRatingValue) {
        unsafe {
            app_stream_glib_sys::as_content_rating_add_attribute(self.as_ref().to_glib_none().0, id.to_glib_none().0, value.to_glib());
        }
    }

    #[cfg(any(feature = "v0_5_12", feature = "dox"))]
    fn get_kind(&self) -> Option<GString> {
        unsafe {
            from_glib_none(app_stream_glib_sys::as_content_rating_get_kind(self.as_ref().to_glib_none().0))
        }
    }

    #[cfg(any(feature = "v0_5_12", feature = "dox"))]
    fn get_minimum_age(&self) -> u32 {
        unsafe {
            app_stream_glib_sys::as_content_rating_get_minimum_age(self.as_ref().to_glib_none().0)
        }
    }

    #[cfg(any(feature = "v0_7_15", feature = "dox"))]
    fn get_rating_ids(&self) -> Vec<GString> {
        unsafe {
            FromGlibPtrContainer::from_glib_container(app_stream_glib_sys::as_content_rating_get_rating_ids(self.as_ref().to_glib_none().0))
        }
    }

    #[cfg(any(feature = "v0_6_4", feature = "dox"))]
    fn get_value(&self, id: &str) -> ContentRatingValue {
        unsafe {
            from_glib(app_stream_glib_sys::as_content_rating_get_value(self.as_ref().to_glib_none().0, id.to_glib_none().0))
        }
    }

    #[cfg(any(feature = "v0_5_12", feature = "dox"))]
    fn set_kind(&self, kind: &str) {
        unsafe {
            app_stream_glib_sys::as_content_rating_set_kind(self.as_ref().to_glib_none().0, kind.to_glib_none().0);
        }
    }
}

impl fmt::Display for ContentRating {
    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
        write!(f, "ContentRating")
    }
}