polkit_rs/auto/
identity.rs

1// Generated by gir (https://github.com/gtk-rs/gir @ b2a1c6f9b362)
2// from ../misc (@ ???)
3// DO NOT EDIT
4
5use crate::ffi;
6use glib::{prelude::*, translate::*};
7
8glib::wrapper! {
9    #[doc(alias = "PolkitIdentity")]
10    pub struct Identity(Interface<ffi::PolkitIdentity, ffi::PolkitIdentityIface>);
11
12    match fn {
13        type_ => || ffi::polkit_identity_get_type(),
14    }
15}
16
17impl Identity {
18    pub const NONE: Option<&'static Identity> = None;
19
20    #[doc(alias = "polkit_identity_from_string")]
21    pub fn from_string(str: &str) -> Result<Option<Identity>, glib::Error> {
22        unsafe {
23            let mut error = std::ptr::null_mut();
24            let ret = ffi::polkit_identity_from_string(str.to_glib_none().0, &mut error);
25            if error.is_null() {
26                Ok(from_glib_full(ret))
27            } else {
28                Err(from_glib_full(error))
29            }
30        }
31    }
32}
33
34pub trait IdentityExt: IsA<Identity> + 'static {
35    #[doc(alias = "polkit_identity_equal")]
36    fn equal(&self, b: &impl IsA<Identity>) -> bool {
37        unsafe {
38            from_glib(ffi::polkit_identity_equal(
39                self.as_ref().to_glib_none().0,
40                b.as_ref().to_glib_none().0,
41            ))
42        }
43    }
44
45    #[doc(alias = "polkit_identity_hash")]
46    fn hash(&self) -> u32 {
47        unsafe { ffi::polkit_identity_hash(self.as_ref().to_glib_none().0) }
48    }
49
50    #[doc(alias = "polkit_identity_to_string")]
51    fn to_string(&self) -> glib::GString {
52        unsafe {
53            from_glib_full(ffi::polkit_identity_to_string(
54                self.as_ref().to_glib_none().0,
55            ))
56        }
57    }
58}
59
60impl<O: IsA<Identity>> IdentityExt for O {}