1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
// Generated by gir (https://github.com/gtk-rs/gir @ 0e476ab5c1de)
// from /usr/share/gir-1.0 (@ ???)
// DO NOT EDIT
use glib::{prelude::*, translate::*};
glib::wrapper! {
/// [`Identity`][crate::Identity] is an abstract type for representing one or more
/// identities.
///
/// # Implements
///
/// [`IdentityExt`][trait@crate::prelude::IdentityExt]
#[doc(alias = "PolkitIdentity")]
pub struct Identity(Interface<ffi::PolkitIdentity, ffi::PolkitIdentityIface>);
match fn {
type_ => || ffi::polkit_identity_get_type(),
}
}
impl Identity {
pub const NONE: Option<&'static Identity> = None;
/// Creates an object from `str` that implements the [`Identity`][crate::Identity]
/// interface.
/// ## `str`
/// A string obtained from [`IdentityExt::to_string()`][crate::prelude::IdentityExt::to_string()].
///
/// # Returns
///
/// A [`Identity`][crate::Identity] or [`None`]
/// if `error` is set. Free with `g_object_unref()`.
#[doc(alias = "polkit_identity_from_string")]
pub fn from_string(str: &str) -> Result<Option<Identity>, glib::Error> {
unsafe {
let mut error = std::ptr::null_mut();
let ret = ffi::polkit_identity_from_string(str.to_glib_none().0, &mut error);
if error.is_null() {
Ok(from_glib_full(ret))
} else {
Err(from_glib_full(error))
}
}
}
}
mod sealed {
pub trait Sealed {}
impl<T: super::IsA<super::Identity>> Sealed for T {}
}
/// Trait containing all [`struct@Identity`] methods.
///
/// # Implementors
///
/// [`Identity`][struct@crate::Identity], [`UnixGroup`][struct@crate::UnixGroup], [`UnixNetgroup`][struct@crate::UnixNetgroup], [`UnixUser`][struct@crate::UnixUser]
pub trait IdentityExt: IsA<Identity> + sealed::Sealed + 'static {
#[doc(alias = "polkit_identity_equal")]
fn equal(&self, b: &impl IsA<Identity>) -> bool {
unsafe {
from_glib(ffi::polkit_identity_equal(
self.as_ref().to_glib_none().0,
b.as_ref().to_glib_none().0,
))
}
}
#[doc(alias = "polkit_identity_hash")]
fn hash(&self) -> u32 {
unsafe { ffi::polkit_identity_hash(self.as_ref().to_glib_none().0) }
}
/// Serializes `self` to a string that can be used in
/// [`Identity::from_string()`][crate::Identity::from_string()].
///
/// # Returns
///
/// A string representing `self`. Free with `g_free()`.
#[doc(alias = "polkit_identity_to_string")]
fn to_string(&self) -> glib::GString {
unsafe {
from_glib_full(ffi::polkit_identity_to_string(
self.as_ref().to_glib_none().0,
))
}
}
}
impl<O: IsA<Identity>> IdentityExt for O {}