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

glib::wrapper! {
    /// OvsBridge Link Settings
    ///
    /// ## Properties
    ///
    ///
    /// #### `datapath-type`
    ///  The data path type. One of "system", "netdev" or empty.
    ///
    /// Readable | Writeable
    ///
    ///
    /// #### `fail-mode`
    ///  The bridge failure mode. One of "secure", "standalone" or empty.
    ///
    /// Readable | Writeable
    ///
    ///
    /// #### `mcast-snooping-enable`
    ///  Enable or disable multicast snooping.
    ///
    /// Readable | Writeable
    ///
    ///
    /// #### `rstp-enable`
    ///  Enable or disable RSTP.
    ///
    /// Readable | Writeable
    ///
    ///
    /// #### `stp-enable`
    ///  Enable or disable STP.
    ///
    /// 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 = "NMSettingOvsBridge")]
    pub struct SettingOvsBridge(Object<ffi::NMSettingOvsBridge, ffi::NMSettingOvsBridgeClass>) @extends Setting;

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

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

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

    ///
    /// # Returns
    ///
    /// the #NMSettingOvsBridge:datapath_type property of the setting
    #[cfg(feature = "v1_42")]
    #[cfg_attr(docsrs, doc(cfg(feature = "v1_42")))]
    #[doc(alias = "nm_setting_ovs_bridge_get_datapath_type")]
    #[doc(alias = "get_datapath_type")]
    #[doc(alias = "datapath-type")]
    pub fn datapath_type(&self) -> glib::GString {
        unsafe {
            from_glib_none(ffi::nm_setting_ovs_bridge_get_datapath_type(self.to_glib_none().0))
        }
    }

    ///
    /// # Returns
    ///
    /// the #NMSettingOvsBridge:fail_mode property of the setting
    #[cfg(feature = "v1_10")]
    #[cfg_attr(docsrs, doc(cfg(feature = "v1_10")))]
    #[doc(alias = "nm_setting_ovs_bridge_get_fail_mode")]
    #[doc(alias = "get_fail_mode")]
    #[doc(alias = "fail-mode")]
    pub fn fail_mode(&self) -> glib::GString {
        unsafe {
            from_glib_none(ffi::nm_setting_ovs_bridge_get_fail_mode(self.to_glib_none().0))
        }
    }

    ///
    /// # Returns
    ///
    /// the #NMSettingOvsBridge:mcast_snooping_enable property of the setting
    #[cfg(feature = "v1_10")]
    #[cfg_attr(docsrs, doc(cfg(feature = "v1_10")))]
    #[doc(alias = "nm_setting_ovs_bridge_get_mcast_snooping_enable")]
    #[doc(alias = "get_mcast_snooping_enable")]
    #[doc(alias = "mcast-snooping-enable")]
    pub fn is_mcast_snooping_enable(&self) -> bool {
        unsafe {
            from_glib(ffi::nm_setting_ovs_bridge_get_mcast_snooping_enable(self.to_glib_none().0))
        }
    }

    ///
    /// # Returns
    ///
    /// the #NMSettingOvsBridge:rstp_enable property of the setting
    #[cfg(feature = "v1_10")]
    #[cfg_attr(docsrs, doc(cfg(feature = "v1_10")))]
    #[doc(alias = "nm_setting_ovs_bridge_get_rstp_enable")]
    #[doc(alias = "get_rstp_enable")]
    #[doc(alias = "rstp-enable")]
    pub fn is_rstp_enable(&self) -> bool {
        unsafe {
            from_glib(ffi::nm_setting_ovs_bridge_get_rstp_enable(self.to_glib_none().0))
        }
    }

    ///
    /// # Returns
    ///
    /// the #NMSettingOvsBridge:stp_enable property of the setting
    #[cfg(feature = "v1_10")]
    #[cfg_attr(docsrs, doc(cfg(feature = "v1_10")))]
    #[doc(alias = "nm_setting_ovs_bridge_get_stp_enable")]
    #[doc(alias = "get_stp_enable")]
    #[doc(alias = "stp-enable")]
    pub fn is_stp_enable(&self) -> bool {
        unsafe {
            from_glib(ffi::nm_setting_ovs_bridge_get_stp_enable(self.to_glib_none().0))
        }
    }

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

    /// The data path type. One of "system", "netdev" or empty.
    #[cfg(feature = "v1_20")]
    #[cfg_attr(docsrs, doc(cfg(feature = "v1_20")))]
    #[doc(alias = "datapath-type")]
    pub fn set_datapath_type(&self, datapath_type: Option<&str>) {
        ObjectExt::set_property(self,"datapath-type", datapath_type)
    }

    /// The bridge failure mode. One of "secure", "standalone" or empty.
    #[cfg(feature = "v1_10")]
    #[cfg_attr(docsrs, doc(cfg(feature = "v1_10")))]
    #[doc(alias = "fail-mode")]
    pub fn set_fail_mode(&self, fail_mode: Option<&str>) {
        ObjectExt::set_property(self,"fail-mode", fail_mode)
    }

    /// Enable or disable multicast snooping.
    #[cfg(feature = "v1_10")]
    #[cfg_attr(docsrs, doc(cfg(feature = "v1_10")))]
    #[doc(alias = "mcast-snooping-enable")]
    pub fn set_mcast_snooping_enable(&self, mcast_snooping_enable: bool) {
        ObjectExt::set_property(self,"mcast-snooping-enable", mcast_snooping_enable)
    }

    /// Enable or disable RSTP.
    #[cfg(feature = "v1_10")]
    #[cfg_attr(docsrs, doc(cfg(feature = "v1_10")))]
    #[doc(alias = "rstp-enable")]
    pub fn set_rstp_enable(&self, rstp_enable: bool) {
        ObjectExt::set_property(self,"rstp-enable", rstp_enable)
    }

    /// Enable or disable STP.
    #[cfg(feature = "v1_10")]
    #[cfg_attr(docsrs, doc(cfg(feature = "v1_10")))]
    #[doc(alias = "stp-enable")]
    pub fn set_stp_enable(&self, stp_enable: bool) {
        ObjectExt::set_property(self,"stp-enable", stp_enable)
    }

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

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

    #[cfg(feature = "v1_10")]
    #[cfg_attr(docsrs, doc(cfg(feature = "v1_10")))]
    #[doc(alias = "mcast-snooping-enable")]
    pub fn connect_mcast_snooping_enable_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
        unsafe extern "C" fn notify_mcast_snooping_enable_trampoline<F: Fn(&SettingOvsBridge) + 'static>(this: *mut ffi::NMSettingOvsBridge, _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::mcast-snooping-enable".as_ptr() as *const _,
                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(notify_mcast_snooping_enable_trampoline::<F> as *const ())), Box_::into_raw(f))
        }
    }

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

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

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

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

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

                            /// The data path type. One of "system", "netdev" or empty.
                            #[cfg(feature = "v1_20")]
    #[cfg_attr(docsrs, doc(cfg(feature = "v1_20")))]
    pub fn datapath_type(self, datapath_type: impl Into<glib::GString>) -> Self {
                            Self { builder: self.builder.property("datapath-type", datapath_type.into()), }
                        }

                            /// The bridge failure mode. One of "secure", "standalone" or empty.
                            #[cfg(feature = "v1_10")]
    #[cfg_attr(docsrs, doc(cfg(feature = "v1_10")))]
    pub fn fail_mode(self, fail_mode: impl Into<glib::GString>) -> Self {
                            Self { builder: self.builder.property("fail-mode", fail_mode.into()), }
                        }

                            /// Enable or disable multicast snooping.
                            #[cfg(feature = "v1_10")]
    #[cfg_attr(docsrs, doc(cfg(feature = "v1_10")))]
    pub fn mcast_snooping_enable(self, mcast_snooping_enable: bool) -> Self {
                            Self { builder: self.builder.property("mcast-snooping-enable", mcast_snooping_enable), }
                        }

                            /// Enable or disable RSTP.
                            #[cfg(feature = "v1_10")]
    #[cfg_attr(docsrs, doc(cfg(feature = "v1_10")))]
    pub fn rstp_enable(self, rstp_enable: bool) -> Self {
                            Self { builder: self.builder.property("rstp-enable", rstp_enable), }
                        }

                            /// Enable or disable STP.
                            #[cfg(feature = "v1_10")]
    #[cfg_attr(docsrs, doc(cfg(feature = "v1_10")))]
    pub fn stp_enable(self, stp_enable: bool) -> Self {
                            Self { builder: self.builder.property("stp-enable", stp_enable), }
                        }

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