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

glib::wrapper! {
    /// IPVLAN Settings
    ///
    /// ## Properties
    ///
    ///
    /// #### `mode`
    ///  The IPVLAN mode. Valid values: [`SettingIpvlanMode::L2`][crate::SettingIpvlanMode::L2],
    /// [`SettingIpvlanMode::L3`][crate::SettingIpvlanMode::L3] and [`SettingIpvlanMode::L3s`][crate::SettingIpvlanMode::L3s].
    ///
    /// Readable | Writeable
    ///
    ///
    /// #### `parent`
    ///  If given, specifies the parent interface name or parent connection UUID
    /// from which this IPVLAN 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
    ///
    ///
    /// #### `private`
    ///  Whether the interface should be put in private mode.
    ///
    /// Readable | Writeable
    ///
    ///
    /// #### `vepa`
    ///  Whether the interface should be put in VEPA mode.
    ///
    /// 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 = "NMSettingIpvlan")]
    pub struct SettingIpvlan(Object<ffi::NMSettingIpvlan, ffi::NMSettingIpvlanClass>) @extends Setting;

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

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

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

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

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

    ///
    /// # Returns
    ///
    /// the #NMSettingIpvlan:private property of the setting
    #[cfg(feature = "v1_52")]
    #[cfg_attr(docsrs, doc(cfg(feature = "v1_52")))]
    #[doc(alias = "nm_setting_ipvlan_get_private")]
    #[doc(alias = "get_private")]
    #[doc(alias = "private")]
    pub fn is_private(&self) -> bool {
        unsafe {
            from_glib(ffi::nm_setting_ipvlan_get_private(self.to_glib_none().0))
        }
    }

    ///
    /// # Returns
    ///
    /// the #NMSettingIpvlan:vepa property of the setting
    #[cfg(feature = "v1_52")]
    #[cfg_attr(docsrs, doc(cfg(feature = "v1_52")))]
    #[doc(alias = "nm_setting_ipvlan_get_vepa")]
    #[doc(alias = "get_vepa")]
    #[doc(alias = "vepa")]
    pub fn is_vepa(&self) -> bool {
        unsafe {
            from_glib(ffi::nm_setting_ipvlan_get_vepa(self.to_glib_none().0))
        }
    }

    /// The IPVLAN mode. Valid values: [`SettingIpvlanMode::L2`][crate::SettingIpvlanMode::L2],
    /// [`SettingIpvlanMode::L3`][crate::SettingIpvlanMode::L3] and [`SettingIpvlanMode::L3s`][crate::SettingIpvlanMode::L3s].
    #[cfg(feature = "v1_52")]
    #[cfg_attr(docsrs, doc(cfg(feature = "v1_52")))]
    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 IPVLAN 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_52")]
    #[cfg_attr(docsrs, doc(cfg(feature = "v1_52")))]
    pub fn set_parent(&self, parent: Option<&str>) {
        ObjectExt::set_property(self,"parent", parent)
    }

    /// Whether the interface should be put in private mode.
    #[cfg(feature = "v1_52")]
    #[cfg_attr(docsrs, doc(cfg(feature = "v1_52")))]
    pub fn set_private(&self, private: bool) {
        ObjectExt::set_property(self,"private", private)
    }

    /// Whether the interface should be put in VEPA mode.
    #[cfg(feature = "v1_52")]
    #[cfg_attr(docsrs, doc(cfg(feature = "v1_52")))]
    pub fn set_vepa(&self, vepa: bool) {
        ObjectExt::set_property(self,"vepa", vepa)
    }

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

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

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

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

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

                            /// The IPVLAN mode. Valid values: [`SettingIpvlanMode::L2`][crate::SettingIpvlanMode::L2],
                            /// [`SettingIpvlanMode::L3`][crate::SettingIpvlanMode::L3] and [`SettingIpvlanMode::L3s`][crate::SettingIpvlanMode::L3s].
                            #[cfg(feature = "v1_52")]
    #[cfg_attr(docsrs, doc(cfg(feature = "v1_52")))]
    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 IPVLAN 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_52")]
    #[cfg_attr(docsrs, doc(cfg(feature = "v1_52")))]
    pub fn parent(self, parent: impl Into<glib::GString>) -> Self {
                            Self { builder: self.builder.property("parent", parent.into()), }
                        }

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

                            /// Whether the interface should be put in VEPA mode.
                            #[cfg(feature = "v1_52")]
    #[cfg_attr(docsrs, doc(cfg(feature = "v1_52")))]
    pub fn vepa(self, vepa: bool) -> Self {
                            Self { builder: self.builder.property("vepa", vepa), }
                        }

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