nm_rs/auto/
device_wifi.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::{AccessPoint, Device, DeviceWifiCapabilities, NM80211Mode, Object, ffi};
8use glib::{
9    prelude::*,
10    signal::{SignalHandlerId, connect_raw},
11    translate::*,
12};
13use std::{boxed::Box as Box_, pin::Pin};
14
15glib::wrapper! {
16    ///
17    ///
18    /// ## Properties
19    ///
20    ///
21    /// #### `access-points`
22    ///  List of all Wi-Fi access points the device can see.
23    ///
24    /// Readable
25    ///
26    ///
27    /// #### `active-access-point`
28    ///  The active #NMAccessPoint of the device.
29    ///
30    /// Readable
31    ///
32    ///
33    /// #### `bitrate`
34    ///  The bit rate of the device in kbit/s.
35    ///
36    /// Readable
37    ///
38    ///
39    /// #### `last-scan`
40    ///  The timestamp (in CLOCK_BOOTTIME seconds) for the last finished
41    /// network scan. A value of -1 means the device never scanned for
42    /// access points.
43    ///
44    /// Readable
45    ///
46    ///
47    /// #### `mode`
48    ///  The mode of the device.
49    ///
50    /// Readable
51    ///
52    ///
53    /// #### `perm-hw-address`
54    ///  The hardware (MAC) address of the device.
55    ///
56    /// Readable
57    ///
58    ///
59    /// #### `wireless-capabilities`
60    ///  The wireless capabilities of the device.
61    ///
62    /// Readable
63    /// <details><summary><h4>Device</h4></summary>
64    ///
65    ///
66    /// #### `active-connection`
67    ///  The #NMActiveConnection object that "owns" this device during activation.
68    ///
69    /// Readable
70    ///
71    ///
72    /// #### `autoconnect`
73    ///  Whether the device can auto-activate a connection.
74    ///
75    /// The property setter is a synchronous D-Bus call. This is deprecated since 1.22.
76    ///
77    /// Readable | Writeable
78    ///
79    ///
80    /// #### `available-connections`
81    ///  The available connections of the device
82    ///
83    /// Readable
84    ///
85    ///
86    /// #### `capabilities`
87    ///  The capabilities of the device.
88    ///
89    /// Readable
90    ///
91    ///
92    /// #### `device-type`
93    ///  The numeric type of the device.
94    ///
95    /// Readable
96    ///
97    ///
98    /// #### `dhcp4-config`
99    ///  The IPv4 #NMDhcpConfig of the device.
100    ///
101    /// Readable
102    ///
103    ///
104    /// #### `dhcp6-config`
105    ///  The IPv6 #NMDhcpConfig of the device.
106    ///
107    /// Readable
108    ///
109    ///
110    /// #### `driver`
111    ///  The driver of the device.
112    ///
113    /// Readable
114    ///
115    ///
116    /// #### `driver-version`
117    ///  The version of the device driver.
118    ///
119    /// Readable
120    ///
121    ///
122    /// #### `firmware-missing`
123    ///  When [`true`] indicates the device is likely missing firmware required
124    /// for its operation.
125    ///
126    /// Readable
127    ///
128    ///
129    /// #### `firmware-version`
130    ///  The firmware version of the device.
131    ///
132    /// Readable
133    ///
134    ///
135    /// #### `hw-address`
136    ///  The hardware address of the device.
137    ///
138    /// Readable
139    ///
140    ///
141    /// #### `interface`
142    ///  The interface of the device.
143    ///
144    /// Readable
145    ///
146    ///
147    /// #### `interface-flags`
148    ///  The interface flags.
149    ///
150    /// Readable
151    ///
152    ///
153    /// #### `ip-interface`
154    ///  The IP interface of the device which should be used for all IP-related
155    /// operations like addressing and routing.
156    ///
157    /// Readable
158    ///
159    ///
160    /// #### `ip4-config`
161    ///  The #NMIP4Config of the device.
162    ///
163    /// Readable
164    ///
165    ///
166    /// #### `ip4-connectivity`
167    ///  The IPv4 connectivity state of the device.
168    ///
169    /// Readable
170    ///
171    ///
172    /// #### `ip6-config`
173    ///  The IPv6 #NMIPConfig of the device.
174    ///
175    /// Readable
176    ///
177    ///
178    /// #### `ip6-connectivity`
179    ///  The IPv6 connectivity state of the device.
180    ///
181    /// Readable
182    ///
183    ///
184    /// #### `lldp-neighbors`
185    ///  The LLDP neighbors.
186    ///
187    /// Readable
188    ///
189    ///
190    /// #### `managed`
191    ///  Whether the device is managed by NetworkManager.
192    ///
193    /// Readable
194    ///
195    ///
196    /// #### `metered`
197    ///  Whether the device is metered.
198    ///
199    /// Readable
200    ///
201    ///
202    /// #### `mtu`
203    ///  The MTU of the device.
204    ///
205    /// Readable
206    ///
207    ///
208    /// #### `nm-plugin-missing`
209    ///  When [`true`] indicates that the NetworkManager plugin for the device
210    /// is not installed.
211    ///
212    /// Readable
213    ///
214    ///
215    /// #### `path`
216    ///  The device path as exposed by the udev property ID_PATH.
217    ///
218    /// The string is backslash escaped (C escaping) for invalid
219    /// characters. The escaping can be reverted with g_strcompress(),
220    /// however the result may not be valid UTF-8.
221    ///
222    /// Readable
223    ///
224    ///
225    /// #### `physical-port-id`
226    ///  The physical port ID of the device. (See
227    /// nm_device_get_physical_port_id().)
228    ///
229    /// Readable
230    ///
231    ///
232    /// #### `ports`
233    ///  The port devices of the controller device. For devices that cannot be
234    /// controllers this is likely to be always empty.
235    ///
236    /// Readable
237    ///
238    ///
239    /// #### `product`
240    ///  The product string of the device.
241    ///
242    /// Readable
243    ///
244    ///
245    /// #### `real`
246    ///  Whether the device is real or is a placeholder device that could
247    /// be created automatically by NetworkManager if one of its
248    /// #NMDevice:available-connections was activated.
249    ///
250    /// Readable
251    ///
252    ///
253    /// #### `state`
254    ///  The state of the device.
255    ///
256    /// Readable
257    ///
258    ///
259    /// #### `state-reason`
260    ///  The reason for the device state.
261    ///
262    /// Readable
263    ///
264    ///
265    /// #### `udi`
266    ///  An operating-system specific device hardware identifier; this is not
267    /// unique to a specific hardware device across reboots or hotplugs.  It
268    /// is an opaque string which for some device types (Bluetooth, Modem)
269    /// contains an identifier provided by the underlying hardware service daemon
270    /// such as Bluez or ModemManager, and clients can use this property to
271    /// request more information about the device from those services.
272    ///
273    /// Readable
274    ///
275    ///
276    /// #### `vendor`
277    ///  The vendor string of the device.
278    ///
279    /// Readable
280    /// </details>
281    /// <details><summary><h4>Object</h4></summary>
282    ///
283    ///
284    /// #### `client`
285    ///  The NMClient instance as returned by nm_object_get_client().
286    ///
287    /// When an NMObject gets removed from the NMClient cache,
288    /// the NMObject:path property stays unchanged, but this client
289    /// instance gets reset to [`None`]. You can use this property to
290    /// track removal of the object from the cache.
291    ///
292    /// Readable
293    ///
294    ///
295    /// #### `path`
296    ///  The D-Bus object path.
297    ///
298    /// The D-Bus path of an object instance never changes, even if the object
299    /// gets removed from the cache. To see whether the object is still in the
300    /// cache, check NMObject:client.
301    ///
302    /// Readable
303    /// </details>
304    ///
305    /// ## Signals
306    ///
307    ///
308    /// #### `access-point-added`
309    ///  Notifies that a #NMAccessPoint is added to the Wi-Fi device.
310    ///
311    ///
312    ///
313    ///
314    /// #### `access-point-removed`
315    ///  Notifies that a #NMAccessPoint is removed from the Wi-Fi device.
316    ///
317    ///
318    /// <details><summary><h4>Device</h4></summary>
319    ///
320    ///
321    /// #### `state-changed`
322    ///  Notifies the state change of a #NMDevice.
323    ///
324    ///
325    /// </details>
326    ///
327    /// # Implements
328    ///
329    /// [`DeviceExt`][trait@crate::prelude::DeviceExt], [`ObjectExt`][trait@crate::prelude::ObjectExt]
330    #[doc(alias = "NMDeviceWifi")]
331    pub struct DeviceWifi(Object<ffi::NMDeviceWifi, ffi::NMDeviceWifiClass>) @extends Device, Object;
332
333    match fn {
334        type_ => || ffi::nm_device_wifi_get_type(),
335    }
336}
337
338impl DeviceWifi {
339    // rustdoc-stripper-ignore-next
340    /// Creates a new builder-pattern struct instance to construct [`DeviceWifi`] objects.
341    ///
342    /// This method returns an instance of [`DeviceWifiBuilder`](crate::builders::DeviceWifiBuilder) which can be used to create [`DeviceWifi`] objects.
343    pub fn builder() -> DeviceWifiBuilder {
344        DeviceWifiBuilder::new()
345    }
346
347    /// Gets a #NMAccessPoint by path.
348    /// ## `path`
349    /// the object path of the access point
350    ///
351    /// # Returns
352    ///
353    /// the access point or [`None`] if none is found.
354    #[doc(alias = "nm_device_wifi_get_access_point_by_path")]
355    #[doc(alias = "get_access_point_by_path")]
356    pub fn access_point_by_path(&self, path: &str) -> AccessPoint {
357        unsafe {
358            from_glib_none(ffi::nm_device_wifi_get_access_point_by_path(
359                self.to_glib_none().0,
360                path.to_glib_none().0,
361            ))
362        }
363    }
364
365    /// Gets all the scanned access points of the #NMDeviceWifi.
366    ///
367    /// # Returns
368    ///
369    /// a #GPtrArray containing all the
370    /// scanned #NMAccessPoints.
371    /// The returned array is owned by the client and should not be modified.
372    #[doc(alias = "nm_device_wifi_get_access_points")]
373    #[doc(alias = "get_access_points")]
374    #[doc(alias = "access-points")]
375    pub fn access_points(&self) -> Vec<AccessPoint> {
376        unsafe {
377            FromGlibPtrContainer::from_glib_none(ffi::nm_device_wifi_get_access_points(
378                self.to_glib_none().0,
379            ))
380        }
381    }
382
383    /// Gets the active #NMAccessPoint.
384    ///
385    /// # Returns
386    ///
387    /// the access point or [`None`] if none is active
388    #[doc(alias = "nm_device_wifi_get_active_access_point")]
389    #[doc(alias = "get_active_access_point")]
390    #[doc(alias = "active-access-point")]
391    pub fn active_access_point(&self) -> AccessPoint {
392        unsafe {
393            from_glib_none(ffi::nm_device_wifi_get_active_access_point(
394                self.to_glib_none().0,
395            ))
396        }
397    }
398
399    /// Gets the bit rate of the #NMDeviceWifi in kbit/s.
400    ///
401    /// # Returns
402    ///
403    /// the bit rate (kbit/s)
404    #[doc(alias = "nm_device_wifi_get_bitrate")]
405    #[doc(alias = "get_bitrate")]
406    pub fn bitrate(&self) -> u32 {
407        unsafe { ffi::nm_device_wifi_get_bitrate(self.to_glib_none().0) }
408    }
409
410    /// Gets the Wi-Fi capabilities of the #NMDeviceWifi.
411    ///
412    /// # Returns
413    ///
414    /// the capabilities
415    #[doc(alias = "nm_device_wifi_get_capabilities")]
416    #[doc(alias = "get_capabilities")]
417    pub fn capabilities(&self) -> DeviceWifiCapabilities {
418        unsafe { from_glib(ffi::nm_device_wifi_get_capabilities(self.to_glib_none().0)) }
419    }
420
421    /// Gets the actual hardware (MAC) address of the #NMDeviceWifi
422    ///
423    /// # Deprecated since 1.24
424    ///
425    /// Use nm_device_get_hw_address() instead.
426    ///
427    /// # Returns
428    ///
429    /// the actual hardware address. This is the internal string used by the
430    /// device, and must not be modified.
431    #[cfg_attr(feature = "v1_24", deprecated = "Since 1.24")]
432    #[allow(deprecated)]
433    #[doc(alias = "nm_device_wifi_get_hw_address")]
434    #[doc(alias = "get_hw_address")]
435    pub fn hw_address(&self) -> glib::GString {
436        unsafe { from_glib_none(ffi::nm_device_wifi_get_hw_address(self.to_glib_none().0)) }
437    }
438
439    /// Returns the timestamp (in CLOCK_BOOTTIME milliseconds) for the last finished
440    /// network scan. A value of -1 means the device never scanned for access points.
441    ///
442    /// Use nm_utils_get_timestamp_msec() to obtain current time value suitable for
443    /// comparing to this value.
444    ///
445    /// # Returns
446    ///
447    /// the last scan time in milliseconds (in clock_gettime(CLOCK_BOOTTIME) scale).
448    #[cfg(feature = "v1_12")]
449    #[cfg_attr(docsrs, doc(cfg(feature = "v1_12")))]
450    #[doc(alias = "nm_device_wifi_get_last_scan")]
451    #[doc(alias = "get_last_scan")]
452    #[doc(alias = "last-scan")]
453    pub fn last_scan(&self) -> i64 {
454        unsafe { ffi::nm_device_wifi_get_last_scan(self.to_glib_none().0) }
455    }
456
457    /// Gets the #NMDeviceWifi mode.
458    ///
459    /// # Returns
460    ///
461    /// the mode
462    #[doc(alias = "nm_device_wifi_get_mode")]
463    #[doc(alias = "get_mode")]
464    pub fn mode(&self) -> NM80211Mode {
465        unsafe { from_glib(ffi::nm_device_wifi_get_mode(self.to_glib_none().0)) }
466    }
467
468    /// Gets the permanent hardware (MAC) address of the #NMDeviceWifi
469    ///
470    /// # Returns
471    ///
472    /// the permanent hardware address. This is the internal string used by the
473    /// device, and must not be modified.
474    #[doc(alias = "nm_device_wifi_get_permanent_hw_address")]
475    #[doc(alias = "get_permanent_hw_address")]
476    pub fn permanent_hw_address(&self) -> glib::GString {
477        unsafe {
478            from_glib_none(ffi::nm_device_wifi_get_permanent_hw_address(
479                self.to_glib_none().0,
480            ))
481        }
482    }
483
484    /// Request NM to scan for access points on @self. Note that the function
485    /// returns immediately after requesting the scan, and it may take some time
486    /// after that for the scan to complete.
487    ///
488    /// # Deprecated since 1.22
489    ///
490    /// Use nm_device_wifi_request_scan_async() or GDBusConnection.
491    /// ## `cancellable`
492    /// a #GCancellable, or [`None`]
493    ///
494    /// # Returns
495    ///
496    /// [`true`] on success, [`false`] on error, in which case @error will be
497    /// set.
498    #[cfg_attr(feature = "v1_22", deprecated = "Since 1.22")]
499    #[allow(deprecated)]
500    #[doc(alias = "nm_device_wifi_request_scan")]
501    pub fn request_scan(
502        &self,
503        cancellable: Option<&impl IsA<gio::Cancellable>>,
504    ) -> Result<(), glib::Error> {
505        unsafe {
506            let mut error = std::ptr::null_mut();
507            let is_ok = ffi::nm_device_wifi_request_scan(
508                self.to_glib_none().0,
509                cancellable.map(|p| p.as_ref()).to_glib_none().0,
510                &mut error,
511            );
512            debug_assert_eq!(is_ok == glib::ffi::GFALSE, !error.is_null());
513            if error.is_null() {
514                Ok(())
515            } else {
516                Err(from_glib_full(error))
517            }
518        }
519    }
520
521    /// Request NM to scan for access points on @self. Note that @callback will be
522    /// called immediately after requesting the scan, and it may take some time after
523    /// that for the scan to complete.
524    /// ## `cancellable`
525    /// a #GCancellable, or [`None`]
526    /// ## `callback`
527    /// callback to be called when the scan has been requested
528    #[doc(alias = "nm_device_wifi_request_scan_async")]
529    pub fn request_scan_async<P: FnOnce(Result<(), glib::Error>) + 'static>(
530        &self,
531        cancellable: Option<&impl IsA<gio::Cancellable>>,
532        callback: P,
533    ) {
534        let main_context = glib::MainContext::ref_thread_default();
535        let is_main_context_owner = main_context.is_owner();
536        let has_acquired_main_context = (!is_main_context_owner)
537            .then(|| main_context.acquire().ok())
538            .flatten();
539        assert!(
540            is_main_context_owner || has_acquired_main_context.is_some(),
541            "Async operations only allowed if the thread is owning the MainContext"
542        );
543
544        let user_data: Box_<glib::thread_guard::ThreadGuard<P>> =
545            Box_::new(glib::thread_guard::ThreadGuard::new(callback));
546        unsafe extern "C" fn request_scan_async_trampoline<
547            P: FnOnce(Result<(), glib::Error>) + 'static,
548        >(
549            _source_object: *mut glib::gobject_ffi::GObject,
550            res: *mut gio::ffi::GAsyncResult,
551            user_data: glib::ffi::gpointer,
552        ) {
553            let mut error = std::ptr::null_mut();
554            ffi::nm_device_wifi_request_scan_finish(_source_object as *mut _, res, &mut error);
555            let result = if error.is_null() {
556                Ok(())
557            } else {
558                Err(from_glib_full(error))
559            };
560            let callback: Box_<glib::thread_guard::ThreadGuard<P>> =
561                Box_::from_raw(user_data as *mut _);
562            let callback: P = callback.into_inner();
563            callback(result);
564        }
565        let callback = request_scan_async_trampoline::<P>;
566        unsafe {
567            ffi::nm_device_wifi_request_scan_async(
568                self.to_glib_none().0,
569                cancellable.map(|p| p.as_ref()).to_glib_none().0,
570                Some(callback),
571                Box_::into_raw(user_data) as *mut _,
572            );
573        }
574    }
575
576    pub fn request_scan_future(
577        &self,
578    ) -> Pin<Box_<dyn std::future::Future<Output = Result<(), glib::Error>> + 'static>> {
579        Box_::pin(gio::GioFuture::new(self, move |obj, cancellable, send| {
580            obj.request_scan_async(Some(cancellable), move |res| {
581                send.resolve(res);
582            });
583        }))
584    }
585
586    //#[cfg_attr(feature = "v1_22", deprecated = "Since 1.22")]
587    //#[cfg(feature = "v1_2")]
588    //#[cfg_attr(docsrs, doc(cfg(feature = "v1_2")))]
589    //#[allow(deprecated)]
590    //#[doc(alias = "nm_device_wifi_request_scan_options")]
591    //pub fn request_scan_options(&self, options: /*Ignored*/&glib::Variant, cancellable: Option<&impl IsA<gio::Cancellable>>) -> Result<(), glib::Error> {
592    //    unsafe { TODO: call ffi:nm_device_wifi_request_scan_options() }
593    //}
594
595    //#[cfg(feature = "v1_2")]
596    //#[cfg_attr(docsrs, doc(cfg(feature = "v1_2")))]
597    //#[doc(alias = "nm_device_wifi_request_scan_options_async")]
598    //pub fn request_scan_options_async<P: FnOnce(Result<(), glib::Error>) + 'static>(&self, options: /*Ignored*/&glib::Variant, cancellable: Option<&impl IsA<gio::Cancellable>>, callback: P) {
599    //    unsafe { TODO: call ffi:nm_device_wifi_request_scan_options_async() }
600    //}
601
602    /// The hardware (MAC) address of the device.
603    #[doc(alias = "perm-hw-address")]
604    pub fn perm_hw_address(&self) -> Option<glib::GString> {
605        ObjectExt::property(self, "perm-hw-address")
606    }
607
608    /// The wireless capabilities of the device.
609    #[doc(alias = "wireless-capabilities")]
610    pub fn wireless_capabilities(&self) -> DeviceWifiCapabilities {
611        ObjectExt::property(self, "wireless-capabilities")
612    }
613
614    //#[doc(alias = "access-point-added")]
615    //pub fn connect_access_point_added<Unsupported or ignored types>(&self, f: F) -> SignalHandlerId {
616    //    Ignored ap: GObject.Object
617    //}
618
619    //#[doc(alias = "access-point-removed")]
620    //pub fn connect_access_point_removed<Unsupported or ignored types>(&self, f: F) -> SignalHandlerId {
621    //    Ignored ap: GObject.Object
622    //}
623
624    #[doc(alias = "access-points")]
625    pub fn connect_access_points_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
626        unsafe extern "C" fn notify_access_points_trampoline<F: Fn(&DeviceWifi) + 'static>(
627            this: *mut ffi::NMDeviceWifi,
628            _param_spec: glib::ffi::gpointer,
629            f: glib::ffi::gpointer,
630        ) {
631            let f: &F = &*(f as *const F);
632            f(&from_glib_borrow(this))
633        }
634        unsafe {
635            let f: Box_<F> = Box_::new(f);
636            connect_raw(
637                self.as_ptr() as *mut _,
638                c"notify::access-points".as_ptr() as *const _,
639                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
640                    notify_access_points_trampoline::<F> as *const (),
641                )),
642                Box_::into_raw(f),
643            )
644        }
645    }
646
647    #[doc(alias = "active-access-point")]
648    pub fn connect_active_access_point_notify<F: Fn(&Self) + 'static>(
649        &self,
650        f: F,
651    ) -> SignalHandlerId {
652        unsafe extern "C" fn notify_active_access_point_trampoline<F: Fn(&DeviceWifi) + 'static>(
653            this: *mut ffi::NMDeviceWifi,
654            _param_spec: glib::ffi::gpointer,
655            f: glib::ffi::gpointer,
656        ) {
657            let f: &F = &*(f as *const F);
658            f(&from_glib_borrow(this))
659        }
660        unsafe {
661            let f: Box_<F> = Box_::new(f);
662            connect_raw(
663                self.as_ptr() as *mut _,
664                c"notify::active-access-point".as_ptr() as *const _,
665                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
666                    notify_active_access_point_trampoline::<F> as *const (),
667                )),
668                Box_::into_raw(f),
669            )
670        }
671    }
672
673    #[doc(alias = "bitrate")]
674    pub fn connect_bitrate_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
675        unsafe extern "C" fn notify_bitrate_trampoline<F: Fn(&DeviceWifi) + 'static>(
676            this: *mut ffi::NMDeviceWifi,
677            _param_spec: glib::ffi::gpointer,
678            f: glib::ffi::gpointer,
679        ) {
680            let f: &F = &*(f as *const F);
681            f(&from_glib_borrow(this))
682        }
683        unsafe {
684            let f: Box_<F> = Box_::new(f);
685            connect_raw(
686                self.as_ptr() as *mut _,
687                c"notify::bitrate".as_ptr() as *const _,
688                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
689                    notify_bitrate_trampoline::<F> as *const (),
690                )),
691                Box_::into_raw(f),
692            )
693        }
694    }
695
696    #[cfg(feature = "v1_12")]
697    #[cfg_attr(docsrs, doc(cfg(feature = "v1_12")))]
698    #[doc(alias = "last-scan")]
699    pub fn connect_last_scan_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
700        unsafe extern "C" fn notify_last_scan_trampoline<F: Fn(&DeviceWifi) + 'static>(
701            this: *mut ffi::NMDeviceWifi,
702            _param_spec: glib::ffi::gpointer,
703            f: glib::ffi::gpointer,
704        ) {
705            let f: &F = &*(f as *const F);
706            f(&from_glib_borrow(this))
707        }
708        unsafe {
709            let f: Box_<F> = Box_::new(f);
710            connect_raw(
711                self.as_ptr() as *mut _,
712                c"notify::last-scan".as_ptr() as *const _,
713                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
714                    notify_last_scan_trampoline::<F> as *const (),
715                )),
716                Box_::into_raw(f),
717            )
718        }
719    }
720
721    #[doc(alias = "mode")]
722    pub fn connect_mode_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
723        unsafe extern "C" fn notify_mode_trampoline<F: Fn(&DeviceWifi) + 'static>(
724            this: *mut ffi::NMDeviceWifi,
725            _param_spec: glib::ffi::gpointer,
726            f: glib::ffi::gpointer,
727        ) {
728            let f: &F = &*(f as *const F);
729            f(&from_glib_borrow(this))
730        }
731        unsafe {
732            let f: Box_<F> = Box_::new(f);
733            connect_raw(
734                self.as_ptr() as *mut _,
735                c"notify::mode".as_ptr() as *const _,
736                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
737                    notify_mode_trampoline::<F> as *const (),
738                )),
739                Box_::into_raw(f),
740            )
741        }
742    }
743
744    #[doc(alias = "perm-hw-address")]
745    pub fn connect_perm_hw_address_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
746        unsafe extern "C" fn notify_perm_hw_address_trampoline<F: Fn(&DeviceWifi) + 'static>(
747            this: *mut ffi::NMDeviceWifi,
748            _param_spec: glib::ffi::gpointer,
749            f: glib::ffi::gpointer,
750        ) {
751            let f: &F = &*(f as *const F);
752            f(&from_glib_borrow(this))
753        }
754        unsafe {
755            let f: Box_<F> = Box_::new(f);
756            connect_raw(
757                self.as_ptr() as *mut _,
758                c"notify::perm-hw-address".as_ptr() as *const _,
759                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
760                    notify_perm_hw_address_trampoline::<F> as *const (),
761                )),
762                Box_::into_raw(f),
763            )
764        }
765    }
766
767    #[doc(alias = "wireless-capabilities")]
768    pub fn connect_wireless_capabilities_notify<F: Fn(&Self) + 'static>(
769        &self,
770        f: F,
771    ) -> SignalHandlerId {
772        unsafe extern "C" fn notify_wireless_capabilities_trampoline<
773            F: Fn(&DeviceWifi) + 'static,
774        >(
775            this: *mut ffi::NMDeviceWifi,
776            _param_spec: glib::ffi::gpointer,
777            f: glib::ffi::gpointer,
778        ) {
779            let f: &F = &*(f as *const F);
780            f(&from_glib_borrow(this))
781        }
782        unsafe {
783            let f: Box_<F> = Box_::new(f);
784            connect_raw(
785                self.as_ptr() as *mut _,
786                c"notify::wireless-capabilities".as_ptr() as *const _,
787                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
788                    notify_wireless_capabilities_trampoline::<F> as *const (),
789                )),
790                Box_::into_raw(f),
791            )
792        }
793    }
794}
795
796// rustdoc-stripper-ignore-next
797/// A [builder-pattern] type to construct [`DeviceWifi`] objects.
798///
799/// [builder-pattern]: https://doc.rust-lang.org/1.0.0/style/ownership/builders.html
800#[must_use = "The builder must be built to be used"]
801pub struct DeviceWifiBuilder {
802    builder: glib::object::ObjectBuilder<'static, DeviceWifi>,
803}
804
805impl DeviceWifiBuilder {
806    fn new() -> Self {
807        Self {
808            builder: glib::object::Object::builder(),
809        }
810    }
811
812    /// Whether the device can auto-activate a connection.
813    ///
814    /// The property setter is a synchronous D-Bus call. This is deprecated since 1.22.
815    pub fn autoconnect(self, autoconnect: bool) -> Self {
816        Self {
817            builder: self.builder.property("autoconnect", autoconnect),
818        }
819    }
820
821    // rustdoc-stripper-ignore-next
822    /// Build the [`DeviceWifi`].
823    #[must_use = "Building the object from the builder is usually expensive and is not expected to have side effects"]
824    pub fn build(self) -> DeviceWifi {
825        assert_initialized_main_thread!();
826        self.builder.build()
827    }
828}