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