use crate::{ffi,Setting};
use glib::{prelude::*};
#[cfg(feature = "v1_10")]
#[cfg_attr(docsrs, doc(cfg(feature = "v1_10")))]
use glib::{signal::{connect_raw, SignalHandlerId},translate::*};
#[cfg(feature = "v1_10")]
#[cfg_attr(docsrs, doc(cfg(feature = "v1_10")))]
use std::{boxed::Box as Box_};
glib::wrapper! {
#[doc(alias = "NMSettingOvsBridge")]
pub struct SettingOvsBridge(Object<ffi::NMSettingOvsBridge, ffi::NMSettingOvsBridgeClass>) @extends Setting;
match fn {
type_ => || ffi::nm_setting_ovs_bridge_get_type(),
}
}
impl SettingOvsBridge {
#[cfg(feature = "v1_10")]
#[cfg_attr(docsrs, doc(cfg(feature = "v1_10")))]
#[doc(alias = "nm_setting_ovs_bridge_new")]
pub fn new() -> SettingOvsBridge {
assert_initialized_main_thread!();
unsafe {
Setting::from_glib_full(ffi::nm_setting_ovs_bridge_new()).unsafe_cast()
}
}
pub fn builder() -> SettingOvsBridgeBuilder {
SettingOvsBridgeBuilder::new()
}
#[cfg(feature = "v1_42")]
#[cfg_attr(docsrs, doc(cfg(feature = "v1_42")))]
#[doc(alias = "nm_setting_ovs_bridge_get_datapath_type")]
#[doc(alias = "get_datapath_type")]
#[doc(alias = "datapath-type")]
pub fn datapath_type(&self) -> glib::GString {
unsafe {
from_glib_none(ffi::nm_setting_ovs_bridge_get_datapath_type(self.to_glib_none().0))
}
}
#[cfg(feature = "v1_10")]
#[cfg_attr(docsrs, doc(cfg(feature = "v1_10")))]
#[doc(alias = "nm_setting_ovs_bridge_get_fail_mode")]
#[doc(alias = "get_fail_mode")]
#[doc(alias = "fail-mode")]
pub fn fail_mode(&self) -> glib::GString {
unsafe {
from_glib_none(ffi::nm_setting_ovs_bridge_get_fail_mode(self.to_glib_none().0))
}
}
#[cfg(feature = "v1_10")]
#[cfg_attr(docsrs, doc(cfg(feature = "v1_10")))]
#[doc(alias = "nm_setting_ovs_bridge_get_mcast_snooping_enable")]
#[doc(alias = "get_mcast_snooping_enable")]
#[doc(alias = "mcast-snooping-enable")]
pub fn is_mcast_snooping_enable(&self) -> bool {
unsafe {
from_glib(ffi::nm_setting_ovs_bridge_get_mcast_snooping_enable(self.to_glib_none().0))
}
}
#[cfg(feature = "v1_10")]
#[cfg_attr(docsrs, doc(cfg(feature = "v1_10")))]
#[doc(alias = "nm_setting_ovs_bridge_get_rstp_enable")]
#[doc(alias = "get_rstp_enable")]
#[doc(alias = "rstp-enable")]
pub fn is_rstp_enable(&self) -> bool {
unsafe {
from_glib(ffi::nm_setting_ovs_bridge_get_rstp_enable(self.to_glib_none().0))
}
}
#[cfg(feature = "v1_10")]
#[cfg_attr(docsrs, doc(cfg(feature = "v1_10")))]
#[doc(alias = "nm_setting_ovs_bridge_get_stp_enable")]
#[doc(alias = "get_stp_enable")]
#[doc(alias = "stp-enable")]
pub fn is_stp_enable(&self) -> bool {
unsafe {
from_glib(ffi::nm_setting_ovs_bridge_get_stp_enable(self.to_glib_none().0))
}
}
#[cfg(not(feature = "v1_42"))]
#[cfg_attr(docsrs, doc(cfg(not(feature = "v1_42"))))]
#[doc(alias = "datapath-type")]
pub fn datapath_type(&self) -> Option<glib::GString> {
ObjectExt::property(self, "datapath-type")
}
#[cfg(feature = "v1_20")]
#[cfg_attr(docsrs, doc(cfg(feature = "v1_20")))]
#[doc(alias = "datapath-type")]
pub fn set_datapath_type(&self, datapath_type: Option<&str>) {
ObjectExt::set_property(self,"datapath-type", datapath_type)
}
#[cfg(feature = "v1_10")]
#[cfg_attr(docsrs, doc(cfg(feature = "v1_10")))]
#[doc(alias = "fail-mode")]
pub fn set_fail_mode(&self, fail_mode: Option<&str>) {
ObjectExt::set_property(self,"fail-mode", fail_mode)
}
#[cfg(feature = "v1_10")]
#[cfg_attr(docsrs, doc(cfg(feature = "v1_10")))]
#[doc(alias = "mcast-snooping-enable")]
pub fn set_mcast_snooping_enable(&self, mcast_snooping_enable: bool) {
ObjectExt::set_property(self,"mcast-snooping-enable", mcast_snooping_enable)
}
#[cfg(feature = "v1_10")]
#[cfg_attr(docsrs, doc(cfg(feature = "v1_10")))]
#[doc(alias = "rstp-enable")]
pub fn set_rstp_enable(&self, rstp_enable: bool) {
ObjectExt::set_property(self,"rstp-enable", rstp_enable)
}
#[cfg(feature = "v1_10")]
#[cfg_attr(docsrs, doc(cfg(feature = "v1_10")))]
#[doc(alias = "stp-enable")]
pub fn set_stp_enable(&self, stp_enable: bool) {
ObjectExt::set_property(self,"stp-enable", stp_enable)
}
#[cfg(feature = "v1_20")]
#[cfg_attr(docsrs, doc(cfg(feature = "v1_20")))]
#[doc(alias = "datapath-type")]
pub fn connect_datapath_type_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
unsafe extern "C" fn notify_datapath_type_trampoline<F: Fn(&SettingOvsBridge) + 'static>(this: *mut ffi::NMSettingOvsBridge, _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::datapath-type".as_ptr() as *const _,
Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(notify_datapath_type_trampoline::<F> as *const ())), Box_::into_raw(f))
}
}
#[cfg(feature = "v1_10")]
#[cfg_attr(docsrs, doc(cfg(feature = "v1_10")))]
#[doc(alias = "fail-mode")]
pub fn connect_fail_mode_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
unsafe extern "C" fn notify_fail_mode_trampoline<F: Fn(&SettingOvsBridge) + 'static>(this: *mut ffi::NMSettingOvsBridge, _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::fail-mode".as_ptr() as *const _,
Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(notify_fail_mode_trampoline::<F> as *const ())), Box_::into_raw(f))
}
}
#[cfg(feature = "v1_10")]
#[cfg_attr(docsrs, doc(cfg(feature = "v1_10")))]
#[doc(alias = "mcast-snooping-enable")]
pub fn connect_mcast_snooping_enable_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
unsafe extern "C" fn notify_mcast_snooping_enable_trampoline<F: Fn(&SettingOvsBridge) + 'static>(this: *mut ffi::NMSettingOvsBridge, _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::mcast-snooping-enable".as_ptr() as *const _,
Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(notify_mcast_snooping_enable_trampoline::<F> as *const ())), Box_::into_raw(f))
}
}
#[cfg(feature = "v1_10")]
#[cfg_attr(docsrs, doc(cfg(feature = "v1_10")))]
#[doc(alias = "rstp-enable")]
pub fn connect_rstp_enable_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
unsafe extern "C" fn notify_rstp_enable_trampoline<F: Fn(&SettingOvsBridge) + 'static>(this: *mut ffi::NMSettingOvsBridge, _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::rstp-enable".as_ptr() as *const _,
Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(notify_rstp_enable_trampoline::<F> as *const ())), Box_::into_raw(f))
}
}
#[cfg(feature = "v1_10")]
#[cfg_attr(docsrs, doc(cfg(feature = "v1_10")))]
#[doc(alias = "stp-enable")]
pub fn connect_stp_enable_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
unsafe extern "C" fn notify_stp_enable_trampoline<F: Fn(&SettingOvsBridge) + 'static>(this: *mut ffi::NMSettingOvsBridge, _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::stp-enable".as_ptr() as *const _,
Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(notify_stp_enable_trampoline::<F> as *const ())), Box_::into_raw(f))
}
}
}
#[cfg(feature = "v1_10")]
#[cfg_attr(docsrs, doc(cfg(feature = "v1_10")))]
impl Default for SettingOvsBridge {
fn default() -> Self {
Self::new()
}
}
#[must_use = "The builder must be built to be used"]
pub struct SettingOvsBridgeBuilder {
builder: glib::object::ObjectBuilder<'static, SettingOvsBridge>,
}
impl SettingOvsBridgeBuilder {
fn new() -> Self {
Self { builder: glib::object::Object::builder() }
}
#[cfg(feature = "v1_20")]
#[cfg_attr(docsrs, doc(cfg(feature = "v1_20")))]
pub fn datapath_type(self, datapath_type: impl Into<glib::GString>) -> Self {
Self { builder: self.builder.property("datapath-type", datapath_type.into()), }
}
#[cfg(feature = "v1_10")]
#[cfg_attr(docsrs, doc(cfg(feature = "v1_10")))]
pub fn fail_mode(self, fail_mode: impl Into<glib::GString>) -> Self {
Self { builder: self.builder.property("fail-mode", fail_mode.into()), }
}
#[cfg(feature = "v1_10")]
#[cfg_attr(docsrs, doc(cfg(feature = "v1_10")))]
pub fn mcast_snooping_enable(self, mcast_snooping_enable: bool) -> Self {
Self { builder: self.builder.property("mcast-snooping-enable", mcast_snooping_enable), }
}
#[cfg(feature = "v1_10")]
#[cfg_attr(docsrs, doc(cfg(feature = "v1_10")))]
pub fn rstp_enable(self, rstp_enable: bool) -> Self {
Self { builder: self.builder.property("rstp-enable", rstp_enable), }
}
#[cfg(feature = "v1_10")]
#[cfg_attr(docsrs, doc(cfg(feature = "v1_10")))]
pub fn stp_enable(self, stp_enable: bool) -> Self {
Self { builder: self.builder.property("stp-enable", stp_enable), }
}
#[must_use = "Building the object from the builder is usually expensive and is not expected to have side effects"]
pub fn build(self) -> SettingOvsBridge {
assert_initialized_main_thread!();
self.builder.build() }
}