1use crate::{ffi,Setting};
7use glib::{prelude::*,signal::{connect_raw, SignalHandlerId},translate::*};
8use std::{boxed::Box as Box_};
9
10glib::wrapper! {
11 #[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 #[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 pub fn builder() -> SettingWpanBuilder {
90 SettingWpanBuilder::new()
91 }
92
93
94 #[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 #[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 #[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 #[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 #[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 #[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 #[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 #[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 #[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 #[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#[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 #[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 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 #[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 pub fn pan_id(self, pan_id: u32) -> Self {
351 Self { builder: self.builder.property("pan-id", pan_id), }
352 }
353
354 pub fn short_address(self, short_address: u32) -> Self {
356 Self { builder: self.builder.property("short-address", short_address), }
357 }
358
359 #[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}