nm_rs/auto/
setting_bluetooth.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,Setting};
7use glib::{prelude::*,signal::{connect_raw, SignalHandlerId},translate::*};
8use std::{boxed::Box as Box_};
9
10glib::wrapper! {
11    /// Bluetooth Settings
12    ///
13    /// ## Properties
14    ///
15    ///
16    /// #### `bdaddr`
17    ///  The Bluetooth address of the device.
18    ///
19    /// Readable | Writeable
20    ///
21    ///
22    /// #### `type`
23    ///  Either "dun" for Dial-Up Networking connections or "panu" for Personal
24    /// Area Networking connections to devices supporting the NAP profile.
25    ///
26    /// Readable | Writeable
27    /// <details><summary><h4>Setting</h4></summary>
28    ///
29    ///
30    /// #### `name`
31    ///  The setting's name, which uniquely identifies the setting within the
32    /// connection.  Each setting type has a name unique to that type, for
33    /// example "ppp" or "802-11-wireless" or "802-3-ethernet".
34    ///
35    /// Readable
36    /// </details>
37    ///
38    /// # Implements
39    ///
40    /// [`SettingExt`][trait@crate::prelude::SettingExt]
41    #[doc(alias = "NMSettingBluetooth")]
42    pub struct SettingBluetooth(Object<ffi::NMSettingBluetooth, ffi::NMSettingBluetoothClass>) @extends Setting;
43
44    match fn {
45        type_ => || ffi::nm_setting_bluetooth_get_type(),
46    }
47}
48
49impl SettingBluetooth {
50    /// Creates a new #NMSettingBluetooth object with default values.
51    ///
52    /// # Returns
53    ///
54    /// the new empty #NMSettingBluetooth object
55    #[doc(alias = "nm_setting_bluetooth_new")]
56    pub fn new() -> SettingBluetooth {
57        assert_initialized_main_thread!();
58        unsafe {
59            Setting::from_glib_full(ffi::nm_setting_bluetooth_new()).unsafe_cast()
60        }
61    }
62
63            // rustdoc-stripper-ignore-next
64            /// Creates a new builder-pattern struct instance to construct [`SettingBluetooth`] objects.
65            ///
66            /// This method returns an instance of [`SettingBluetoothBuilder`](crate::builders::SettingBluetoothBuilder) which can be used to create [`SettingBluetooth`] objects.
67            pub fn builder() -> SettingBluetoothBuilder {
68                SettingBluetoothBuilder::new()
69            }
70        
71
72    /// Gets the Bluetooth address of the remote device which this setting
73    /// describes a connection to.
74    ///
75    /// # Returns
76    ///
77    /// the Bluetooth address
78    #[doc(alias = "nm_setting_bluetooth_get_bdaddr")]
79    #[doc(alias = "get_bdaddr")]
80    pub fn bdaddr(&self) -> glib::GString {
81        unsafe {
82            from_glib_none(ffi::nm_setting_bluetooth_get_bdaddr(self.to_glib_none().0))
83        }
84    }
85
86    /// Returns the connection method for communicating with the remote device (i.e.
87    /// either DUN to a DUN-capable device or PANU to a NAP-capable device).
88    ///
89    /// # Returns
90    ///
91    /// the type, either [`SETTING_BLUETOOTH_TYPE_PANU`][crate::SETTING_BLUETOOTH_TYPE_PANU],
92    /// [`SETTING_BLUETOOTH_TYPE_NAP`][crate::SETTING_BLUETOOTH_TYPE_NAP] or [`SETTING_BLUETOOTH_TYPE_DUN`][crate::SETTING_BLUETOOTH_TYPE_DUN]
93    #[doc(alias = "nm_setting_bluetooth_get_connection_type")]
94    #[doc(alias = "get_connection_type")]
95    pub fn connection_type(&self) -> glib::GString {
96        unsafe {
97            from_glib_none(ffi::nm_setting_bluetooth_get_connection_type(self.to_glib_none().0))
98        }
99    }
100
101    /// The Bluetooth address of the device.
102    pub fn set_bdaddr(&self, bdaddr: Option<&str>) {
103        ObjectExt::set_property(self,"bdaddr", bdaddr)
104    }
105
106    /// Either "dun" for Dial-Up Networking connections or "panu" for Personal
107    /// Area Networking connections to devices supporting the NAP profile.
108    #[doc(alias = "type")]
109    pub fn type_(&self) -> Option<glib::GString> {
110        ObjectExt::property(self, "type")
111    }
112
113    /// Either "dun" for Dial-Up Networking connections or "panu" for Personal
114    /// Area Networking connections to devices supporting the NAP profile.
115    #[doc(alias = "type")]
116    pub fn set_type(&self, type_: Option<&str>) {
117        ObjectExt::set_property(self,"type", type_)
118    }
119
120    #[doc(alias = "bdaddr")]
121    pub fn connect_bdaddr_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
122        unsafe extern "C" fn notify_bdaddr_trampoline<F: Fn(&SettingBluetooth) + 'static>(this: *mut ffi::NMSettingBluetooth, _param_spec: glib::ffi::gpointer, f: glib::ffi::gpointer) {
123            let f: &F = &*(f as *const F);
124            f(&from_glib_borrow(this))
125        }
126        unsafe {
127            let f: Box_<F> = Box_::new(f);
128            connect_raw(self.as_ptr() as *mut _, c"notify::bdaddr".as_ptr() as *const _,
129                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(notify_bdaddr_trampoline::<F> as *const ())), Box_::into_raw(f))
130        }
131    }
132
133    #[doc(alias = "type")]
134    pub fn connect_type_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
135        unsafe extern "C" fn notify_type_trampoline<F: Fn(&SettingBluetooth) + 'static>(this: *mut ffi::NMSettingBluetooth, _param_spec: glib::ffi::gpointer, f: glib::ffi::gpointer) {
136            let f: &F = &*(f as *const F);
137            f(&from_glib_borrow(this))
138        }
139        unsafe {
140            let f: Box_<F> = Box_::new(f);
141            connect_raw(self.as_ptr() as *mut _, c"notify::type".as_ptr() as *const _,
142                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(notify_type_trampoline::<F> as *const ())), Box_::into_raw(f))
143        }
144    }
145}
146
147impl Default for SettingBluetooth {
148                     fn default() -> Self {
149                         Self::new()
150                     }
151                 }
152
153// rustdoc-stripper-ignore-next
154        /// A [builder-pattern] type to construct [`SettingBluetooth`] objects.
155        ///
156        /// [builder-pattern]: https://doc.rust-lang.org/1.0.0/style/ownership/builders.html
157#[must_use = "The builder must be built to be used"]
158pub struct SettingBluetoothBuilder {
159            builder: glib::object::ObjectBuilder<'static, SettingBluetooth>,
160        }
161
162        impl SettingBluetoothBuilder {
163        fn new() -> Self {
164            Self { builder: glib::object::Object::builder() }
165        }
166
167                            /// The Bluetooth address of the device.
168                            pub fn bdaddr(self, bdaddr: impl Into<glib::GString>) -> Self {
169                            Self { builder: self.builder.property("bdaddr", bdaddr.into()), }
170                        }
171
172                            pub fn type_(self, type_: impl Into<glib::GString>) -> Self {
173                            Self { builder: self.builder.property("type", type_.into()), }
174                        }
175
176    // rustdoc-stripper-ignore-next
177    /// Build the [`SettingBluetooth`].
178    #[must_use = "Building the object from the builder is usually expensive and is not expected to have side effects"]
179    pub fn build(self) -> SettingBluetooth {
180assert_initialized_main_thread!();
181    self.builder.build() }
182}