nm_rs/auto/
setting_infiniband.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::*,signal::{connect_raw, SignalHandlerId},translate::*};
8use std::{boxed::Box as Box_};
9
10glib::wrapper! {
11    /// Infiniband Settings
12    ///
13    /// ## Properties
14    ///
15    ///
16    /// #### `mac-address`
17    ///  If specified, this connection will only apply to the IPoIB device whose
18    /// permanent MAC address matches. This property does not change the MAC
19    /// address of the device (i.e. MAC spoofing).
20    ///
21    /// Readable | Writeable
22    ///
23    ///
24    /// #### `mtu`
25    ///  If non-zero, only transmit packets of the specified size or smaller,
26    /// breaking larger packets up into multiple frames.
27    ///
28    /// Readable | Writeable
29    ///
30    ///
31    /// #### `p-key`
32    ///  The InfiniBand p-key to use for this device. A value of -1 means to use
33    /// the default p-key (aka "the p-key at index 0"). Otherwise, it is a
34    /// 16-bit unsigned integer, whose high bit 0x8000 is set if it is a "full
35    /// membership" p-key. The values 0 and 0x8000 are not allowed.
36    ///
37    /// With the p-key set, the interface name is always "$parent.$p_key".
38    /// Setting "connection.interface-name" to another name is not supported.
39    ///
40    /// Note that kernel will internally always set the full membership bit,
41    /// although the interface name does not reflect that. Usually the user
42    /// would want to configure a full membership p-key with 0x8000 flag set.
43    ///
44    /// Readable | Writeable
45    ///
46    ///
47    /// #### `parent`
48    ///  The interface name of the parent device of this device. Normally [`None`],
49    /// but if the #NMSettingInfiniband:p_key property is set, then you must
50    /// specify the base device by setting either this property or
51    /// #NMSettingInfiniband:mac-address.
52    ///
53    /// Readable | Writeable
54    ///
55    ///
56    /// #### `transport-mode`
57    ///  The IP-over-InfiniBand transport mode. Either "datagram" or
58    /// "connected".
59    ///
60    /// Readable | Writeable
61    /// <details><summary><h4>Setting</h4></summary>
62    ///
63    ///
64    /// #### `name`
65    ///  The setting's name, which uniquely identifies the setting within the
66    /// connection.  Each setting type has a name unique to that type, for
67    /// example "ppp" or "802-11-wireless" or "802-3-ethernet".
68    ///
69    /// Readable
70    /// </details>
71    ///
72    /// # Implements
73    ///
74    /// [`SettingExt`][trait@crate::prelude::SettingExt]
75    #[doc(alias = "NMSettingInfiniband")]
76    pub struct SettingInfiniband(Object<ffi::NMSettingInfiniband, ffi::NMSettingInfinibandClass>) @extends Setting;
77
78    match fn {
79        type_ => || ffi::nm_setting_infiniband_get_type(),
80    }
81}
82
83impl SettingInfiniband {
84    /// Creates a new #NMSettingInfiniband object with default values.
85    ///
86    /// # Returns
87    ///
88    /// the new empty #NMSettingInfiniband object
89    #[doc(alias = "nm_setting_infiniband_new")]
90    pub fn new() -> SettingInfiniband {
91        assert_initialized_main_thread!();
92        unsafe {
93            Setting::from_glib_full(ffi::nm_setting_infiniband_new()).unsafe_cast()
94        }
95    }
96
97            // rustdoc-stripper-ignore-next
98            /// Creates a new builder-pattern struct instance to construct [`SettingInfiniband`] objects.
99            ///
100            /// This method returns an instance of [`SettingInfinibandBuilder`](crate::builders::SettingInfinibandBuilder) which can be used to create [`SettingInfiniband`] objects.
101            pub fn builder() -> SettingInfinibandBuilder {
102                SettingInfinibandBuilder::new()
103            }
104        
105
106    ///
107    /// # Returns
108    ///
109    /// the #NMSettingInfiniband:mac-address property of the setting
110    #[doc(alias = "nm_setting_infiniband_get_mac_address")]
111    #[doc(alias = "get_mac_address")]
112    #[doc(alias = "mac-address")]
113    pub fn mac_address(&self) -> glib::GString {
114        unsafe {
115            from_glib_none(ffi::nm_setting_infiniband_get_mac_address(self.to_glib_none().0))
116        }
117    }
118
119    ///
120    /// # Returns
121    ///
122    /// the #NMSettingInfiniband:mtu property of the setting
123    #[doc(alias = "nm_setting_infiniband_get_mtu")]
124    #[doc(alias = "get_mtu")]
125    pub fn mtu(&self) -> u32 {
126        unsafe {
127            ffi::nm_setting_infiniband_get_mtu(self.to_glib_none().0)
128        }
129    }
130
131    /// Returns the P_Key to use for this device. A value of -1 means to
132    /// use the default P_Key (aka "the P_Key at index 0"). Otherwise, it is
133    /// a 16-bit unsigned integer.
134    ///
135    /// # Returns
136    ///
137    /// the IPoIB P_Key
138    #[doc(alias = "nm_setting_infiniband_get_p_key")]
139    #[doc(alias = "get_p_key")]
140    #[doc(alias = "p-key")]
141    pub fn p_key(&self) -> i32 {
142        unsafe {
143            ffi::nm_setting_infiniband_get_p_key(self.to_glib_none().0)
144        }
145    }
146
147    /// Returns the parent interface name for this device, if set.
148    ///
149    /// # Returns
150    ///
151    /// the parent interface name
152    #[doc(alias = "nm_setting_infiniband_get_parent")]
153    #[doc(alias = "get_parent")]
154    pub fn parent(&self) -> glib::GString {
155        unsafe {
156            from_glib_none(ffi::nm_setting_infiniband_get_parent(self.to_glib_none().0))
157        }
158    }
159
160    /// Returns the transport mode for this device. Either 'datagram' or
161    /// 'connected'.
162    ///
163    /// # Returns
164    ///
165    /// the IPoIB transport mode
166    #[doc(alias = "nm_setting_infiniband_get_transport_mode")]
167    #[doc(alias = "get_transport_mode")]
168    #[doc(alias = "transport-mode")]
169    pub fn transport_mode(&self) -> glib::GString {
170        unsafe {
171            from_glib_none(ffi::nm_setting_infiniband_get_transport_mode(self.to_glib_none().0))
172        }
173    }
174
175    /// Returns the interface name created by combining #NMSettingInfiniband:parent
176    /// and #NMSettingInfiniband:p-key. (If either property is unset, this will
177    /// return [`None`].)
178    ///
179    /// # Returns
180    ///
181    /// the interface name, or [`None`]
182    #[doc(alias = "nm_setting_infiniband_get_virtual_interface_name")]
183    #[doc(alias = "get_virtual_interface_name")]
184    pub fn virtual_interface_name(&self) -> glib::GString {
185        unsafe {
186            from_glib_none(ffi::nm_setting_infiniband_get_virtual_interface_name(self.to_glib_none().0))
187        }
188    }
189
190    /// If specified, this connection will only apply to the IPoIB device whose
191    /// permanent MAC address matches. This property does not change the MAC
192    /// address of the device (i.e. MAC spoofing).
193    #[doc(alias = "mac-address")]
194    pub fn set_mac_address(&self, mac_address: Option<&str>) {
195        ObjectExt::set_property(self,"mac-address", mac_address)
196    }
197
198    /// If non-zero, only transmit packets of the specified size or smaller,
199    /// breaking larger packets up into multiple frames.
200    pub fn set_mtu(&self, mtu: u32) {
201        ObjectExt::set_property(self,"mtu", mtu)
202    }
203
204    /// The InfiniBand p-key to use for this device. A value of -1 means to use
205    /// the default p-key (aka "the p-key at index 0"). Otherwise, it is a
206    /// 16-bit unsigned integer, whose high bit 0x8000 is set if it is a "full
207    /// membership" p-key. The values 0 and 0x8000 are not allowed.
208    ///
209    /// With the p-key set, the interface name is always "$parent.$p_key".
210    /// Setting "connection.interface-name" to another name is not supported.
211    ///
212    /// Note that kernel will internally always set the full membership bit,
213    /// although the interface name does not reflect that. Usually the user
214    /// would want to configure a full membership p-key with 0x8000 flag set.
215    #[doc(alias = "p-key")]
216    pub fn set_p_key(&self, p_key: i32) {
217        ObjectExt::set_property(self,"p-key", p_key)
218    }
219
220    /// The interface name of the parent device of this device. Normally [`None`],
221    /// but if the #NMSettingInfiniband:p_key property is set, then you must
222    /// specify the base device by setting either this property or
223    /// #NMSettingInfiniband:mac-address.
224    pub fn set_parent(&self, parent: Option<&str>) {
225        ObjectExt::set_property(self,"parent", parent)
226    }
227
228    /// The IP-over-InfiniBand transport mode. Either "datagram" or
229    /// "connected".
230    #[doc(alias = "transport-mode")]
231    pub fn set_transport_mode(&self, transport_mode: Option<&str>) {
232        ObjectExt::set_property(self,"transport-mode", transport_mode)
233    }
234
235    #[doc(alias = "mac-address")]
236    pub fn connect_mac_address_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
237        unsafe extern "C" fn notify_mac_address_trampoline<F: Fn(&SettingInfiniband) + 'static>(this: *mut ffi::NMSettingInfiniband, _param_spec: glib::ffi::gpointer, f: glib::ffi::gpointer) {
238            let f: &F = &*(f as *const F);
239            f(&from_glib_borrow(this))
240        }
241        unsafe {
242            let f: Box_<F> = Box_::new(f);
243            connect_raw(self.as_ptr() as *mut _, c"notify::mac-address".as_ptr() as *const _,
244                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(notify_mac_address_trampoline::<F> as *const ())), Box_::into_raw(f))
245        }
246    }
247
248    #[doc(alias = "mtu")]
249    pub fn connect_mtu_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
250        unsafe extern "C" fn notify_mtu_trampoline<F: Fn(&SettingInfiniband) + 'static>(this: *mut ffi::NMSettingInfiniband, _param_spec: glib::ffi::gpointer, f: glib::ffi::gpointer) {
251            let f: &F = &*(f as *const F);
252            f(&from_glib_borrow(this))
253        }
254        unsafe {
255            let f: Box_<F> = Box_::new(f);
256            connect_raw(self.as_ptr() as *mut _, c"notify::mtu".as_ptr() as *const _,
257                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(notify_mtu_trampoline::<F> as *const ())), Box_::into_raw(f))
258        }
259    }
260
261    #[doc(alias = "p-key")]
262    pub fn connect_p_key_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
263        unsafe extern "C" fn notify_p_key_trampoline<F: Fn(&SettingInfiniband) + 'static>(this: *mut ffi::NMSettingInfiniband, _param_spec: glib::ffi::gpointer, f: glib::ffi::gpointer) {
264            let f: &F = &*(f as *const F);
265            f(&from_glib_borrow(this))
266        }
267        unsafe {
268            let f: Box_<F> = Box_::new(f);
269            connect_raw(self.as_ptr() as *mut _, c"notify::p-key".as_ptr() as *const _,
270                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(notify_p_key_trampoline::<F> as *const ())), Box_::into_raw(f))
271        }
272    }
273
274    #[doc(alias = "parent")]
275    pub fn connect_parent_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
276        unsafe extern "C" fn notify_parent_trampoline<F: Fn(&SettingInfiniband) + 'static>(this: *mut ffi::NMSettingInfiniband, _param_spec: glib::ffi::gpointer, f: glib::ffi::gpointer) {
277            let f: &F = &*(f as *const F);
278            f(&from_glib_borrow(this))
279        }
280        unsafe {
281            let f: Box_<F> = Box_::new(f);
282            connect_raw(self.as_ptr() as *mut _, c"notify::parent".as_ptr() as *const _,
283                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(notify_parent_trampoline::<F> as *const ())), Box_::into_raw(f))
284        }
285    }
286
287    #[doc(alias = "transport-mode")]
288    pub fn connect_transport_mode_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
289        unsafe extern "C" fn notify_transport_mode_trampoline<F: Fn(&SettingInfiniband) + 'static>(this: *mut ffi::NMSettingInfiniband, _param_spec: glib::ffi::gpointer, f: glib::ffi::gpointer) {
290            let f: &F = &*(f as *const F);
291            f(&from_glib_borrow(this))
292        }
293        unsafe {
294            let f: Box_<F> = Box_::new(f);
295            connect_raw(self.as_ptr() as *mut _, c"notify::transport-mode".as_ptr() as *const _,
296                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(notify_transport_mode_trampoline::<F> as *const ())), Box_::into_raw(f))
297        }
298    }
299}
300
301impl Default for SettingInfiniband {
302                     fn default() -> Self {
303                         Self::new()
304                     }
305                 }
306
307// rustdoc-stripper-ignore-next
308        /// A [builder-pattern] type to construct [`SettingInfiniband`] objects.
309        ///
310        /// [builder-pattern]: https://doc.rust-lang.org/1.0.0/style/ownership/builders.html
311#[must_use = "The builder must be built to be used"]
312pub struct SettingInfinibandBuilder {
313            builder: glib::object::ObjectBuilder<'static, SettingInfiniband>,
314        }
315
316        impl SettingInfinibandBuilder {
317        fn new() -> Self {
318            Self { builder: glib::object::Object::builder() }
319        }
320
321                            /// If specified, this connection will only apply to the IPoIB device whose
322                            /// permanent MAC address matches. This property does not change the MAC
323                            /// address of the device (i.e. MAC spoofing).
324                            pub fn mac_address(self, mac_address: impl Into<glib::GString>) -> Self {
325                            Self { builder: self.builder.property("mac-address", mac_address.into()), }
326                        }
327
328                            /// If non-zero, only transmit packets of the specified size or smaller,
329                            /// breaking larger packets up into multiple frames.
330                            pub fn mtu(self, mtu: u32) -> Self {
331                            Self { builder: self.builder.property("mtu", mtu), }
332                        }
333
334                            /// The InfiniBand p-key to use for this device. A value of -1 means to use
335                            /// the default p-key (aka "the p-key at index 0"). Otherwise, it is a
336                            /// 16-bit unsigned integer, whose high bit 0x8000 is set if it is a "full
337                            /// membership" p-key. The values 0 and 0x8000 are not allowed.
338                            ///
339                            /// With the p-key set, the interface name is always "$parent.$p_key".
340                            /// Setting "connection.interface-name" to another name is not supported.
341                            ///
342                            /// Note that kernel will internally always set the full membership bit,
343                            /// although the interface name does not reflect that. Usually the user
344                            /// would want to configure a full membership p-key with 0x8000 flag set.
345                            pub fn p_key(self, p_key: i32) -> Self {
346                            Self { builder: self.builder.property("p-key", p_key), }
347                        }
348
349                            /// The interface name of the parent device of this device. Normally [`None`],
350                            /// but if the #NMSettingInfiniband:p_key property is set, then you must
351                            /// specify the base device by setting either this property or
352                            /// #NMSettingInfiniband:mac-address.
353                            pub fn parent(self, parent: impl Into<glib::GString>) -> Self {
354                            Self { builder: self.builder.property("parent", parent.into()), }
355                        }
356
357                            /// The IP-over-InfiniBand transport mode. Either "datagram" or
358                            /// "connected".
359                            pub fn transport_mode(self, transport_mode: impl Into<glib::GString>) -> Self {
360                            Self { builder: self.builder.property("transport-mode", transport_mode.into()), }
361                        }
362
363    // rustdoc-stripper-ignore-next
364    /// Build the [`SettingInfiniband`].
365    #[must_use = "Building the object from the builder is usually expensive and is not expected to have side effects"]
366    pub fn build(self) -> SettingInfiniband {
367assert_initialized_main_thread!();
368    self.builder.build() }
369}