nm_rs/auto/
setting_bond_port.rs

1// This file was generated by gir (https://github.com/gtk-rs/gir)
2// from gir
3// from gtk-girs (https://github.com/gtk-rs/gir-files)
4// DO NOT EDIT
5
6use crate::{ffi,Setting};
7use glib::{prelude::*};
8#[cfg(feature = "v1_34")]
9#[cfg_attr(docsrs, doc(cfg(feature = "v1_34")))]
10use glib::{signal::{connect_raw, SignalHandlerId},translate::*};
11#[cfg(feature = "v1_34")]
12#[cfg_attr(docsrs, doc(cfg(feature = "v1_34")))]
13use std::{boxed::Box as Box_};
14
15glib::wrapper! {
16    /// Bond Port Settings
17    ///
18    /// ## Properties
19    ///
20    ///
21    /// #### `prio`
22    ///  The port priority for bond active port re-selection during failover. A
23    /// higher number means a higher priority in selection. The primary port has
24    /// the highest priority. This option is only compatible with active-backup,
25    /// balance-tlb and balance-alb modes.
26    ///
27    /// Readable | Writeable
28    ///
29    ///
30    /// #### `queue-id`
31    ///  The queue ID of this bond port. The maximum value of queue ID is
32    /// the number of TX queues currently active in device.
33    ///
34    /// Readable | Writeable
35    /// <details><summary><h4>Setting</h4></summary>
36    ///
37    ///
38    /// #### `name`
39    ///  The setting's name, which uniquely identifies the setting within the
40    /// connection.  Each setting type has a name unique to that type, for
41    /// example "ppp" or "802-11-wireless" or "802-3-ethernet".
42    ///
43    /// Readable
44    /// </details>
45    ///
46    /// # Implements
47    ///
48    /// [`SettingExt`][trait@crate::prelude::SettingExt]
49    #[doc(alias = "NMSettingBondPort")]
50    pub struct SettingBondPort(Object<ffi::NMSettingBondPort, ffi::NMSettingBondPortClass>) @extends Setting;
51
52    match fn {
53        type_ => || ffi::nm_setting_bond_port_get_type(),
54    }
55}
56
57impl SettingBondPort {
58    /// Creates a new #NMSettingBondPort object with default values.
59    ///
60    /// # Returns
61    ///
62    /// the new empty #NMSettingBondPort object
63    #[cfg(feature = "v1_34")]
64    #[cfg_attr(docsrs, doc(cfg(feature = "v1_34")))]
65    #[doc(alias = "nm_setting_bond_port_new")]
66    pub fn new() -> SettingBondPort {
67        assert_initialized_main_thread!();
68        unsafe {
69            Setting::from_glib_full(ffi::nm_setting_bond_port_new()).unsafe_cast()
70        }
71    }
72
73            // rustdoc-stripper-ignore-next
74            /// Creates a new builder-pattern struct instance to construct [`SettingBondPort`] objects.
75            ///
76            /// This method returns an instance of [`SettingBondPortBuilder`](crate::builders::SettingBondPortBuilder) which can be used to create [`SettingBondPort`] objects.
77            pub fn builder() -> SettingBondPortBuilder {
78                SettingBondPortBuilder::new()
79            }
80        
81
82    ///
83    /// # Returns
84    ///
85    /// the #NMSettingBondPort:prio property of the setting
86    #[cfg(feature = "v1_44")]
87    #[cfg_attr(docsrs, doc(cfg(feature = "v1_44")))]
88    #[doc(alias = "nm_setting_bond_port_get_prio")]
89    #[doc(alias = "get_prio")]
90    pub fn prio(&self) -> i32 {
91        unsafe {
92            ffi::nm_setting_bond_port_get_prio(self.to_glib_none().0)
93        }
94    }
95
96    ///
97    /// # Returns
98    ///
99    /// the #NMSettingBondPort:queue_id property of the setting
100    #[cfg(feature = "v1_34")]
101    #[cfg_attr(docsrs, doc(cfg(feature = "v1_34")))]
102    #[doc(alias = "nm_setting_bond_port_get_queue_id")]
103    #[doc(alias = "get_queue_id")]
104    #[doc(alias = "queue-id")]
105    pub fn queue_id(&self) -> u32 {
106        unsafe {
107            ffi::nm_setting_bond_port_get_queue_id(self.to_glib_none().0)
108        }
109    }
110
111    /// The port priority for bond active port re-selection during failover. A
112    /// higher number means a higher priority in selection. The primary port has
113    /// the highest priority. This option is only compatible with active-backup,
114    /// balance-tlb and balance-alb modes.
115    #[cfg(feature = "v1_44")]
116    #[cfg_attr(docsrs, doc(cfg(feature = "v1_44")))]
117    pub fn set_prio(&self, prio: i32) {
118        ObjectExt::set_property(self,"prio", prio)
119    }
120
121    /// The queue ID of this bond port. The maximum value of queue ID is
122    /// the number of TX queues currently active in device.
123    #[cfg(feature = "v1_34")]
124    #[cfg_attr(docsrs, doc(cfg(feature = "v1_34")))]
125    #[doc(alias = "queue-id")]
126    pub fn set_queue_id(&self, queue_id: u32) {
127        ObjectExt::set_property(self,"queue-id", queue_id)
128    }
129
130    #[cfg(feature = "v1_44")]
131    #[cfg_attr(docsrs, doc(cfg(feature = "v1_44")))]
132    #[doc(alias = "prio")]
133    pub fn connect_prio_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
134        unsafe extern "C" fn notify_prio_trampoline<F: Fn(&SettingBondPort) + 'static>(this: *mut ffi::NMSettingBondPort, _param_spec: glib::ffi::gpointer, f: glib::ffi::gpointer) {
135            let f: &F = &*(f as *const F);
136            f(&from_glib_borrow(this))
137        }
138        unsafe {
139            let f: Box_<F> = Box_::new(f);
140            connect_raw(self.as_ptr() as *mut _, c"notify::prio".as_ptr() as *const _,
141                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(notify_prio_trampoline::<F> as *const ())), Box_::into_raw(f))
142        }
143    }
144
145    #[cfg(feature = "v1_34")]
146    #[cfg_attr(docsrs, doc(cfg(feature = "v1_34")))]
147    #[doc(alias = "queue-id")]
148    pub fn connect_queue_id_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
149        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) {
150            let f: &F = &*(f as *const F);
151            f(&from_glib_borrow(this))
152        }
153        unsafe {
154            let f: Box_<F> = Box_::new(f);
155            connect_raw(self.as_ptr() as *mut _, c"notify::queue-id".as_ptr() as *const _,
156                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(notify_queue_id_trampoline::<F> as *const ())), Box_::into_raw(f))
157        }
158    }
159}
160
161#[cfg(feature = "v1_34")]
162#[cfg_attr(docsrs, doc(cfg(feature = "v1_34")))]
163impl Default for SettingBondPort {
164                     fn default() -> Self {
165                         Self::new()
166                     }
167                 }
168
169// rustdoc-stripper-ignore-next
170        /// A [builder-pattern] type to construct [`SettingBondPort`] objects.
171        ///
172        /// [builder-pattern]: https://doc.rust-lang.org/1.0.0/style/ownership/builders.html
173#[must_use = "The builder must be built to be used"]
174pub struct SettingBondPortBuilder {
175            builder: glib::object::ObjectBuilder<'static, SettingBondPort>,
176        }
177
178        impl SettingBondPortBuilder {
179        fn new() -> Self {
180            Self { builder: glib::object::Object::builder() }
181        }
182
183                            /// The port priority for bond active port re-selection during failover. A
184                            /// higher number means a higher priority in selection. The primary port has
185                            /// the highest priority. This option is only compatible with active-backup,
186                            /// balance-tlb and balance-alb modes.
187                            #[cfg(feature = "v1_44")]
188    #[cfg_attr(docsrs, doc(cfg(feature = "v1_44")))]
189    pub fn prio(self, prio: i32) -> Self {
190                            Self { builder: self.builder.property("prio", prio), }
191                        }
192
193                            /// The queue ID of this bond port. The maximum value of queue ID is
194                            /// the number of TX queues currently active in device.
195                            #[cfg(feature = "v1_34")]
196    #[cfg_attr(docsrs, doc(cfg(feature = "v1_34")))]
197    pub fn queue_id(self, queue_id: u32) -> Self {
198                            Self { builder: self.builder.property("queue-id", queue_id), }
199                        }
200
201    // rustdoc-stripper-ignore-next
202    /// Build the [`SettingBondPort`].
203    #[must_use = "Building the object from the builder is usually expensive and is not expected to have side effects"]
204    pub fn build(self) -> SettingBondPort {
205assert_initialized_main_thread!();
206    self.builder.build() }
207}