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

glib::wrapper! {
    /// Bond Port Settings
    ///
    /// ## Properties
    ///
    ///
    /// #### `prio`
    ///  The port priority for bond active port re-selection during failover. A
    /// higher number means a higher priority in selection. The primary port has
    /// the highest priority. This option is only compatible with active-backup,
    /// balance-tlb and balance-alb modes.
    ///
    /// Readable | Writeable
    ///
    ///
    /// #### `queue-id`
    ///  The queue ID of this bond port. The maximum value of queue ID is
    /// the number of TX queues currently active in device.
    ///
    /// 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 = "NMSettingBondPort")]
    pub struct SettingBondPort(Object<ffi::NMSettingBondPort, ffi::NMSettingBondPortClass>) @extends Setting;

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

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

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

    ///
    /// # Returns
    ///
    /// the #NMSettingBondPort:prio property of the setting
    #[cfg(feature = "v1_44")]
    #[cfg_attr(docsrs, doc(cfg(feature = "v1_44")))]
    #[doc(alias = "nm_setting_bond_port_get_prio")]
    #[doc(alias = "get_prio")]
    pub fn prio(&self) -> i32 {
        unsafe {
            ffi::nm_setting_bond_port_get_prio(self.to_glib_none().0)
        }
    }

    ///
    /// # Returns
    ///
    /// the #NMSettingBondPort:queue_id property of the setting
    #[cfg(feature = "v1_34")]
    #[cfg_attr(docsrs, doc(cfg(feature = "v1_34")))]
    #[doc(alias = "nm_setting_bond_port_get_queue_id")]
    #[doc(alias = "get_queue_id")]
    #[doc(alias = "queue-id")]
    pub fn queue_id(&self) -> u32 {
        unsafe {
            ffi::nm_setting_bond_port_get_queue_id(self.to_glib_none().0)
        }
    }

    /// The port priority for bond active port re-selection during failover. A
    /// higher number means a higher priority in selection. The primary port has
    /// the highest priority. This option is only compatible with active-backup,
    /// balance-tlb and balance-alb modes.
    #[cfg(feature = "v1_44")]
    #[cfg_attr(docsrs, doc(cfg(feature = "v1_44")))]
    pub fn set_prio(&self, prio: i32) {
        ObjectExt::set_property(self,"prio", prio)
    }

    /// The queue ID of this bond port. The maximum value of queue ID is
    /// the number of TX queues currently active in device.
    #[cfg(feature = "v1_34")]
    #[cfg_attr(docsrs, doc(cfg(feature = "v1_34")))]
    #[doc(alias = "queue-id")]
    pub fn set_queue_id(&self, queue_id: u32) {
        ObjectExt::set_property(self,"queue-id", queue_id)
    }

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

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

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

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

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

                            /// The port priority for bond active port re-selection during failover. A
                            /// higher number means a higher priority in selection. The primary port has
                            /// the highest priority. This option is only compatible with active-backup,
                            /// balance-tlb and balance-alb modes.
                            #[cfg(feature = "v1_44")]
    #[cfg_attr(docsrs, doc(cfg(feature = "v1_44")))]
    pub fn prio(self, prio: i32) -> Self {
                            Self { builder: self.builder.property("prio", prio), }
                        }

                            /// The queue ID of this bond port. The maximum value of queue ID is
                            /// the number of TX queues currently active in device.
                            #[cfg(feature = "v1_34")]
    #[cfg_attr(docsrs, doc(cfg(feature = "v1_34")))]
    pub fn queue_id(self, queue_id: u32) -> Self {
                            Self { builder: self.builder.property("queue-id", queue_id), }
                        }

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