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::*};
#[cfg(feature = "v1_46")]
#[cfg_attr(docsrs, doc(cfg(feature = "v1_46")))]
use glib::{signal::{connect_raw, SignalHandlerId},translate::*};
#[cfg(feature = "v1_46")]
#[cfg_attr(docsrs, doc(cfg(feature = "v1_46")))]
use std::{boxed::Box as Box_};

glib::wrapper! {
    /// HSR/PRP Settings
    ///
    /// ## Properties
    ///
    ///
    /// #### `multicast-spec`
    ///  The last byte of supervision address.
    ///
    /// Readable | Writeable
    ///
    ///
    /// #### `port1`
    ///  The port1 interface name of the HSR. This property is mandatory.
    ///
    /// Readable | Writeable
    ///
    ///
    /// #### `port2`
    ///  The port2 interface name of the HSR. This property is mandatory.
    ///
    /// Readable | Writeable
    ///
    ///
    /// #### `prp`
    ///  The protocol used by the interface, whether it is PRP or HSR.
    ///
    /// 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 = "NMSettingHsr")]
    pub struct SettingHsr(Object<ffi::NMSettingHsr, ffi::NMSettingHsrClass>) @extends Setting;

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

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

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

    ///
    /// # Returns
    ///
    /// the #NMSettingHsr:multicast_spec property of the setting
    #[cfg(feature = "v1_46")]
    #[cfg_attr(docsrs, doc(cfg(feature = "v1_46")))]
    #[doc(alias = "nm_setting_hsr_get_multicast_spec")]
    #[doc(alias = "get_multicast_spec")]
    #[doc(alias = "multicast-spec")]
    pub fn multicast_spec(&self) -> u32 {
        unsafe {
            ffi::nm_setting_hsr_get_multicast_spec(self.to_glib_none().0)
        }
    }

    ///
    /// # Returns
    ///
    /// the #NMSettingHsr:port1 property of the setting
    #[cfg(feature = "v1_46")]
    #[cfg_attr(docsrs, doc(cfg(feature = "v1_46")))]
    #[doc(alias = "nm_setting_hsr_get_port1")]
    #[doc(alias = "get_port1")]
    pub fn port1(&self) -> glib::GString {
        unsafe {
            from_glib_none(ffi::nm_setting_hsr_get_port1(self.to_glib_none().0))
        }
    }

    ///
    /// # Returns
    ///
    /// the #NMSettingHsr:port2 property of the setting
    #[cfg(feature = "v1_46")]
    #[cfg_attr(docsrs, doc(cfg(feature = "v1_46")))]
    #[doc(alias = "nm_setting_hsr_get_port2")]
    #[doc(alias = "get_port2")]
    pub fn port2(&self) -> glib::GString {
        unsafe {
            from_glib_none(ffi::nm_setting_hsr_get_port2(self.to_glib_none().0))
        }
    }

    ///
    /// # Returns
    ///
    /// the #NMSettingHsr:prp property of the setting
    #[cfg(feature = "v1_46")]
    #[cfg_attr(docsrs, doc(cfg(feature = "v1_46")))]
    #[doc(alias = "nm_setting_hsr_get_prp")]
    #[doc(alias = "get_prp")]
    #[doc(alias = "prp")]
    pub fn is_prp(&self) -> bool {
        unsafe {
            from_glib(ffi::nm_setting_hsr_get_prp(self.to_glib_none().0))
        }
    }

    /// The last byte of supervision address.
    #[cfg(feature = "v1_46")]
    #[cfg_attr(docsrs, doc(cfg(feature = "v1_46")))]
    #[doc(alias = "multicast-spec")]
    pub fn set_multicast_spec(&self, multicast_spec: u32) {
        ObjectExt::set_property(self,"multicast-spec", multicast_spec)
    }

    /// The port1 interface name of the HSR. This property is mandatory.
    #[cfg(feature = "v1_46")]
    #[cfg_attr(docsrs, doc(cfg(feature = "v1_46")))]
    pub fn set_port1(&self, port1: Option<&str>) {
        ObjectExt::set_property(self,"port1", port1)
    }

    /// The port2 interface name of the HSR. This property is mandatory.
    #[cfg(feature = "v1_46")]
    #[cfg_attr(docsrs, doc(cfg(feature = "v1_46")))]
    pub fn set_port2(&self, port2: Option<&str>) {
        ObjectExt::set_property(self,"port2", port2)
    }

    /// The protocol used by the interface, whether it is PRP or HSR.
    #[cfg(feature = "v1_46")]
    #[cfg_attr(docsrs, doc(cfg(feature = "v1_46")))]
    pub fn set_prp(&self, prp: bool) {
        ObjectExt::set_property(self,"prp", prp)
    }

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

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

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

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

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

// rustdoc-stripper-ignore-next
        /// A [builder-pattern] type to construct [`SettingHsr`] 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 SettingHsrBuilder {
            builder: glib::object::ObjectBuilder<'static, SettingHsr>,
        }

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

                            /// The last byte of supervision address.
                            #[cfg(feature = "v1_46")]
    #[cfg_attr(docsrs, doc(cfg(feature = "v1_46")))]
    pub fn multicast_spec(self, multicast_spec: u32) -> Self {
                            Self { builder: self.builder.property("multicast-spec", multicast_spec), }
                        }

                            /// The port1 interface name of the HSR. This property is mandatory.
                            #[cfg(feature = "v1_46")]
    #[cfg_attr(docsrs, doc(cfg(feature = "v1_46")))]
    pub fn port1(self, port1: impl Into<glib::GString>) -> Self {
                            Self { builder: self.builder.property("port1", port1.into()), }
                        }

                            /// The port2 interface name of the HSR. This property is mandatory.
                            #[cfg(feature = "v1_46")]
    #[cfg_attr(docsrs, doc(cfg(feature = "v1_46")))]
    pub fn port2(self, port2: impl Into<glib::GString>) -> Self {
                            Self { builder: self.builder.property("port2", port2.into()), }
                        }

                            /// The protocol used by the interface, whether it is PRP or HSR.
                            #[cfg(feature = "v1_46")]
    #[cfg_attr(docsrs, doc(cfg(feature = "v1_46")))]
    pub fn prp(self, prp: bool) -> Self {
                            Self { builder: self.builder.property("prp", prp), }
                        }

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