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,Setting};
use glib::{prelude::*,signal::{connect_raw, SignalHandlerId},translate::*};
use std::{boxed::Box as Box_};

glib::wrapper! {
    /// IEEE 802.15.4 (WPAN) MAC Settings
    ///
    /// ## Properties
    ///
    ///
    /// #### `channel`
    ///  IEEE 802.15.4 channel. A positive integer or -1, meaning "do not
    /// set, use whatever the device is already set to".
    ///
    /// Readable | Writeable
    ///
    ///
    /// #### `mac-address`
    ///  If specified, this connection will only apply to the IEEE 802.15.4 (WPAN)
    /// MAC layer device whose permanent MAC address matches.
    ///
    /// Readable | Writeable
    ///
    ///
    /// #### `page`
    ///  IEEE 802.15.4 channel page. A positive integer or -1, meaning "do not
    /// set, use whatever the device is already set to".
    ///
    /// Readable | Writeable
    ///
    ///
    /// #### `pan-id`
    ///  IEEE 802.15.4 Personal Area Network (PAN) identifier.
    ///
    /// Readable | Writeable
    ///
    ///
    /// #### `short-address`
    ///  Short IEEE 802.15.4 address to be used within a restricted environment.
    ///
    /// Readable | Writeable
    /// <details><summary><h4>Setting</h4></summary>
    ///
    ///
    /// #### `name`
    ///  The setting's name, which uniquely identifies the setting within the
    /// connection.  Each setting type has a name unique to that type, for
    /// example "ppp" or "802-11-wireless" or "802-3-ethernet".
    ///
    /// Readable
    /// </details>
    ///
    /// # Implements
    ///
    /// [`SettingExt`][trait@crate::prelude::SettingExt]
    #[doc(alias = "NMSettingWpan")]
    pub struct SettingWpan(Object<ffi::NMSettingWpan, ffi::NMSettingWpanClass>) @extends Setting;

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

impl SettingWpan {
    /// Creates a new #NMSettingWpan object with default values.
    ///
    /// # Returns
    ///
    /// the new empty #NMSettingWpan object
    #[cfg(feature = "v1_42")]
    #[cfg_attr(docsrs, doc(cfg(feature = "v1_42")))]
    #[doc(alias = "nm_setting_wpan_new")]
    pub fn new() -> SettingWpan {
        assert_initialized_main_thread!();
        unsafe {
            Setting::from_glib_full(ffi::nm_setting_wpan_new()).unsafe_cast()
        }
    }

            // rustdoc-stripper-ignore-next
            /// Creates a new builder-pattern struct instance to construct [`SettingWpan`] objects.
            ///
            /// This method returns an instance of [`SettingWpanBuilder`](crate::builders::SettingWpanBuilder) which can be used to create [`SettingWpan`] objects.
            pub fn builder() -> SettingWpanBuilder {
                SettingWpanBuilder::new()
            }
        

    ///
    /// # Returns
    ///
    /// the #NMSettingWpan:channel property of the setting
    #[cfg(feature = "v1_42")]
    #[cfg_attr(docsrs, doc(cfg(feature = "v1_42")))]
    #[doc(alias = "nm_setting_wpan_get_channel")]
    #[doc(alias = "get_channel")]
    pub fn channel(&self) -> i16 {
        unsafe {
            ffi::nm_setting_wpan_get_channel(self.to_glib_none().0)
        }
    }

    ///
    /// # Returns
    ///
    /// the #NMSettingWpan:mac-address property of the setting
    #[cfg(feature = "v1_42")]
    #[cfg_attr(docsrs, doc(cfg(feature = "v1_42")))]
    #[doc(alias = "nm_setting_wpan_get_mac_address")]
    #[doc(alias = "get_mac_address")]
    #[doc(alias = "mac-address")]
    pub fn mac_address(&self) -> glib::GString {
        unsafe {
            from_glib_none(ffi::nm_setting_wpan_get_mac_address(self.to_glib_none().0))
        }
    }

    ///
    /// # Returns
    ///
    /// the #NMSettingWpan:page property of the setting
    #[cfg(feature = "v1_42")]
    #[cfg_attr(docsrs, doc(cfg(feature = "v1_42")))]
    #[doc(alias = "nm_setting_wpan_get_page")]
    #[doc(alias = "get_page")]
    pub fn page(&self) -> i16 {
        unsafe {
            ffi::nm_setting_wpan_get_page(self.to_glib_none().0)
        }
    }

    ///
    /// # Returns
    ///
    /// the #NMSettingWpan:pan-id property of the setting
    #[cfg(feature = "v1_42")]
    #[cfg_attr(docsrs, doc(cfg(feature = "v1_42")))]
    #[doc(alias = "nm_setting_wpan_get_pan_id")]
    #[doc(alias = "get_pan_id")]
    #[doc(alias = "pan-id")]
    pub fn pan_id(&self) -> u16 {
        unsafe {
            ffi::nm_setting_wpan_get_pan_id(self.to_glib_none().0)
        }
    }

    ///
    /// # Returns
    ///
    /// the #NMSettingWpan:short-address property of the setting
    #[cfg(feature = "v1_42")]
    #[cfg_attr(docsrs, doc(cfg(feature = "v1_42")))]
    #[doc(alias = "nm_setting_wpan_get_short_address")]
    #[doc(alias = "get_short_address")]
    #[doc(alias = "short-address")]
    pub fn short_address(&self) -> u16 {
        unsafe {
            ffi::nm_setting_wpan_get_short_address(self.to_glib_none().0)
        }
    }

    #[cfg(not(feature = "v1_42"))]
    #[cfg_attr(docsrs, doc(cfg(not(feature = "v1_42"))))]
    pub fn channel(&self) -> i32 {
        ObjectExt::property(self, "channel")
    }

    /// IEEE 802.15.4 channel. A positive integer or -1, meaning "do not
    /// set, use whatever the device is already set to".
    #[cfg(feature = "v1_16")]
    #[cfg_attr(docsrs, doc(cfg(feature = "v1_16")))]
    pub fn set_channel(&self, channel: i32) {
        ObjectExt::set_property(self,"channel", channel)
    }

    #[cfg(not(feature = "v1_42"))]
    #[cfg_attr(docsrs, doc(cfg(not(feature = "v1_42"))))]
    #[doc(alias = "mac-address")]
    pub fn mac_address(&self) -> Option<glib::GString> {
        ObjectExt::property(self, "mac-address")
    }

    /// If specified, this connection will only apply to the IEEE 802.15.4 (WPAN)
    /// MAC layer device whose permanent MAC address matches.
    #[doc(alias = "mac-address")]
    pub fn set_mac_address(&self, mac_address: Option<&str>) {
        ObjectExt::set_property(self,"mac-address", mac_address)
    }

    #[cfg(not(feature = "v1_42"))]
    #[cfg_attr(docsrs, doc(cfg(not(feature = "v1_42"))))]
    pub fn page(&self) -> i32 {
        ObjectExt::property(self, "page")
    }

    /// IEEE 802.15.4 channel page. A positive integer or -1, meaning "do not
    /// set, use whatever the device is already set to".
    #[cfg(feature = "v1_16")]
    #[cfg_attr(docsrs, doc(cfg(feature = "v1_16")))]
    pub fn set_page(&self, page: i32) {
        ObjectExt::set_property(self,"page", page)
    }

    #[cfg(not(feature = "v1_42"))]
    #[cfg_attr(docsrs, doc(cfg(not(feature = "v1_42"))))]
    #[doc(alias = "pan-id")]
    pub fn pan_id(&self) -> u32 {
        ObjectExt::property(self, "pan-id")
    }

    /// IEEE 802.15.4 Personal Area Network (PAN) identifier.
    #[doc(alias = "pan-id")]
    pub fn set_pan_id(&self, pan_id: u32) {
        ObjectExt::set_property(self,"pan-id", pan_id)
    }

    #[cfg(not(feature = "v1_42"))]
    #[cfg_attr(docsrs, doc(cfg(not(feature = "v1_42"))))]
    #[doc(alias = "short-address")]
    pub fn short_address(&self) -> u32 {
        ObjectExt::property(self, "short-address")
    }

    /// Short IEEE 802.15.4 address to be used within a restricted environment.
    #[doc(alias = "short-address")]
    pub fn set_short_address(&self, short_address: u32) {
        ObjectExt::set_property(self,"short-address", short_address)
    }

    #[cfg(feature = "v1_16")]
    #[cfg_attr(docsrs, doc(cfg(feature = "v1_16")))]
    #[doc(alias = "channel")]
    pub fn connect_channel_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
        unsafe extern "C" fn notify_channel_trampoline<F: Fn(&SettingWpan) + 'static>(this: *mut ffi::NMSettingWpan, _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::channel".as_ptr() as *const _,
                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(notify_channel_trampoline::<F> as *const ())), Box_::into_raw(f))
        }
    }

    #[doc(alias = "mac-address")]
    pub fn connect_mac_address_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
        unsafe extern "C" fn notify_mac_address_trampoline<F: Fn(&SettingWpan) + 'static>(this: *mut ffi::NMSettingWpan, _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::mac-address".as_ptr() as *const _,
                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(notify_mac_address_trampoline::<F> as *const ())), Box_::into_raw(f))
        }
    }

    #[cfg(feature = "v1_16")]
    #[cfg_attr(docsrs, doc(cfg(feature = "v1_16")))]
    #[doc(alias = "page")]
    pub fn connect_page_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
        unsafe extern "C" fn notify_page_trampoline<F: Fn(&SettingWpan) + 'static>(this: *mut ffi::NMSettingWpan, _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::page".as_ptr() as *const _,
                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(notify_page_trampoline::<F> as *const ())), Box_::into_raw(f))
        }
    }

    #[doc(alias = "pan-id")]
    pub fn connect_pan_id_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
        unsafe extern "C" fn notify_pan_id_trampoline<F: Fn(&SettingWpan) + 'static>(this: *mut ffi::NMSettingWpan, _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::pan-id".as_ptr() as *const _,
                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(notify_pan_id_trampoline::<F> as *const ())), Box_::into_raw(f))
        }
    }

    #[doc(alias = "short-address")]
    pub fn connect_short_address_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
        unsafe extern "C" fn notify_short_address_trampoline<F: Fn(&SettingWpan) + 'static>(this: *mut ffi::NMSettingWpan, _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::short-address".as_ptr() as *const _,
                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(notify_short_address_trampoline::<F> as *const ())), Box_::into_raw(f))
        }
    }
}

