use crate::{ffi,Setting};
use glib::{prelude::*};
#[cfg(feature = "v1_46")]
#[cfg_attr(docsrs, doc(cfg(feature = "v1_46")))]
use glib::{signal::{connect_raw, SignalHandlerId},translate::*};
#[cfg(feature = "v1_46")]
#[cfg_attr(docsrs, doc(cfg(feature = "v1_46")))]
use std::{boxed::Box as Box_};
glib::wrapper! {
#[doc(alias = "NMSettingHsr")]
pub struct SettingHsr(Object<ffi::NMSettingHsr, ffi::NMSettingHsrClass>) @extends Setting;
match fn {
type_ => || ffi::nm_setting_hsr_get_type(),
}
}
impl SettingHsr {
#[cfg(feature = "v1_46")]
#[cfg_attr(docsrs, doc(cfg(feature = "v1_46")))]
#[doc(alias = "nm_setting_hsr_new")]
pub fn new() -> SettingHsr {
assert_initialized_main_thread!();
unsafe {
Setting::from_glib_full(ffi::nm_setting_hsr_new()).unsafe_cast()
}
}
pub fn builder() -> SettingHsrBuilder {
SettingHsrBuilder::new()
}
#[cfg(feature = "v1_46")]
#[cfg_attr(docsrs, doc(cfg(feature = "v1_46")))]
#[doc(alias = "nm_setting_hsr_get_multicast_spec")]
#[doc(alias = "get_multicast_spec")]
#[doc(alias = "multicast-spec")]
pub fn multicast_spec(&self) -> u32 {
unsafe {
ffi::nm_setting_hsr_get_multicast_spec(self.to_glib_none().0)
}
}
#[cfg(feature = "v1_46")]
#[cfg_attr(docsrs, doc(cfg(feature = "v1_46")))]
#[doc(alias = "nm_setting_hsr_get_port1")]
#[doc(alias = "get_port1")]
pub fn port1(&self) -> glib::GString {
unsafe {
from_glib_none(ffi::nm_setting_hsr_get_port1(self.to_glib_none().0))
}
}
#[cfg(feature = "v1_46")]
#[cfg_attr(docsrs, doc(cfg(feature = "v1_46")))]
#[doc(alias = "nm_setting_hsr_get_port2")]
#[doc(alias = "get_port2")]
pub fn port2(&self) -> glib::GString {
unsafe {
from_glib_none(ffi::nm_setting_hsr_get_port2(self.to_glib_none().0))
}
}
#[cfg(feature = "v1_46")]
#[cfg_attr(docsrs, doc(cfg(feature = "v1_46")))]
#[doc(alias = "nm_setting_hsr_get_prp")]
#[doc(alias = "get_prp")]
#[doc(alias = "prp")]
pub fn is_prp(&self) -> bool {
unsafe {
from_glib(ffi::nm_setting_hsr_get_prp(self.to_glib_none().0))
}
}
#[cfg(feature = "v1_46")]
#[cfg_attr(docsrs, doc(cfg(feature = "v1_46")))]
#[doc(alias = "multicast-spec")]
pub fn set_multicast_spec(&self, multicast_spec: u32) {
ObjectExt::set_property(self,"multicast-spec", multicast_spec)
}
#[cfg(feature = "v1_46")]
#[cfg_attr(docsrs, doc(cfg(feature = "v1_46")))]
pub fn set_port1(&self, port1: Option<&str>) {
ObjectExt::set_property(self,"port1", port1)
}
#[cfg(feature = "v1_46")]
#[cfg_attr(docsrs, doc(cfg(feature = "v1_46")))]
pub fn set_port2(&self, port2: Option<&str>) {
ObjectExt::set_property(self,"port2", port2)
}
#[cfg(feature = "v1_46")]
#[cfg_attr(docsrs, doc(cfg(feature = "v1_46")))]
pub fn set_prp(&self, prp: bool) {
ObjectExt::set_property(self,"prp", prp)
}
#[cfg(feature = "v1_46")]
#[cfg_attr(docsrs, doc(cfg(feature = "v1_46")))]
#[doc(alias = "multicast-spec")]
pub fn connect_multicast_spec_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
unsafe extern "C" fn notify_multicast_spec_trampoline<F: Fn(&SettingHsr) + 'static>(this: *mut ffi::NMSettingHsr, _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::multicast-spec".as_ptr() as *const _,
Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(notify_multicast_spec_trampoline::<F> as *const ())), Box_::into_raw(f))
}
}
#[cfg(feature = "v1_46")]
#[cfg_attr(docsrs, doc(cfg(feature = "v1_46")))]
#[doc(alias = "port1")]
pub fn connect_port1_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
unsafe extern "C" fn notify_port1_trampoline<F: Fn(&SettingHsr) + 'static>(this: *mut ffi::NMSettingHsr, _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::port1".as_ptr() as *const _,
Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(notify_port1_trampoline::<F> as *const ())), Box_::into_raw(f))
}
}
#[cfg(feature = "v1_46")]
#[cfg_attr(docsrs, doc(cfg(feature = "v1_46")))]
#[doc(alias = "port2")]
pub fn connect_port2_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
unsafe extern "C" fn notify_port2_trampoline<F: Fn(&SettingHsr) + 'static>(this: *mut ffi::NMSettingHsr, _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::port2".as_ptr() as *const _,
Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(notify_port2_trampoline::<F> as *const ())), Box_::into_raw(f))
}
}
#[cfg(feature = "v1_46")]
#[cfg_attr(docsrs, doc(cfg(feature = "v1_46")))]
#[doc(alias = "prp")]
pub fn connect_prp_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
unsafe extern "C" fn notify_prp_trampoline<F: Fn(&SettingHsr) + 'static>(this: *mut ffi::NMSettingHsr, _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::prp".as_ptr() as *const _,
Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(notify_prp_trampoline::<F> as *const ())), Box_::into_raw(f))
}
}
}
#[cfg(feature = "v1_46")]
#[cfg_attr(docsrs, doc(cfg(feature = "v1_46")))]
impl Default for SettingHsr {
fn default() -> Self {
Self::new()
}
}
#[must_use = "The builder must be built to be used"]
pub struct SettingHsrBuilder {
builder: glib::object::ObjectBuilder<'static, SettingHsr>,
}
impl SettingHsrBuilder {
fn new() -> Self {
Self { builder: glib::object::Object::builder() }
}
#[cfg(feature = "v1_46")]
#[cfg_attr(docsrs, doc(cfg(feature = "v1_46")))]
pub fn multicast_spec(self, multicast_spec: u32) -> Self {
Self { builder: self.builder.property("multicast-spec", multicast_spec), }
}
#[cfg(feature = "v1_46")]
#[cfg_attr(docsrs, doc(cfg(feature = "v1_46")))]
pub fn port1(self, port1: impl Into<glib::GString>) -> Self {
Self { builder: self.builder.property("port1", port1.into()), }
}
#[cfg(feature = "v1_46")]
#[cfg_attr(docsrs, doc(cfg(feature = "v1_46")))]
pub fn port2(self, port2: impl Into<glib::GString>) -> Self {
Self { builder: self.builder.property("port2", port2.into()), }
}
#[cfg(feature = "v1_46")]
#[cfg_attr(docsrs, doc(cfg(feature = "v1_46")))]
pub fn prp(self, prp: bool) -> Self {
Self { builder: self.builder.property("prp", prp), }
}
#[must_use = "Building the object from the builder is usually expensive and is not expected to have side effects"]
pub fn build(self) -> SettingHsr {
assert_initialized_main_thread!();
self.builder.build() }
}