nm_rs/auto/
device_team.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#![allow(deprecated)]
6
7use crate::{ffi,Device,Object};
8use glib::{prelude::*,signal::{connect_raw, SignalHandlerId},translate::*};
9use std::{boxed::Box as Box_};
10
11glib::wrapper! {
12    ///
13    ///
14    /// ## Properties
15    ///
16    ///
17    /// #### `carrier`
18    ///  Whether the device has carrier.
19    ///
20    /// Readable
21    ///
22    ///
23    /// #### `config`
24    ///  The current JSON configuration of the device.
25    ///
26    /// Readable
27    ///
28    ///
29    /// #### `slaves`
30    ///  The devices attached as port to the team device.
31    ///
32    /// Readable
33    /// <details><summary><h4>Device</h4></summary>
34    ///
35    ///
36    /// #### `active-connection`
37    ///  The #NMActiveConnection object that "owns" this device during activation.
38    ///
39    /// Readable
40    ///
41    ///
42    /// #### `autoconnect`
43    ///  Whether the device can auto-activate a connection.
44    ///
45    /// The property setter is a synchronous D-Bus call. This is deprecated since 1.22.
46    ///
47    /// Readable | Writeable
48    ///
49    ///
50    /// #### `available-connections`
51    ///  The available connections of the device
52    ///
53    /// Readable
54    ///
55    ///
56    /// #### `capabilities`
57    ///  The capabilities of the device.
58    ///
59    /// Readable
60    ///
61    ///
62    /// #### `device-type`
63    ///  The numeric type of the device.
64    ///
65    /// Readable
66    ///
67    ///
68    /// #### `dhcp4-config`
69    ///  The IPv4 #NMDhcpConfig of the device.
70    ///
71    /// Readable
72    ///
73    ///
74    /// #### `dhcp6-config`
75    ///  The IPv6 #NMDhcpConfig of the device.
76    ///
77    /// Readable
78    ///
79    ///
80    /// #### `driver`
81    ///  The driver of the device.
82    ///
83    /// Readable
84    ///
85    ///
86    /// #### `driver-version`
87    ///  The version of the device driver.
88    ///
89    /// Readable
90    ///
91    ///
92    /// #### `firmware-missing`
93    ///  When [`true`] indicates the device is likely missing firmware required
94    /// for its operation.
95    ///
96    /// Readable
97    ///
98    ///
99    /// #### `firmware-version`
100    ///  The firmware version of the device.
101    ///
102    /// Readable
103    ///
104    ///
105    /// #### `hw-address`
106    ///  The hardware address of the device.
107    ///
108    /// Readable
109    ///
110    ///
111    /// #### `interface`
112    ///  The interface of the device.
113    ///
114    /// Readable
115    ///
116    ///
117    /// #### `interface-flags`
118    ///  The interface flags.
119    ///
120    /// Readable
121    ///
122    ///
123    /// #### `ip-interface`
124    ///  The IP interface of the device which should be used for all IP-related
125    /// operations like addressing and routing.
126    ///
127    /// Readable
128    ///
129    ///
130    /// #### `ip4-config`
131    ///  The #NMIP4Config of the device.
132    ///
133    /// Readable
134    ///
135    ///
136    /// #### `ip4-connectivity`
137    ///  The IPv4 connectivity state of the device.
138    ///
139    /// Readable
140    ///
141    ///
142    /// #### `ip6-config`
143    ///  The IPv6 #NMIPConfig of the device.
144    ///
145    /// Readable
146    ///
147    ///
148    /// #### `ip6-connectivity`
149    ///  The IPv6 connectivity state of the device.
150    ///
151    /// Readable
152    ///
153    ///
154    /// #### `lldp-neighbors`
155    ///  The LLDP neighbors.
156    ///
157    /// Readable
158    ///
159    ///
160    /// #### `managed`
161    ///  Whether the device is managed by NetworkManager.
162    ///
163    /// Readable
164    ///
165    ///
166    /// #### `metered`
167    ///  Whether the device is metered.
168    ///
169    /// Readable
170    ///
171    ///
172    /// #### `mtu`
173    ///  The MTU of the device.
174    ///
175    /// Readable
176    ///
177    ///
178    /// #### `nm-plugin-missing`
179    ///  When [`true`] indicates that the NetworkManager plugin for the device
180    /// is not installed.
181    ///
182    /// Readable
183    ///
184    ///
185    /// #### `path`
186    ///  The device path as exposed by the udev property ID_PATH.
187    ///
188    /// The string is backslash escaped (C escaping) for invalid
189    /// characters. The escaping can be reverted with g_strcompress(),
190    /// however the result may not be valid UTF-8.
191    ///
192    /// Readable
193    ///
194    ///
195    /// #### `physical-port-id`
196    ///  The physical port ID of the device. (See
197    /// nm_device_get_physical_port_id().)
198    ///
199    /// Readable
200    ///
201    ///
202    /// #### `ports`
203    ///  The port devices of the controller device. For devices that cannot be
204    /// controllers this is likely to be always empty.
205    ///
206    /// Readable
207    ///
208    ///
209    /// #### `product`
210    ///  The product string of the device.
211    ///
212    /// Readable
213    ///
214    ///
215    /// #### `real`
216    ///  Whether the device is real or is a placeholder device that could
217    /// be created automatically by NetworkManager if one of its
218    /// #NMDevice:available-connections was activated.
219    ///
220    /// Readable
221    ///
222    ///
223    /// #### `state`
224    ///  The state of the device.
225    ///
226    /// Readable
227    ///
228    ///
229    /// #### `state-reason`
230    ///  The reason for the device state.
231    ///
232    /// Readable
233    ///
234    ///
235    /// #### `udi`
236    ///  An operating-system specific device hardware identifier; this is not
237    /// unique to a specific hardware device across reboots or hotplugs.  It
238    /// is an opaque string which for some device types (Bluetooth, Modem)
239    /// contains an identifier provided by the underlying hardware service daemon
240    /// such as Bluez or ModemManager, and clients can use this property to
241    /// request more information about the device from those services.
242    ///
243    /// Readable
244    ///
245    ///
246    /// #### `vendor`
247    ///  The vendor string of the device.
248    ///
249    /// Readable
250    /// </details>
251    /// <details><summary><h4>Object</h4></summary>
252    ///
253    ///
254    /// #### `client`
255    ///  The NMClient instance as returned by nm_object_get_client().
256    ///
257    /// When an NMObject gets removed from the NMClient cache,
258    /// the NMObject:path property stays unchanged, but this client
259    /// instance gets reset to [`None`]. You can use this property to
260    /// track removal of the object from the cache.
261    ///
262    /// Readable
263    ///
264    ///
265    /// #### `path`
266    ///  The D-Bus object path.
267    ///
268    /// The D-Bus path of an object instance never changes, even if the object
269    /// gets removed from the cache. To see whether the object is still in the
270    /// cache, check NMObject:client.
271    ///
272    /// Readable
273    /// </details>
274    ///
275    /// # Implements
276    ///
277    /// [`DeviceExt`][trait@crate::prelude::DeviceExt], [`ObjectExt`][trait@crate::prelude::ObjectExt]
278    #[doc(alias = "NMDeviceTeam")]
279    pub struct DeviceTeam(Object<ffi::NMDeviceTeam, ffi::NMDeviceTeamClass>) @extends Device, Object;
280
281    match fn {
282        type_ => || ffi::nm_device_team_get_type(),
283    }
284}
285
286impl DeviceTeam {
287            // rustdoc-stripper-ignore-next
288            /// Creates a new builder-pattern struct instance to construct [`DeviceTeam`] objects.
289            ///
290            /// This method returns an instance of [`DeviceTeamBuilder`](crate::builders::DeviceTeamBuilder) which can be used to create [`DeviceTeam`] objects.
291            pub fn builder() -> DeviceTeamBuilder {
292                DeviceTeamBuilder::new()
293            }
294        
295
296    /// Whether the device has carrier.
297    ///
298    /// # Returns
299    ///
300    /// [`true`] if the device has carrier
301    #[doc(alias = "nm_device_team_get_carrier")]
302    #[doc(alias = "get_carrier")]
303    #[doc(alias = "carrier")]
304    pub fn is_carrier(&self) -> bool {
305        unsafe {
306            from_glib(ffi::nm_device_team_get_carrier(self.to_glib_none().0))
307        }
308    }
309
310    /// Gets the current JSON configuration of the #NMDeviceTeam
311    ///
312    /// # Returns
313    ///
314    /// the current configuration. This is the internal string used by the
315    /// device, and must not be modified.
316    #[cfg(feature = "v1_4")]
317    #[cfg_attr(docsrs, doc(cfg(feature = "v1_4")))]
318    #[doc(alias = "nm_device_team_get_config")]
319    #[doc(alias = "get_config")]
320    pub fn config(&self) -> glib::GString {
321        unsafe {
322            from_glib_none(ffi::nm_device_team_get_config(self.to_glib_none().0))
323        }
324    }
325
326    /// Gets the hardware (MAC) address of the #NMDeviceTeam
327    ///
328    /// # Deprecated since 1.24
329    ///
330    /// Use nm_device_get_hw_address() instead.
331    ///
332    /// # Returns
333    ///
334    /// the hardware address. This is the internal string used by the
335    /// device, and must not be modified.
336    #[cfg_attr(feature = "v1_24", deprecated = "Since 1.24")]
337    #[allow(deprecated)]
338    #[doc(alias = "nm_device_team_get_hw_address")]
339    #[doc(alias = "get_hw_address")]
340    pub fn hw_address(&self) -> glib::GString {
341        unsafe {
342            from_glib_none(ffi::nm_device_team_get_hw_address(self.to_glib_none().0))
343        }
344    }
345
346    /// Gets the devices currently attach as port to @self.
347    ///
348    /// # Deprecated since 1.34
349    ///
350    /// Use nm_device_get_ports() instead.
351    ///
352    /// # Returns
353    ///
354    /// the #GPtrArray containing
355    /// #NMDevices that are ports of @self. This is the internal
356    /// copy used by the device, and must not be modified.
357    #[cfg_attr(feature = "v1_34", deprecated = "Since 1.34")]
358    #[allow(deprecated)]
359    #[doc(alias = "nm_device_team_get_slaves")]
360    #[doc(alias = "get_slaves")]
361    pub fn slaves(&self) -> Vec<Device> {
362        unsafe {
363            FromGlibPtrContainer::from_glib_none(ffi::nm_device_team_get_slaves(self.to_glib_none().0))
364        }
365    }
366
367    #[doc(alias = "carrier")]
368    pub fn connect_carrier_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
369        unsafe extern "C" fn notify_carrier_trampoline<F: Fn(&DeviceTeam) + 'static>(this: *mut ffi::NMDeviceTeam, _param_spec: glib::ffi::gpointer, f: glib::ffi::gpointer) {
370            let f: &F = &*(f as *const F);
371            f(&from_glib_borrow(this))
372        }
373        unsafe {
374            let f: Box_<F> = Box_::new(f);
375            connect_raw(self.as_ptr() as *mut _, c"notify::carrier".as_ptr() as *const _,
376                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(notify_carrier_trampoline::<F> as *const ())), Box_::into_raw(f))
377        }
378    }
379
380    #[cfg(feature = "v1_4")]
381    #[cfg_attr(docsrs, doc(cfg(feature = "v1_4")))]
382    #[doc(alias = "config")]
383    pub fn connect_config_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
384        unsafe extern "C" fn notify_config_trampoline<F: Fn(&DeviceTeam) + 'static>(this: *mut ffi::NMDeviceTeam, _param_spec: glib::ffi::gpointer, f: glib::ffi::gpointer) {
385            let f: &F = &*(f as *const F);
386            f(&from_glib_borrow(this))
387        }
388        unsafe {
389            let f: Box_<F> = Box_::new(f);
390            connect_raw(self.as_ptr() as *mut _, c"notify::config".as_ptr() as *const _,
391                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(notify_config_trampoline::<F> as *const ())), Box_::into_raw(f))
392        }
393    }
394
395    #[doc(alias = "slaves")]
396    pub fn connect_slaves_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
397        unsafe extern "C" fn notify_slaves_trampoline<F: Fn(&DeviceTeam) + 'static>(this: *mut ffi::NMDeviceTeam, _param_spec: glib::ffi::gpointer, f: glib::ffi::gpointer) {
398            let f: &F = &*(f as *const F);
399            f(&from_glib_borrow(this))
400        }
401        unsafe {
402            let f: Box_<F> = Box_::new(f);
403            connect_raw(self.as_ptr() as *mut _, c"notify::slaves".as_ptr() as *const _,
404                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(notify_slaves_trampoline::<F> as *const ())), Box_::into_raw(f))
405        }
406    }
407}
408
409// rustdoc-stripper-ignore-next
410        /// A [builder-pattern] type to construct [`DeviceTeam`] objects.
411        ///
412        /// [builder-pattern]: https://doc.rust-lang.org/1.0.0/style/ownership/builders.html
413#[must_use = "The builder must be built to be used"]
414pub struct DeviceTeamBuilder {
415            builder: glib::object::ObjectBuilder<'static, DeviceTeam>,
416        }
417
418        impl DeviceTeamBuilder {
419        fn new() -> Self {
420            Self { builder: glib::object::Object::builder() }
421        }
422
423                            /// Whether the device can auto-activate a connection.
424                            ///
425                            /// The property setter is a synchronous D-Bus call. This is deprecated since 1.22.
426                            pub fn autoconnect(self, autoconnect: bool) -> Self {
427                            Self { builder: self.builder.property("autoconnect", autoconnect), }
428                        }
429
430    // rustdoc-stripper-ignore-next
431    /// Build the [`DeviceTeam`].
432    #[must_use = "Building the object from the builder is usually expensive and is not expected to have side effects"]
433    pub fn build(self) -> DeviceTeam {
434assert_initialized_main_thread!();
435    self.builder.build() }
436}