nm_rs/auto/
setting_wpan.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    /// IEEE 802.15.4 (WPAN) MAC Settings
12    ///
13    /// ## Properties
14    ///
15    ///
16    /// #### `channel`
17    ///  IEEE 802.15.4 channel. A positive integer or -1, meaning "do not
18    /// set, use whatever the device is already set to".
19    ///
20    /// Readable | Writeable
21    ///
22    ///
23    /// #### `mac-address`
24    ///  If specified, this connection will only apply to the IEEE 802.15.4 (WPAN)
25    /// MAC layer device whose permanent MAC address matches.
26    ///
27    /// Readable | Writeable
28    ///
29    ///
30    /// #### `page`
31    ///  IEEE 802.15.4 channel page. A positive integer or -1, meaning "do not
32    /// set, use whatever the device is already set to".
33    ///
34    /// Readable | Writeable
35    ///
36    ///
37    /// #### `pan-id`
38    ///  IEEE 802.15.4 Personal Area Network (PAN) identifier.
39    ///
40    /// Readable | Writeable
41    ///
42    ///
43    /// #### `short-address`
44    ///  Short IEEE 802.15.4 address to be used within a restricted environment.
45    ///
46    /// Readable | Writeable
47    /// <details><summary><h4>Setting</h4></summary>
48    ///
49    ///
50    /// #### `name`
51    ///  The setting's name, which uniquely identifies the setting within the
52    /// connection.  Each setting type has a name unique to that type, for
53    /// example "ppp" or "802-11-wireless" or "802-3-ethernet".
54    ///
55    /// Readable
56    /// </details>
57    ///
58    /// # Implements
59    ///
60    /// [`SettingExt`][trait@crate::prelude::SettingExt]
61    #[doc(alias = "NMSettingWpan")]
62    pub struct SettingWpan(Object<ffi::NMSettingWpan, ffi::NMSettingWpanClass>) @extends Setting;
63
64    match fn {
65        type_ => || ffi::nm_setting_wpan_get_type(),
66    }
67}
68
69impl SettingWpan {
70    /// Creates a new #NMSettingWpan object with default values.
71    ///
72    /// # Returns
73    ///
74    /// the new empty #NMSettingWpan object
75    #[cfg(feature = "v1_42")]
76    #[cfg_attr(docsrs, doc(cfg(feature = "v1_42")))]
77    #[doc(alias = "nm_setting_wpan_new")]
78    pub fn new() -> SettingWpan {
79        assert_initialized_main_thread!();
80        unsafe {
81            Setting::from_glib_full(ffi::nm_setting_wpan_new()).unsafe_cast()
82        }
83    }
84
85            // rustdoc-stripper-ignore-next
86            /// Creates a new builder-pattern struct instance to construct [`SettingWpan`] objects.
87            ///
88            /// This method returns an instance of [`SettingWpanBuilder`](crate::builders::SettingWpanBuilder) which can be used to create [`SettingWpan`] objects.
89            pub fn builder() -> SettingWpanBuilder {
90                SettingWpanBuilder::new()
91            }
92        
93
94    ///
95    /// # Returns
96    ///
97    /// the #NMSettingWpan:channel property of the setting
98    #[cfg(feature = "v1_42")]
99    #[cfg_attr(docsrs, doc(cfg(feature = "v1_42")))]
100    #[doc(alias = "nm_setting_wpan_get_channel")]
101    #[doc(alias = "get_channel")]
102    pub fn channel(&self) -> i16 {
103        unsafe {
104            ffi::nm_setting_wpan_get_channel(self.to_glib_none().0)
105        }
106    }
107
108    ///
109    /// # Returns
110    ///
111    /// the #NMSettingWpan:mac-address property of the setting
112    #[cfg(feature = "v1_42")]
113    #[cfg_attr(docsrs, doc(cfg(feature = "v1_42")))]
114    #[doc(alias = "nm_setting_wpan_get_mac_address")]
115    #[doc(alias = "get_mac_address")]
116    #[doc(alias = "mac-address")]
117    pub fn mac_address(&self) -> glib::GString {
118        unsafe {
119            from_glib_none(ffi::nm_setting_wpan_get_mac_address(self.to_glib_none().0))
120        }
121    }
122
123    ///
124    /// # Returns
125    ///
126    /// the #NMSettingWpan:page property of the setting
127    #[cfg(feature = "v1_42")]
128    #[cfg_attr(docsrs, doc(cfg(feature = "v1_42")))]
129    #[doc(alias = "nm_setting_wpan_get_page")]
130    #[doc(alias = "get_page")]
131    pub fn page(&self) -> i16 {
132        unsafe {
133            ffi::nm_setting_wpan_get_page(self.to_glib_none().0)
134        }
135    }
136
137    ///
138    /// # Returns
139    ///
140    /// the #NMSettingWpan:pan-id property of the setting
141    #[cfg(feature = "v1_42")]
142    #[cfg_attr(docsrs, doc(cfg(feature = "v1_42")))]
143    #[doc(alias = "nm_setting_wpan_get_pan_id")]
144    #[doc(alias = "get_pan_id")]
145    #[doc(alias = "pan-id")]
146    pub fn pan_id(&self) -> u16 {
147        unsafe {
148            ffi::nm_setting_wpan_get_pan_id(self.to_glib_none().0)
149        }
150    }
151
152    ///
153    /// # Returns
154    ///
155    /// the #NMSettingWpan:short-address property of the setting
156    #[cfg(feature = "v1_42")]
157    #[cfg_attr(docsrs, doc(cfg(feature = "v1_42")))]
158    #[doc(alias = "nm_setting_wpan_get_short_address")]
159    #[doc(alias = "get_short_address")]
160    #[doc(alias = "short-address")]
161    pub fn short_address(&self) -> u16 {
162        unsafe {
163            ffi::nm_setting_wpan_get_short_address(self.to_glib_none().0)
164        }
165    }
166
167    #[cfg(not(feature = "v1_42"))]
168    #[cfg_attr(docsrs, doc(cfg(not(feature = "v1_42"))))]
169    pub fn channel(&self) -> i32 {
170        ObjectExt::property(self, "channel")
171    }
172
173    /// IEEE 802.15.4 channel. A positive integer or -1, meaning "do not
174    /// set, use whatever the device is already set to".
175    #[cfg(feature = "v1_16")]
176    #[cfg_attr(docsrs, doc(cfg(feature = "v1_16")))]
177    pub fn set_channel(&self, channel: i32) {
178        ObjectExt::set_property(self,"channel", channel)
179    }
180
181    #[cfg(not(feature = "v1_42"))]
182    #[cfg_attr(docsrs, doc(cfg(not(feature = "v1_42"))))]
183    #[doc(alias = "mac-address")]
184    pub fn mac_address(&self) -> Option<glib::GString> {
185        ObjectExt::property(self, "mac-address")
186    }
187
188    /// If specified, this connection will only apply to the IEEE 802.15.4 (WPAN)
189    /// MAC layer device whose permanent MAC address matches.
190    #[doc(alias = "mac-address")]
191    pub fn set_mac_address(&self, mac_address: Option<&str>) {
192        ObjectExt::set_property(self,"mac-address", mac_address)
193    }
194
195    #[cfg(not(feature = "v1_42"))]
196    #[cfg_attr(docsrs, doc(cfg(not(feature = "v1_42"))))]
197    pub fn page(&self) -> i32 {
198        ObjectExt::property(self, "page")
199    }
200
201    /// IEEE 802.15.4 channel page. A positive integer or -1, meaning "do not
202    /// set, use whatever the device is already set to".
203    #[cfg(feature = "v1_16")]
204    #[cfg_attr(docsrs, doc(cfg(feature = "v1_16")))]
205    pub fn set_page(&self, page: i32) {
206        ObjectExt::set_property(self,"page", page)
207    }
208
209    #[cfg(not(feature = "v1_42"))]
210    #[cfg_attr(docsrs, doc(cfg(not(feature = "v1_42"))))]
211    #[doc(alias = "pan-id")]
212    pub fn pan_id(&self) -> u32 {
213        ObjectExt::property(self, "pan-id")
214    }
215
216    /// IEEE 802.15.4 Personal Area Network (PAN) identifier.
217    #[doc(alias = "pan-id")]
218    pub fn set_pan_id(&self, pan_id: u32) {
219        ObjectExt::set_property(self,"pan-id", pan_id)
220    }
221
222    #[cfg(not(feature = "v1_42"))]
223    #[cfg_attr(docsrs, doc(cfg(not(feature = "v1_42"))))]
224    #[doc(alias = "short-address")]
225    pub fn short_address(&self) -> u32 {
226        ObjectExt::property(self, "short-address")
227    }
228
229    /// Short IEEE 802.15.4 address to be used within a restricted environment.
230    #[doc(alias = "short-address")]
231    pub fn set_short_address(&self, short_address: u32) {
232        ObjectExt::set_property(self,"short-address", short_address)
233    }
234
235    #[cfg(feature = "v1_16")]
236    #[cfg_attr(docsrs, doc(cfg(feature = "v1_16")))]
237    #[doc(alias = "channel")]
238    pub fn connect_channel_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
239        unsafe extern "C" fn notify_channel_trampoline<F: Fn(&SettingWpan) + 'static>(this: *mut ffi::NMSettingWpan, _param_spec: glib::ffi::gpointer, f: glib::ffi::gpointer) {
240            let f: &F = &*(f as *const F);
241            f(&from_glib_borrow(this))
242        }
243        unsafe {
244            let f: Box_<F> = Box_::new(f);
245            connect_raw(self.as_ptr() as *mut _, c"notify::channel".as_ptr() as *const _,
246                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(notify_channel_trampoline::<F> as *const ())), Box_::into_raw(f))
247        }
248    }
249
250    #[doc(alias = "mac-address")]
251    pub fn connect_mac_address_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
252        unsafe extern "C" fn notify_mac_address_trampoline<F: Fn(&SettingWpan) + 'static>(this: *mut ffi::NMSettingWpan, _param_spec: glib::ffi::gpointer, f: glib::ffi::gpointer) {
253            let f: &F = &*(f as *const F);
254            f(&from_glib_borrow(this))
255        }
256        unsafe {
257            let f: Box_<F> = Box_::new(f);
258            connect_raw(self.as_ptr() as *mut _, c"notify::mac-address".as_ptr() as *const _,
259                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(notify_mac_address_trampoline::<F> as *const ())), Box_::into_raw(f))
260        }
261    }
262
263    #[cfg(feature = "v1_16")]
264    #[cfg_attr(docsrs, doc(cfg(feature = "v1_16")))]
265    #[doc(alias = "page")]
266    pub fn connect_page_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
267        unsafe extern "C" fn notify_page_trampoline<F: Fn(&SettingWpan) + 'static>(this: *mut ffi::NMSettingWpan, _param_spec: glib::ffi::gpointer, f: glib::ffi::gpointer) {
268            let f: &F = &*(f as *const F);
269            f(&from_glib_borrow(this))
270        }
271        unsafe {
272            let f: Box_<F> = Box_::new(f);
273            connect_raw(self.as_ptr() as *mut _, c"notify::page".as_ptr() as *const _,
274                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(notify_page_trampoline::<F> as *const ())), Box_::into_raw(f))
275        }
276    }
277
278    #[doc(alias = "pan-id")]
279    pub fn connect_pan_id_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
280        unsafe extern "C" fn notify_pan_id_trampoline<F: Fn(&SettingWpan) + 'static>(this: *mut ffi::NMSettingWpan, _param_spec: glib::ffi::gpointer, f: glib::ffi::gpointer) {
281            let f: &F = &*(f as *const F);
282            f(&from_glib_borrow(this))
283        }
284        unsafe {
285            let f: Box_<F> = Box_::new(f);
286            connect_raw(self.as_ptr() as *mut _, c"notify::pan-id".as_ptr() as *const _,
287                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(notify_pan_id_trampoline::<F> as *const ())), Box_::into_raw(f))
288        }
289    }
290
291    #[doc(alias = "short-address")]
292    pub fn connect_short_address_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
293        unsafe extern "C" fn notify_short_address_trampoline<F: Fn(&SettingWpan) + 'static>(this: *mut ffi::NMSettingWpan, _param_spec: glib::ffi::gpointer, f: glib::ffi::gpointer) {
294            let f: &F = &*(f as *const F);
295            f(&from_glib_borrow(this))
296        }
297        unsafe {
298            let f: Box_<F> = Box_::new(f);
299            connect_raw(self.as_ptr() as *mut _, c"notify::short-address".as_ptr() as *const _,
300                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(notify_short_address_trampoline::<F> as *const ())), Box_::into_raw(f))
301        }
302    }
303}
304
305#[cfg(feature = "v1_42")]
306#[cfg_attr(docsrs, doc(cfg(feature = "v1_42")))]
307impl Default for SettingWpan {
308                     fn default() -> Self {
309                         Self::new()
310                     }
311                 }
312
313// rustdoc-stripper-ignore-next
314        /// A [builder-pattern] type to construct [`SettingWpan`] objects.
315        ///
316        /// [builder-pattern]: https://doc.rust-lang.org/1.0.0/style/ownership/builders.html
317#[must_use = "The builder must be built to be used"]
318pub struct SettingWpanBuilder {
319            builder: glib::object::ObjectBuilder<'static, SettingWpan>,
320        }
321
322        impl SettingWpanBuilder {
323        fn new() -> Self {
324            Self { builder: glib::object::Object::builder() }
325        }
326
327                            /// IEEE 802.15.4 channel. A positive integer or -1, meaning "do not
328                            /// set, use whatever the device is already set to".
329                            #[cfg(feature = "v1_16")]
330    #[cfg_attr(docsrs, doc(cfg(feature = "v1_16")))]
331    pub fn channel(self, channel: i32) -> Self {
332                            Self { builder: self.builder.property("channel", channel), }
333                        }
334
335                            /// If specified, this connection will only apply to the IEEE 802.15.4 (WPAN)
336                            /// MAC layer device whose permanent MAC address matches.
337                            pub fn mac_address(self, mac_address: impl Into<glib::GString>) -> Self {
338                            Self { builder: self.builder.property("mac-address", mac_address.into()), }
339                        }
340
341                            /// IEEE 802.15.4 channel page. A positive integer or -1, meaning "do not
342                            /// set, use whatever the device is already set to".
343                            #[cfg(feature = "v1_16")]
344    #[cfg_attr(docsrs, doc(cfg(feature = "v1_16")))]
345    pub fn page(self, page: i32) -> Self {
346                            Self { builder: self.builder.property("page", page), }
347                        }
348
349                            /// IEEE 802.15.4 Personal Area Network (PAN) identifier.
350                            pub fn pan_id(self, pan_id: u32) -> Self {
351                            Self { builder: self.builder.property("pan-id", pan_id), }
352                        }
353
354                            /// Short IEEE 802.15.4 address to be used within a restricted environment.
355                            pub fn short_address(self, short_address: u32) -> Self {
356                            Self { builder: self.builder.property("short-address", short_address), }
357                        }
358
359    // rustdoc-stripper-ignore-next
360    /// Build the [`SettingWpan`].
361    #[must_use = "Building the object from the builder is usually expensive and is not expected to have side effects"]
362    pub fn build(self) -> SettingWpan {
363assert_initialized_main_thread!();
364    self.builder.build() }
365}