nm_rs/auto/device_bt.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,BluetoothCapabilities,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 /// #### `bt-capabilities`
18 /// The device's bluetooth capabilities, a combination of #NMBluetoothCapabilities.
19 ///
20 /// Readable
21 ///
22 ///
23 /// #### `name`
24 /// The name of the bluetooth 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 = "NMDeviceBt")]
273 pub struct DeviceBt(Object<ffi::NMDeviceBt, ffi::NMDeviceBtClass>) @extends Device, Object;
274
275 match fn {
276 type_ => || ffi::nm_device_bt_get_type(),
277 }
278}
279
280impl DeviceBt {
281 // rustdoc-stripper-ignore-next
282 /// Creates a new builder-pattern struct instance to construct [`DeviceBt`] objects.
283 ///
284 /// This method returns an instance of [`DeviceBtBuilder`](crate::builders::DeviceBtBuilder) which can be used to create [`DeviceBt`] objects.
285 pub fn builder() -> DeviceBtBuilder {
286 DeviceBtBuilder::new()
287 }
288
289
290 /// Returns the Bluetooth device's usable capabilities.
291 ///
292 /// # Returns
293 ///
294 /// a combination of #NMBluetoothCapabilities
295 #[doc(alias = "nm_device_bt_get_capabilities")]
296 #[doc(alias = "get_capabilities")]
297 pub fn capabilities(&self) -> BluetoothCapabilities {
298 unsafe {
299 from_glib(ffi::nm_device_bt_get_capabilities(self.to_glib_none().0))
300 }
301 }
302
303 /// Gets the hardware (MAC) address of the #NMDeviceBt
304 ///
305 /// # Deprecated since 1.24
306 ///
307 /// Use nm_device_get_hw_address() instead.
308 ///
309 /// # Returns
310 ///
311 /// the hardware address. This is the internal string used by the
312 /// device, and must not be modified.
313 #[cfg_attr(feature = "v1_24", deprecated = "Since 1.24")]
314 #[allow(deprecated)]
315 #[doc(alias = "nm_device_bt_get_hw_address")]
316 #[doc(alias = "get_hw_address")]
317 pub fn hw_address(&self) -> glib::GString {
318 unsafe {
319 from_glib_none(ffi::nm_device_bt_get_hw_address(self.to_glib_none().0))
320 }
321 }
322
323 /// Gets the name of the #NMDeviceBt.
324 ///
325 /// # Returns
326 ///
327 /// the name of the device
328 #[doc(alias = "nm_device_bt_get_name")]
329 #[doc(alias = "get_name")]
330 pub fn name(&self) -> glib::GString {
331 unsafe {
332 from_glib_none(ffi::nm_device_bt_get_name(self.to_glib_none().0))
333 }
334 }
335
336 /// The device's bluetooth capabilities, a combination of #NMBluetoothCapabilities.
337 #[doc(alias = "bt-capabilities")]
338 pub fn bt_capabilities(&self) -> BluetoothCapabilities {
339 ObjectExt::property(self, "bt-capabilities")
340 }
341
342 #[doc(alias = "bt-capabilities")]
343 pub fn connect_bt_capabilities_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
344 unsafe extern "C" fn notify_bt_capabilities_trampoline<F: Fn(&DeviceBt) + 'static>(this: *mut ffi::NMDeviceBt, _param_spec: glib::ffi::gpointer, f: glib::ffi::gpointer) {
345 let f: &F = &*(f as *const F);
346 f(&from_glib_borrow(this))
347 }
348 unsafe {
349 let f: Box_<F> = Box_::new(f);
350 connect_raw(self.as_ptr() as *mut _, c"notify::bt-capabilities".as_ptr() as *const _,
351 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(notify_bt_capabilities_trampoline::<F> as *const ())), Box_::into_raw(f))
352 }
353 }
354
355 #[doc(alias = "name")]
356 pub fn connect_name_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
357 unsafe extern "C" fn notify_name_trampoline<F: Fn(&DeviceBt) + 'static>(this: *mut ffi::NMDeviceBt, _param_spec: glib::ffi::gpointer, f: glib::ffi::gpointer) {
358 let f: &F = &*(f as *const F);
359 f(&from_glib_borrow(this))
360 }
361 unsafe {
362 let f: Box_<F> = Box_::new(f);
363 connect_raw(self.as_ptr() as *mut _, c"notify::name".as_ptr() as *const _,
364 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(notify_name_trampoline::<F> as *const ())), Box_::into_raw(f))
365 }
366 }
367}
368
369impl std::fmt::Display for DeviceBt {
370 #[inline]
371 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
372 f.write_str(&self.name())
373 }
374}
375
376// rustdoc-stripper-ignore-next
377 /// A [builder-pattern] type to construct [`DeviceBt`] objects.
378 ///
379 /// [builder-pattern]: https://doc.rust-lang.org/1.0.0/style/ownership/builders.html
380#[must_use = "The builder must be built to be used"]
381pub struct DeviceBtBuilder {
382 builder: glib::object::ObjectBuilder<'static, DeviceBt>,
383 }
384
385 impl DeviceBtBuilder {
386 fn new() -> Self {
387 Self { builder: glib::object::Object::builder() }
388 }
389
390 /// Whether the device can auto-activate a connection.
391 ///
392 /// The property setter is a synchronous D-Bus call. This is deprecated since 1.22.
393 pub fn autoconnect(self, autoconnect: bool) -> Self {
394 Self { builder: self.builder.property("autoconnect", autoconnect), }
395 }
396
397 // rustdoc-stripper-ignore-next
398 /// Build the [`DeviceBt`].
399 #[must_use = "Building the object from the builder is usually expensive and is not expected to have side effects"]
400 pub fn build(self) -> DeviceBt {
401assert_initialized_main_thread!();
402 self.builder.build() }
403}