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