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