nm-rs 0.1.3

Rust bindings for the libnm library.
Documentation
// This file was generated by gir (https://github.com/gtk-rs/gir)
// from gir
// from gtk-girs (https://github.com/gtk-rs/gir-files)
// DO NOT EDIT

use crate::{ffi};
use glib::{prelude::*,signal::{connect_raw, SignalHandlerId},translate::*};
use std::{boxed::Box as Box_};

glib::wrapper! {
    ///
    ///
    /// This is an Abstract Base Class, you cannot instantiate it.
    ///
    /// ## Properties
    ///
    ///
    /// #### `client`
    ///  The NMClient instance as returned by nm_object_get_client().
    ///
    /// When an NMObject gets removed from the NMClient cache,
    /// the NMObject:path property stays unchanged, but this client
    /// instance gets reset to [`None`]. You can use this property to
    /// track removal of the object from the cache.
    ///
    /// Readable
    ///
    ///
    /// #### `path`
    ///  The D-Bus object path.
    ///
    /// The D-Bus path of an object instance never changes, even if the object
    /// gets removed from the cache. To see whether the object is still in the
    /// cache, check NMObject:client.
    ///
    /// Readable
    ///
    /// # Implements
    ///
    /// [`ObjectExt`][trait@crate::prelude::ObjectExt]
    #[doc(alias = "NMObject")]
    pub struct Object(Object<ffi::NMObject, ffi::NMObjectClass>);

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

impl Object {
        pub const NONE: Option<&'static Object> = None;
    
}

/// Trait containing all [`struct@Object`] methods.
///
/// # Implementors
///
/// [`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]
pub trait ObjectExt: IsA<Object> + 'static {
    //#[cfg(feature = "v1_24")]
    //#[cfg_attr(docsrs, doc(cfg(feature = "v1_24")))]
    //#[doc(alias = "nm_object_get_client")]
    //#[doc(alias = "get_client")]
    //fn client(&self) -> /*Unimplemented*/Option<Basic: Pointer> {
    //    unsafe { TODO: call ffi:nm_object_get_client() }
    //}

    /// Gets the DBus path of the #NMObject.
    ///
    /// # Returns
    ///
    /// the object's path. This is the internal string used by the
    /// object, and must not be modified.
    ///
    /// Note that the D-Bus path of an NMObject never changes, even
    /// if the instance gets removed from the cache. To find out
    /// whether the object is still alive/cached, check nm_object_get_client().
    #[doc(alias = "nm_object_get_path")]
    #[doc(alias = "get_path")]
    fn path(&self) -> glib::GString {
        unsafe {
            from_glib_none(ffi::nm_object_get_path(self.as_ref().to_glib_none().0))
        }
    }

    #[cfg(feature = "v1_34")]
    #[cfg_attr(docsrs, doc(cfg(feature = "v1_34")))]
    #[doc(alias = "client")]
    fn connect_client_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
        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) {
            let f: &F = &*(f as *const F);
            f(Object::from_glib_borrow(this).unsafe_cast_ref())
        }
        unsafe {
            let f: Box_<F> = Box_::new(f);
            connect_raw(self.as_ptr() as *mut _, c"notify::client".as_ptr() as *const _,
                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(notify_client_trampoline::<Self, F> as *const ())), Box_::into_raw(f))
        }
    }

    #[doc(alias = "path")]
    fn connect_path_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
        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) {
            let f: &F = &*(f as *const F);
            f(Object::from_glib_borrow(this).unsafe_cast_ref())
        }
        unsafe {
            let f: Box_<F> = Box_::new(f);
            connect_raw(self.as_ptr() as *mut _, c"notify::path".as_ptr() as *const _,
                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(notify_path_trampoline::<Self, F> as *const ())), Box_::into_raw(f))
        }
    }
}

impl<O: IsA<Object>> ObjectExt for O {}