polkit_rs/auto/
unix_netgroup.rs1use crate::{Identity, ffi};
6use glib::{
7 prelude::*,
8 signal::{SignalHandlerId, connect_raw},
9 translate::*,
10};
11use std::boxed::Box as Box_;
12
13glib::wrapper! {
14 #[doc(alias = "PolkitUnixNetgroup")]
15 pub struct UnixNetgroup(Object<ffi::PolkitUnixNetgroup, ffi::PolkitUnixNetgroupClass>) @implements Identity;
16
17 match fn {
18 type_ => || ffi::polkit_unix_netgroup_get_type(),
19 }
20}
21
22impl UnixNetgroup {
23 #[doc(alias = "polkit_unix_netgroup_get_name")]
24 #[doc(alias = "get_name")]
25 pub fn name(&self) -> glib::GString {
26 unsafe { from_glib_none(ffi::polkit_unix_netgroup_get_name(self.to_glib_none().0)) }
27 }
28
29 #[doc(alias = "polkit_unix_netgroup_set_name")]
30 #[doc(alias = "name")]
31 pub fn set_name(&self, name: &str) {
32 unsafe {
33 ffi::polkit_unix_netgroup_set_name(self.to_glib_none().0, name.to_glib_none().0);
34 }
35 }
36
37 #[doc(alias = "polkit_unix_netgroup_new")]
38 pub fn new(name: &str) -> Self {
39 let identify: Identity =
40 unsafe { from_glib_full(ffi::polkit_unix_netgroup_new(name.to_glib_none().0)) };
41 identify.dynamic_cast().expect("it should always work")
42 }
43
44 #[doc(alias = "name")]
45 pub fn connect_name_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
46 unsafe extern "C" fn notify_name_trampoline<F: Fn(&UnixNetgroup) + 'static>(
47 this: *mut ffi::PolkitUnixNetgroup,
48 _param_spec: glib::ffi::gpointer,
49 f: glib::ffi::gpointer,
50 ) {
51 unsafe {
52 let f: &F = &*(f as *const F);
53 f(&from_glib_borrow(this))
54 }
55 }
56 unsafe {
57 let f: Box_<F> = Box_::new(f);
58 connect_raw(
59 self.as_ptr() as *mut _,
60 c"notify::name".as_ptr() as *const _,
61 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
62 notify_name_trampoline::<F> as *const (),
63 )),
64 Box_::into_raw(f),
65 )
66 }
67 }
68}
69
70impl std::fmt::Display for UnixNetgroup {
71 #[inline]
72 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
73 f.write_str(&self.name())
74 }
75}