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

glib::wrapper! {
    /// MAC VLAN Settings
    ///
    /// ## Properties
    ///
    ///
    /// #### `mode`
    ///  The macvlan mode, which specifies the communication mechanism between multiple
    /// macvlans on the same lower device.
    ///
    /// Readable | Writeable
    ///
    ///
    /// #### `parent`
    ///  If given, specifies the parent interface name or parent connection UUID
    /// from which this MAC-VLAN interface should be created.  If this property is
    /// not specified, the connection must contain an #NMSettingWired setting
    /// with a #NMSettingWired:mac-address property.
    ///
    /// Readable | Writeable
    ///
    ///
    /// #### `promiscuous`
    ///  Whether the parent interface should be put in promiscuous mode (true by default).
    ///
    /// Readable | Writeable
    ///
    ///
    /// #### `tap`
    ///  Whether the interface should be a MACVTAP.
    ///
    /// 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 = "NMSettingMacvlan")]
    pub struct SettingMacvlan(Object<ffi::NMSettingMacvlan, ffi::NMSettingMacvlanClass>) @extends Setting;

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

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

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

    ///
    /// # Returns
    ///
    /// the #NMSettingMacvlan:mode property of the setting
    #[cfg(feature = "v1_2")]
    #[cfg_attr(docsrs, doc(cfg(feature = "v1_2")))]
    #[doc(alias = "nm_setting_macvlan_get_mode")]
    #[doc(alias = "get_mode")]
    pub fn mode(&self) -> SettingMacvlanMode {
        unsafe {
            from_glib(ffi::nm_setting_macvlan_get_mode(self.to_glib_none().0))
        }
    }

    ///
    /// # Returns
    ///
    /// the #NMSettingMacvlan:parent property of the setting
    #[cfg(feature = "v1_2")]
    #[cfg_attr(docsrs, doc(cfg(feature = "v1_2")))]
    #[doc(alias = "nm_setting_macvlan_get_parent")]
    #[doc(alias = "get_parent")]
    pub fn parent(&self) -> glib::GString {
        unsafe {
            from_glib_none(ffi::nm_setting_macvlan_get_parent(self.to_glib_none().0))
        }
    }

    ///
    /// # Returns
    ///
    /// the #NMSettingMacvlan:promiscuous property of the setting
    #[cfg(feature = "v1_2")]
    #[cfg_attr(docsrs, doc(cfg(feature = "v1_2")))]
    #[doc(alias = "nm_setting_macvlan_get_promiscuous")]
    #[doc(alias = "get_promiscuous")]
    #[doc(alias = "promiscuous")]
    pub fn is_promiscuous(&self) -> bool {
        unsafe {
            from_glib(ffi::nm_setting_macvlan_get_promiscuous(self.to_glib_none().0))
        }
    }

    ///
    /// # Returns
    ///
    /// the #NMSettingMacvlan:tap property of the setting
    #[cfg(feature = "v1_2")]
    #[cfg_attr(docsrs, doc(cfg(feature = "v1_2")))]
    #[doc(alias = "nm_setting_macvlan_get_tap")]
    #[doc(alias = "get_tap")]
    #[doc(alias = "tap")]
    pub fn is_tap(&self) -> bool {
        unsafe {
            from_glib(ffi::nm_setting_macvlan_get_tap(self.to_glib_none().0))
        }
    }

    /// The macvlan mode, which specifies the communication mechanism between multiple
    /// macvlans on the same lower device.
    #[cfg(feature = "v1_2")]
    #[cfg_attr(docsrs, doc(cfg(feature = "v1_2")))]
    pub fn set_mode(&self, mode: u32) {
        ObjectExt::set_property(self,"mode", mode)
    }

    /// If given, specifies the parent interface name or parent connection UUID
    /// from which this MAC-VLAN interface should be created.  If this property is
    /// not specified, the connection must contain an #NMSettingWired setting
    /// with a #NMSettingWired:mac-address property.
    #[cfg(feature = "v1_2")]
    #[cfg_attr(docsrs, doc(cfg(feature = "v1_2")))]
    pub fn set_parent(&self, parent: Option<&str>) {
        ObjectExt::set_property(self,"parent", parent)
    }

    /// Whether the parent interface should be put in promiscuous mode (true by default).
    #[cfg(feature = "v1_2")]
    #[cfg_attr(docsrs, doc(cfg(feature = "v1_2")))]
    pub fn set_promiscuous(&self, promiscuous: bool) {
        ObjectExt::set_property(self,"promiscuous", promiscuous)
    }

    /// Whether the interface should be a MACVTAP.
    #[cfg(feature = "v1_2")]
    #[cfg_attr(docsrs, doc(cfg(feature = "v1_2")))]
    pub fn set_tap(&self, tap: bool) {
        ObjectExt::set_property(self,"tap", tap)
    }

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

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

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

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

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

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

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

                            /// The macvlan mode, which specifies the communication mechanism between multiple
                            /// macvlans on the same lower device.
                            #[cfg(feature = "v1_2")]
    #[cfg_attr(docsrs, doc(cfg(feature = "v1_2")))]
    pub fn mode(self, mode: u32) -> Self {
                            Self { builder: self.builder.property("mode", mode), }
                        }

                            /// If given, specifies the parent interface name or parent connection UUID
                            /// from which this MAC-VLAN interface should be created.  If this property is
                            /// not specified, the connection must contain an #NMSettingWired setting
                            /// with a #NMSettingWired:mac-address property.
                            #[cfg(feature = "v1_2")]
    #[cfg_attr(docsrs, doc(cfg(feature = "v1_2")))]
    pub fn parent(self, parent: impl Into<glib::GString>) -> Self {
                            Self { builder: self.builder.property("parent", parent.into()), }
                        }

                            /// Whether the parent interface should be put in promiscuous mode (true by default).
                            #[cfg(feature = "v1_2")]
    #[cfg_attr(docsrs, doc(cfg(feature = "v1_2")))]
    pub fn promiscuous(self, promiscuous: bool) -> Self {
                            Self { builder: self.builder.property("promiscuous", promiscuous), }
                        }

                            /// Whether the interface should be a MACVTAP.
                            #[cfg(feature = "v1_2")]
    #[cfg_attr(docsrs, doc(cfg(feature = "v1_2")))]
    pub fn tap(self, tap: bool) -> Self {
                            Self { builder: self.builder.property("tap", tap), }
                        }

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