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 crate::Subject;
use glib::translate::*;

glib::wrapper! {
    /// Object used to describe a temporary authorization.
    ///
    /// # Implements
    ///
    /// [`trait@glib::ObjectExt`]
    #[doc(alias = "PolkitTemporaryAuthorization")]
    pub struct TemporaryAuthorization(Object<ffi::PolkitTemporaryAuthorization, ffi::PolkitTemporaryAuthorizationClass>);

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

impl TemporaryAuthorization {
    /// Gets the action that `self` is for.
    ///
    /// # Returns
    ///
    /// A string owned by `self`. Do not free.
    #[doc(alias = "polkit_temporary_authorization_get_action_id")]
    #[doc(alias = "get_action_id")]
    pub fn action_id(&self) -> glib::GString {
        unsafe {
            from_glib_none(ffi::polkit_temporary_authorization_get_action_id(
                self.to_glib_none().0,
            ))
        }
    }

    /// Gets the opaque identifier for `self`.
    ///
    /// # Returns
    ///
    /// A string owned by `self`. Do not free.
    #[doc(alias = "polkit_temporary_authorization_get_id")]
    #[doc(alias = "get_id")]
    pub fn id(&self) -> glib::GString {
        unsafe {
            from_glib_none(ffi::polkit_temporary_authorization_get_id(
                self.to_glib_none().0,
            ))
        }
    }

    /// Gets the subject that `self` is for.
    ///
    /// # Returns
    ///
    /// A [`Subject`][crate::Subject], free with `g_object_unref()`.
    #[doc(alias = "polkit_temporary_authorization_get_subject")]
    #[doc(alias = "get_subject")]
    pub fn subject(&self) -> Subject {
        unsafe {
            from_glib_full(ffi::polkit_temporary_authorization_get_subject(
                self.to_glib_none().0,
            ))
        }
    }

    /// Gets the time when `self` will expire.
    ///
    /// (Note that the PolicyKit daemon is using monotonic time internally
    /// so the returned value may change if system time changes.)
    ///
    /// # Returns
    ///
    /// Seconds since the Epoch Jan 1. 1970, 0:00 UTC.
    #[doc(alias = "polkit_temporary_authorization_get_time_expires")]
    #[doc(alias = "get_time_expires")]
    pub fn time_expires(&self) -> u64 {
        unsafe { ffi::polkit_temporary_authorization_get_time_expires(self.to_glib_none().0) }
    }

    /// Gets the time when `self` was obtained.
    ///
    /// (Note that the PolicyKit daemon is using monotonic time internally
    /// so the returned value may change if system time changes.)
    ///
    /// # Returns
    ///
    /// Seconds since the Epoch Jan 1. 1970, 0:00 UTC.
    #[doc(alias = "polkit_temporary_authorization_get_time_obtained")]
    #[doc(alias = "get_time_obtained")]
    pub fn time_obtained(&self) -> u64 {
        unsafe { ffi::polkit_temporary_authorization_get_time_obtained(self.to_glib_none().0) }
    }
}