nm_rs/auto/object.rs
1// This file was generated by gir (https://github.com/gtk-rs/gir)
2// from gir
3// from gtk-girs (https://github.com/gtk-rs/gir-files)
4// DO NOT EDIT
5
6use crate::{ffi};
7use glib::{prelude::*,signal::{connect_raw, SignalHandlerId},translate::*};
8use std::{boxed::Box as Box_};
9
10glib::wrapper! {
11 ///
12 ///
13 /// This is an Abstract Base Class, you cannot instantiate it.
14 ///
15 /// ## Properties
16 ///
17 ///
18 /// #### `client`
19 /// The NMClient instance as returned by nm_object_get_client().
20 ///
21 /// When an NMObject gets removed from the NMClient cache,
22 /// the NMObject:path property stays unchanged, but this client
23 /// instance gets reset to [`None`]. You can use this property to
24 /// track removal of the object from the cache.
25 ///
26 /// Readable
27 ///
28 ///
29 /// #### `path`
30 /// The D-Bus object path.
31 ///
32 /// The D-Bus path of an object instance never changes, even if the object
33 /// gets removed from the cache. To see whether the object is still in the
34 /// cache, check NMObject:client.
35 ///
36 /// Readable
37 ///
38 /// # Implements
39 ///
40 /// [`ObjectExt`][trait@crate::prelude::ObjectExt]
41 #[doc(alias = "NMObject")]
42 pub struct Object(Object<ffi::NMObject, ffi::NMObjectClass>);
43
44 match fn {
45 type_ => || ffi::nm_object_get_type(),
46 }
47}
48
49impl Object {
50 pub const NONE: Option<&'static Object> = None;
51
52}
53
54/// Trait containing all [`struct@Object`] methods.
55///
56/// # Implementors
57///
58/// [`AccessPoint`][struct@crate::AccessPoint], [`ActiveConnection`][struct@crate::ActiveConnection], [`Checkpoint`][struct@crate::Checkpoint], [`Device`][struct@crate::Device], [`DhcpConfig`][struct@crate::DhcpConfig], [`IPConfig`][struct@crate::IPConfig], [`Object`][struct@crate::Object], [`RemoteConnection`][struct@crate::RemoteConnection], [`WifiP2PPeer`][struct@crate::WifiP2PPeer], [`WimaxNsp`][struct@crate::WimaxNsp]
59pub trait ObjectExt: IsA<Object> + 'static {
60 //#[cfg(feature = "v1_24")]
61 //#[cfg_attr(docsrs, doc(cfg(feature = "v1_24")))]
62 //#[doc(alias = "nm_object_get_client")]
63 //#[doc(alias = "get_client")]
64 //fn client(&self) -> /*Unimplemented*/Option<Basic: Pointer> {
65 // unsafe { TODO: call ffi:nm_object_get_client() }
66 //}
67
68 /// Gets the DBus path of the #NMObject.
69 ///
70 /// # Returns
71 ///
72 /// the object's path. This is the internal string used by the
73 /// object, and must not be modified.
74 ///
75 /// Note that the D-Bus path of an NMObject never changes, even
76 /// if the instance gets removed from the cache. To find out
77 /// whether the object is still alive/cached, check nm_object_get_client().
78 #[doc(alias = "nm_object_get_path")]
79 #[doc(alias = "get_path")]
80 fn path(&self) -> glib::GString {
81 unsafe {
82 from_glib_none(ffi::nm_object_get_path(self.as_ref().to_glib_none().0))
83 }
84 }
85
86 #[cfg(feature = "v1_34")]
87 #[cfg_attr(docsrs, doc(cfg(feature = "v1_34")))]
88 #[doc(alias = "client")]
89 fn connect_client_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
90 unsafe extern "C" fn notify_client_trampoline<P: IsA<Object>, F: Fn(&P) + 'static>(this: *mut ffi::NMObject, _param_spec: glib::ffi::gpointer, f: glib::ffi::gpointer) {
91 let f: &F = &*(f as *const F);
92 f(Object::from_glib_borrow(this).unsafe_cast_ref())
93 }
94 unsafe {
95 let f: Box_<F> = Box_::new(f);
96 connect_raw(self.as_ptr() as *mut _, c"notify::client".as_ptr() as *const _,
97 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(notify_client_trampoline::<Self, F> as *const ())), Box_::into_raw(f))
98 }
99 }
100
101 #[doc(alias = "path")]
102 fn connect_path_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
103 unsafe extern "C" fn notify_path_trampoline<P: IsA<Object>, F: Fn(&P) + 'static>(this: *mut ffi::NMObject, _param_spec: glib::ffi::gpointer, f: glib::ffi::gpointer) {
104 let f: &F = &*(f as *const F);
105 f(Object::from_glib_borrow(this).unsafe_cast_ref())
106 }
107 unsafe {
108 let f: Box_<F> = Box_::new(f);
109 connect_raw(self.as_ptr() as *mut _, c"notify::path".as_ptr() as *const _,
110 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(notify_path_trampoline::<Self, F> as *const ())), Box_::into_raw(f))
111 }
112 }
113}
114
115impl<O: IsA<Object>> ObjectExt for O {}