polkit 0.19.0

High-level bindings for libpolkit-gobject-1
// Generated by gir (https://github.com/gtk-rs/gir @ 0e476ab5c1de)
// from /usr/share/gir-1.0 (@ ???)
// DO NOT EDIT

use glib::translate::*;

glib::wrapper! {
    /// An object used for passing details around.
    ///
    /// # Implements
    ///
    /// [`trait@glib::ObjectExt`]
    #[doc(alias = "PolkitDetails")]
    pub struct Details(Object<ffi::PolkitDetails, ffi::PolkitDetailsClass>);

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

impl Details {
    /// Creates a new [`Details`][crate::Details] object.
    ///
    /// # Returns
    ///
    /// A [`Details`][crate::Details] object. Free with `g_object_unref()`.
    #[doc(alias = "polkit_details_new")]
    pub fn new() -> Details {
        unsafe { from_glib_full(ffi::polkit_details_new()) }
    }

    /// Gets a list of all keys on `self`.
    ///
    /// # Returns
    ///
    /// [`None`] if there are no keys
    /// otherwise an array of strings that should be freed with
    /// `g_strfreev()`.
    #[doc(alias = "polkit_details_get_keys")]
    #[doc(alias = "get_keys")]
    pub fn keys(&self) -> Vec<glib::GString> {
        unsafe {
            FromGlibPtrContainer::from_glib_full(ffi::polkit_details_get_keys(
                self.to_glib_none().0,
            ))
        }
    }

    /// Inserts a copy of `key` and `value` on `self`.
    ///
    /// If `value` is [`None`], the key will be removed.
    /// ## `key`
    /// A key.
    /// ## `value`
    /// A value.
    #[doc(alias = "polkit_details_insert")]
    pub fn insert(&self, key: &str, value: Option<&str>) {
        unsafe {
            ffi::polkit_details_insert(
                self.to_glib_none().0,
                key.to_glib_none().0,
                value.to_glib_none().0,
            );
        }
    }

    /// Gets the value for `key` on `self`.
    /// ## `key`
    /// A key.
    ///
    /// # Returns
    ///
    /// [`None`] if there is no value for `key`, otherwise a string owned by `self`.
    #[doc(alias = "polkit_details_lookup")]
    pub fn lookup(&self, key: &str) -> Option<glib::GString> {
        unsafe {
            from_glib_none(ffi::polkit_details_lookup(
                self.to_glib_none().0,
                key.to_glib_none().0,
            ))
        }
    }
}

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