#[cfg(feature = "v1_42")]
#[cfg_attr(docsrs, doc(cfg(feature = "v1_42")))]
impl Default for SettingWpan {
                     fn default() -> Self {
                         Self::new()
                     }
                 }

// rustdoc-stripper-ignore-next
        /// A [builder-pattern] type to construct [`SettingWpan`] objects.
        ///
        /// [builder-pattern]: https://doc.rust-lang.org/1.0.0/style/ownership/builders.html
#[must_use = "The builder must be built to be used"]
pub struct SettingWpanBuilder {
            builder: glib::object::ObjectBuilder<'static, SettingWpan>,
        }

        impl SettingWpanBuilder {
        fn new() -> Self {
            Self { builder: glib::object::Object::builder() }
        }

                            /// IEEE 802.15.4 channel. A positive integer or -1, meaning "do not
                            /// set, use whatever the device is already set to".
                            #[cfg(feature = "v1_16")]
    #[cfg_attr(docsrs, doc(cfg(feature = "v1_16")))]
    pub fn channel(self, channel: i32) -> Self {
                            Self { builder: self.builder.property("channel", channel), }
                        }

                            /// If specified, this connection will only apply to the IEEE 802.15.4 (WPAN)
                            /// MAC layer device whose permanent MAC address matches.
                            pub fn mac_address(self, mac_address: impl Into<glib::GString>) -> Self {
                            Self { builder: self.builder.property("mac-address", mac_address.into()), }
                        }

                            /// IEEE 802.15.4 channel page. A positive integer or -1, meaning "do not
                            /// set, use whatever the device is already set to".
                            #[cfg(feature = "v1_16")]
    #[cfg_attr(docsrs, doc(cfg(feature = "v1_16")))]
    pub fn page(self, page: i32) -> Self {
                            Self { builder: self.builder.property("page", page), }
                        }

                            /// IEEE 802.15.4 Personal Area Network (PAN) identifier.
                            pub fn pan_id(self, pan_id: u32) -> Self {
                            Self { builder: self.builder.property("pan-id", pan_id), }
                        }

                            /// Short IEEE 802.15.4 address to be used within a restricted environment.
                            pub fn short_address(self, short_address: u32) -> Self {
                            Self { builder: self.builder.property("short-address", short_address), }
                        }

    // rustdoc-stripper-ignore-next
    /// Build the [`SettingWpan`].
    #[must_use = "Building the object from the builder is usually expensive and is not expected to have side effects"]
    pub fn build(self) -> SettingWpan {
assert_initialized_main_thread!();
    self.builder.build() }
}