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