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,Object};
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
    ///
    ///
    /// #### `family`
    ///  The IP address family of the configuration; either
    /// <literal>AF_INET</literal> or <literal>AF_INET6</literal>.
    ///
    /// Readable
    ///
    ///
    /// #### `options`
    ///  The #GHashTable containing options of the configuration.
    ///
    /// Readable
    /// <details><summary><h4>Object</h4></summary>
    ///
    ///
    /// #### `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
    /// </details>
    ///
    /// # Implements
    ///
    /// [`ObjectExt`][trait@crate::prelude::ObjectExt]
    #[doc(alias = "NMDhcpConfig")]
    pub struct DhcpConfig(Object<ffi::NMDhcpConfig, ffi::NMDhcpConfigClass>) @extends Object;

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

impl DhcpConfig {
    /// Gets the IP address family of the configuration
    ///
    /// # Returns
    ///
    /// the IP address family; either <literal>AF_INET</literal> or
    ///   <literal>AF_INET6</literal>
    #[doc(alias = "nm_dhcp_config_get_family")]
    #[doc(alias = "get_family")]
    pub fn family(&self) -> i32 {
        unsafe {
            ffi::nm_dhcp_config_get_family(self.to_glib_none().0)
        }
    }

    /// Gets one option by option name.
    /// ## `option`
    /// the option to retrieve
    ///
    /// # Returns
    ///
    /// the configuration option's value. This is the internal string used by the
    /// configuration, and must not be modified.
    #[doc(alias = "nm_dhcp_config_get_one_option")]
    #[doc(alias = "get_one_option")]
    pub fn one_option(&self, option: &str) -> glib::GString {
        unsafe {
            from_glib_none(ffi::nm_dhcp_config_get_one_option(self.to_glib_none().0, option.to_glib_none().0))
        }
    }

    //#[doc(alias = "nm_dhcp_config_get_options")]
    //#[doc(alias = "get_options")]
    //pub fn options(&self) -> /*Unknown conversion*//*Unimplemented*/HashTable TypeId { ns_id: 0, id: 28 }/TypeId { ns_id: 0, id: 28 } {
    //    unsafe { TODO: call ffi:nm_dhcp_config_get_options() }
    //}

    #[doc(alias = "family")]
    pub fn connect_family_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
        unsafe extern "C" fn notify_family_trampoline<F: Fn(&DhcpConfig) + 'static>(this: *mut ffi::NMDhcpConfig, _param_spec: glib::ffi::gpointer, f: glib::ffi::gpointer) {
            let f: &F = &*(f as *const F);
            f(&from_glib_borrow(this))
        }
        unsafe {
            let f: Box_<F> = Box_::new(f);
            connect_raw(self.as_ptr() as *mut _, c"notify::family".as_ptr() as *const _,
                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(notify_family_trampoline::<F> as *const ())), Box_::into_raw(f))
        }
    }

    #[doc(alias = "options")]
    pub fn connect_options_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
        unsafe extern "C" fn notify_options_trampoline<F: Fn(&DhcpConfig) + 'static>(this: *mut ffi::NMDhcpConfig, _param_spec: glib::ffi::gpointer, f: glib::ffi::gpointer) {
            let f: &F = &*(f as *const F);
            f(&from_glib_borrow(this))
        }
        unsafe {
            let f: Box_<F> = Box_::new(f);
            connect_raw(self.as_ptr() as *mut _, c"notify::options".as_ptr() as *const _,
                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(notify_options_trampoline::<F> as *const ())), Box_::into_raw(f))
        }
    }
}