use crate::{ffi,Setting};
#[cfg(feature = "v1_2")]
#[cfg_attr(docsrs, doc(cfg(feature = "v1_2")))]
use crate::{SettingMacvlanMode};
use glib::{prelude::*};
#[cfg(feature = "v1_2")]
#[cfg_attr(docsrs, doc(cfg(feature = "v1_2")))]
use glib::{signal::{connect_raw, SignalHandlerId},translate::*};
#[cfg(feature = "v1_2")]
#[cfg_attr(docsrs, doc(cfg(feature = "v1_2")))]
use std::{boxed::Box as Box_};
glib::wrapper! {
#[doc(alias = "NMSettingMacvlan")]
pub struct SettingMacvlan(Object<ffi::NMSettingMacvlan, ffi::NMSettingMacvlanClass>) @extends Setting;
match fn {
type_ => || ffi::nm_setting_macvlan_get_type(),
}
}
impl SettingMacvlan {
#[cfg(feature = "v1_2")]
#[cfg_attr(docsrs, doc(cfg(feature = "v1_2")))]
#[doc(alias = "nm_setting_macvlan_new")]
pub fn new() -> SettingMacvlan {
assert_initialized_main_thread!();
unsafe {
Setting::from_glib_full(ffi::nm_setting_macvlan_new()).unsafe_cast()
}
}
pub fn builder() -> SettingMacvlanBuilder {
SettingMacvlanBuilder::new()
}
#[cfg(feature = "v1_2")]
#[cfg_attr(docsrs, doc(cfg(feature = "v1_2")))]
#[doc(alias = "nm_setting_macvlan_get_mode")]
#[doc(alias = "get_mode")]
pub fn mode(&self) -> SettingMacvlanMode {
unsafe {
from_glib(ffi::nm_setting_macvlan_get_mode(self.to_glib_none().0))
}
}
#[cfg(feature = "v1_2")]
#[cfg_attr(docsrs, doc(cfg(feature = "v1_2")))]
#[doc(alias = "nm_setting_macvlan_get_parent")]
#[doc(alias = "get_parent")]
pub fn parent(&self) -> glib::GString {
unsafe {
from_glib_none(ffi::nm_setting_macvlan_get_parent(self.to_glib_none().0))
}
}
#[cfg(feature = "v1_2")]
#[cfg_attr(docsrs, doc(cfg(feature = "v1_2")))]
#[doc(alias = "nm_setting_macvlan_get_promiscuous")]
#[doc(alias = "get_promiscuous")]
#[doc(alias = "promiscuous")]
pub fn is_promiscuous(&self) -> bool {
unsafe {
from_glib(ffi::nm_setting_macvlan_get_promiscuous(self.to_glib_none().0))
}
}
#[cfg(feature = "v1_2")]
#[cfg_attr(docsrs, doc(cfg(feature = "v1_2")))]
#[doc(alias = "nm_setting_macvlan_get_tap")]
#[doc(alias = "get_tap")]
#[doc(alias = "tap")]
pub fn is_tap(&self) -> bool {
unsafe {
from_glib(ffi::nm_setting_macvlan_get_tap(self.to_glib_none().0))
}
}
#[cfg(feature = "v1_2")]
#[cfg_attr(docsrs, doc(cfg(feature = "v1_2")))]
pub fn set_mode(&self, mode: u32) {
ObjectExt::set_property(self,"mode", mode)
}
#[cfg(feature = "v1_2")]
#[cfg_attr(docsrs, doc(cfg(feature = "v1_2")))]
pub fn set_parent(&self, parent: Option<&str>) {
ObjectExt::set_property(self,"parent", parent)
}
#[cfg(feature = "v1_2")]
#[cfg_attr(docsrs, doc(cfg(feature = "v1_2")))]
pub fn set_promiscuous(&self, promiscuous: bool) {
ObjectExt::set_property(self,"promiscuous", promiscuous)
}
#[cfg(feature = "v1_2")]
#[cfg_attr(docsrs, doc(cfg(feature = "v1_2")))]
pub fn set_tap(&self, tap: bool) {
ObjectExt::set_property(self,"tap", tap)
}
#[cfg(feature = "v1_2")]
#[cfg_attr(docsrs, doc(cfg(feature = "v1_2")))]
#[doc(alias = "mode")]
pub fn connect_mode_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
unsafe extern "C" fn notify_mode_trampoline<F: Fn(&SettingMacvlan) + 'static>(this: *mut ffi::NMSettingMacvlan, _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::mode".as_ptr() as *const _,
Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(notify_mode_trampoline::<F> as *const ())), Box_::into_raw(f))
}
}
#[cfg(feature = "v1_2")]
#[cfg_attr(docsrs, doc(cfg(feature = "v1_2")))]
#[doc(alias = "parent")]
pub fn connect_parent_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
unsafe extern "C" fn notify_parent_trampoline<F: Fn(&SettingMacvlan) + 'static>(this: *mut ffi::NMSettingMacvlan, _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::parent".as_ptr() as *const _,
Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(notify_parent_trampoline::<F> as *const ())), Box_::into_raw(f))
}
}
#[cfg(feature = "v1_2")]
#[cfg_attr(docsrs, doc(cfg(feature = "v1_2")))]
#[doc(alias = "promiscuous")]
pub fn connect_promiscuous_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
unsafe extern "C" fn notify_promiscuous_trampoline<F: Fn(&SettingMacvlan) + 'static>(this: *mut ffi::NMSettingMacvlan, _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::promiscuous".as_ptr() as *const _,
Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(notify_promiscuous_trampoline::<F> as *const ())), Box_::into_raw(f))
}
}
#[cfg(feature = "v1_2")]
#[cfg_attr(docsrs, doc(cfg(feature = "v1_2")))]
#[doc(alias = "tap")]
pub fn connect_tap_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
unsafe extern "C" fn notify_tap_trampoline<F: Fn(&SettingMacvlan) + 'static>(this: *mut ffi::NMSettingMacvlan, _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::tap".as_ptr() as *const _,
Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(notify_tap_trampoline::<F> as *const ())), Box_::into_raw(f))
}
}
}
#[cfg(feature = "v1_2")]
#[cfg_attr(docsrs, doc(cfg(feature = "v1_2")))]
impl Default for SettingMacvlan {
fn default() -> Self {
Self::new()
}
}
#[must_use = "The builder must be built to be used"]
pub struct SettingMacvlanBuilder {
builder: glib::object::ObjectBuilder<'static, SettingMacvlan>,
}
impl SettingMacvlanBuilder {
fn new() -> Self {
Self { builder: glib::object::Object::builder() }
}
#[cfg(feature = "v1_2")]
#[cfg_attr(docsrs, doc(cfg(feature = "v1_2")))]
pub fn mode(self, mode: u32) -> Self {
Self { builder: self.builder.property("mode", mode), }
}
#[cfg(feature = "v1_2")]
#[cfg_attr(docsrs, doc(cfg(feature = "v1_2")))]
pub fn parent(self, parent: impl Into<glib::GString>) -> Self {
Self { builder: self.builder.property("parent", parent.into()), }
}
#[cfg(feature = "v1_2")]
#[cfg_attr(docsrs, doc(cfg(feature = "v1_2")))]
pub fn promiscuous(self, promiscuous: bool) -> Self {
Self { builder: self.builder.property("promiscuous", promiscuous), }
}
#[cfg(feature = "v1_2")]
#[cfg_attr(docsrs, doc(cfg(feature = "v1_2")))]
pub fn tap(self, tap: bool) -> Self {
Self { builder: self.builder.property("tap", tap), }
}
#[must_use = "Building the object from the builder is usually expensive and is not expected to have side effects"]
pub fn build(self) -> SettingMacvlan {
assert_initialized_main_thread!();
self.builder.build() }
}