use crate::{ffi,Setting};
use glib::{prelude::*,signal::{connect_raw, SignalHandlerId},translate::*};
use std::{boxed::Box as Box_};
glib::wrapper! {
#[doc(alias = "NMSettingWpan")]
pub struct SettingWpan(Object<ffi::NMSettingWpan, ffi::NMSettingWpanClass>) @extends Setting;
match fn {
type_ => || ffi::nm_setting_wpan_get_type(),
}
}
impl SettingWpan {
#[cfg(feature = "v1_42")]
#[cfg_attr(docsrs, doc(cfg(feature = "v1_42")))]
#[doc(alias = "nm_setting_wpan_new")]
pub fn new() -> SettingWpan {
assert_initialized_main_thread!();
unsafe {
Setting::from_glib_full(ffi::nm_setting_wpan_new()).unsafe_cast()
}
}
pub fn builder() -> SettingWpanBuilder {
SettingWpanBuilder::new()
}
#[cfg(feature = "v1_42")]
#[cfg_attr(docsrs, doc(cfg(feature = "v1_42")))]
#[doc(alias = "nm_setting_wpan_get_channel")]
#[doc(alias = "get_channel")]
pub fn channel(&self) -> i16 {
unsafe {
ffi::nm_setting_wpan_get_channel(self.to_glib_none().0)
}
}
#[cfg(feature = "v1_42")]
#[cfg_attr(docsrs, doc(cfg(feature = "v1_42")))]
#[doc(alias = "nm_setting_wpan_get_mac_address")]
#[doc(alias = "get_mac_address")]
#[doc(alias = "mac-address")]
pub fn mac_address(&self) -> glib::GString {
unsafe {
from_glib_none(ffi::nm_setting_wpan_get_mac_address(self.to_glib_none().0))
}
}
#[cfg(feature = "v1_42")]
#[cfg_attr(docsrs, doc(cfg(feature = "v1_42")))]
#[doc(alias = "nm_setting_wpan_get_page")]
#[doc(alias = "get_page")]
pub fn page(&self) -> i16 {
unsafe {
ffi::nm_setting_wpan_get_page(self.to_glib_none().0)
}
}
#[cfg(feature = "v1_42")]
#[cfg_attr(docsrs, doc(cfg(feature = "v1_42")))]
#[doc(alias = "nm_setting_wpan_get_pan_id")]
#[doc(alias = "get_pan_id")]
#[doc(alias = "pan-id")]
pub fn pan_id(&self) -> u16 {
unsafe {
ffi::nm_setting_wpan_get_pan_id(self.to_glib_none().0)
}
}
#[cfg(feature = "v1_42")]
#[cfg_attr(docsrs, doc(cfg(feature = "v1_42")))]
#[doc(alias = "nm_setting_wpan_get_short_address")]
#[doc(alias = "get_short_address")]
#[doc(alias = "short-address")]
pub fn short_address(&self) -> u16 {
unsafe {
ffi::nm_setting_wpan_get_short_address(self.to_glib_none().0)
}
}
#[cfg(not(feature = "v1_42"))]
#[cfg_attr(docsrs, doc(cfg(not(feature = "v1_42"))))]
pub fn channel(&self) -> i32 {
ObjectExt::property(self, "channel")
}
#[cfg(feature = "v1_16")]
#[cfg_attr(docsrs, doc(cfg(feature = "v1_16")))]
pub fn set_channel(&self, channel: i32) {
ObjectExt::set_property(self,"channel", channel)
}
#[cfg(not(feature = "v1_42"))]
#[cfg_attr(docsrs, doc(cfg(not(feature = "v1_42"))))]
#[doc(alias = "mac-address")]
pub fn mac_address(&self) -> Option<glib::GString> {
ObjectExt::property(self, "mac-address")
}
#[doc(alias = "mac-address")]
pub fn set_mac_address(&self, mac_address: Option<&str>) {
ObjectExt::set_property(self,"mac-address", mac_address)
}
#[cfg(not(feature = "v1_42"))]
#[cfg_attr(docsrs, doc(cfg(not(feature = "v1_42"))))]
pub fn page(&self) -> i32 {
ObjectExt::property(self, "page")
}
#[cfg(feature = "v1_16")]
#[cfg_attr(docsrs, doc(cfg(feature = "v1_16")))]
pub fn set_page(&self, page: i32) {
ObjectExt::set_property(self,"page", page)
}
#[cfg(not(feature = "v1_42"))]
#[cfg_attr(docsrs, doc(cfg(not(feature = "v1_42"))))]
#[doc(alias = "pan-id")]
pub fn pan_id(&self) -> u32 {
ObjectExt::property(self, "pan-id")
}
#[doc(alias = "pan-id")]
pub fn set_pan_id(&self, pan_id: u32) {
ObjectExt::set_property(self,"pan-id", pan_id)
}
#[cfg(not(feature = "v1_42"))]
#[cfg_attr(docsrs, doc(cfg(not(feature = "v1_42"))))]
#[doc(alias = "short-address")]
pub fn short_address(&self) -> u32 {
ObjectExt::property(self, "short-address")
}
#[doc(alias = "short-address")]
pub fn set_short_address(&self, short_address: u32) {
ObjectExt::set_property(self,"short-address", short_address)
}
#[cfg(feature = "v1_16")]
#[cfg_attr(docsrs, doc(cfg(feature = "v1_16")))]
#[doc(alias = "channel")]
pub fn connect_channel_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
unsafe extern "C" fn notify_channel_trampoline<F: Fn(&SettingWpan) + 'static>(this: *mut ffi::NMSettingWpan, _param_spec: glib::ffi::gpointer, f: glib::ffi::gpointer) {
let f: &F = &*(f as *const F);
f(&from_glib_borrow(this))
}
unsafe {
let f: Box_<F> = Box_::new(f);
connect_raw(self.as_ptr() as *mut _, c"notify::channel".as_ptr() as *const _,
Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(notify_channel_trampoline::<F> as *const ())), Box_::into_raw(f))
}
}
#[doc(alias = "mac-address")]
pub fn connect_mac_address_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
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) {
let f: &F = &*(f as *const F);
f(&from_glib_borrow(this))
}
unsafe {
let f: Box_<F> = Box_::new(f);
connect_raw(self.as_ptr() as *mut _, c"notify::mac-address".as_ptr() as *const _,
Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(notify_mac_address_trampoline::<F> as *const ())), Box_::into_raw(f))
}
}
#[cfg(feature = "v1_16")]
#[cfg_attr(docsrs, doc(cfg(feature = "v1_16")))]
#[doc(alias = "page")]
pub fn connect_page_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
unsafe extern "C" fn notify_page_trampoline<F: Fn(&SettingWpan) + 'static>(this: *mut ffi::NMSettingWpan, _param_spec: glib::ffi::gpointer, f: glib::ffi::gpointer) {
let f: &F = &*(f as *const F);
f(&from_glib_borrow(this))
}
unsafe {
let f: Box_<F> = Box_::new(f);
connect_raw(self.as_ptr() as *mut _, c"notify::page".as_ptr() as *const _,
Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(notify_page_trampoline::<F> as *const ())), Box_::into_raw(f))
}
}
#[doc(alias = "pan-id")]
pub fn connect_pan_id_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
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) {
let f: &F = &*(f as *const F);
f(&from_glib_borrow(this))
}
unsafe {
let f: Box_<F> = Box_::new(f);
connect_raw(self.as_ptr() as *mut _, c"notify::pan-id".as_ptr() as *const _,
Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(notify_pan_id_trampoline::<F> as *const ())), Box_::into_raw(f))
}
}
#[doc(alias = "short-address")]
pub fn connect_short_address_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
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) {
let f: &F = &*(f as *const F);
f(&from_glib_borrow(this))
}
unsafe {
let f: Box_<F> = Box_::new(f);
connect_raw(self.as_ptr() as *mut _, c"notify::short-address".as_ptr() as *const _,
Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(notify_short_address_trampoline::<F> as *const ())), Box_::into_raw(f))
}
}
}
#[cfg(feature = "v1_42")]
#[cfg_attr(docsrs, doc(cfg(feature = "v1_42")))]
impl Default for SettingWpan {
fn default() -> Self {
Self::new()
}
}
#[must_use = "The builder must be built to be used"]
pub struct SettingWpanBuilder {
builder: glib::object::ObjectBuilder<'static, SettingWpan>,
}
impl SettingWpanBuilder {
fn new() -> Self {
Self { builder: glib::object::Object::builder() }
}
#[cfg(feature = "v1_16")]
#[cfg_attr(docsrs, doc(cfg(feature = "v1_16")))]
pub fn channel(self, channel: i32) -> Self {
Self { builder: self.builder.property("channel", channel), }
}
pub fn mac_address(self, mac_address: impl Into<glib::GString>) -> Self {
Self { builder: self.builder.property("mac-address", mac_address.into()), }
}
#[cfg(feature = "v1_16")]
#[cfg_attr(docsrs, doc(cfg(feature = "v1_16")))]
pub fn page(self, page: i32) -> Self {
Self { builder: self.builder.property("page", page), }
}
pub fn pan_id(self, pan_id: u32) -> Self {
Self { builder: self.builder.property("pan-id", pan_id), }
}
pub fn short_address(self, short_address: u32) -> Self {
Self { builder: self.builder.property("short-address", short_address), }
}
#[must_use = "Building the object from the builder is usually expensive and is not expected to have side effects"]
pub fn build(self) -> SettingWpan {
assert_initialized_main_thread!();
self.builder.build() }
}