#[cfg(feature = "v1_42")]
#[cfg_attr(docsrs, doc(cfg(feature = "v1_42")))]
use crate::Range;
use crate::{Setting, ffi};
use glib::prelude::*;
#[cfg(feature = "v1_10")]
#[cfg_attr(docsrs, doc(cfg(feature = "v1_10")))]
use glib::{
signal::{SignalHandlerId, connect_raw},
translate::*,
};
#[cfg(feature = "v1_10")]
#[cfg_attr(docsrs, doc(cfg(feature = "v1_10")))]
use std::boxed::Box as Box_;
glib::wrapper! {
#[doc(alias = "NMSettingOvsPort")]
pub struct SettingOvsPort(Object<ffi::NMSettingOvsPort, ffi::NMSettingOvsPortClass>) @extends Setting;
match fn {
type_ => || ffi::nm_setting_ovs_port_get_type(),
}
}
impl SettingOvsPort {
#[cfg(feature = "v1_10")]
#[cfg_attr(docsrs, doc(cfg(feature = "v1_10")))]
#[doc(alias = "nm_setting_ovs_port_new")]
pub fn new() -> SettingOvsPort {
assert_initialized_main_thread!();
unsafe { Setting::from_glib_full(ffi::nm_setting_ovs_port_new()).unsafe_cast() }
}
pub fn builder() -> SettingOvsPortBuilder {
SettingOvsPortBuilder::new()
}
#[cfg(feature = "v1_42")]
#[cfg_attr(docsrs, doc(cfg(feature = "v1_42")))]
#[doc(alias = "nm_setting_ovs_port_add_trunk")]
pub fn add_trunk(&self, trunk: &Range) {
unsafe {
ffi::nm_setting_ovs_port_add_trunk(self.to_glib_none().0, trunk.to_glib_none().0);
}
}
#[cfg(feature = "v1_42")]
#[cfg_attr(docsrs, doc(cfg(feature = "v1_42")))]
#[doc(alias = "nm_setting_ovs_port_clear_trunks")]
pub fn clear_trunks(&self) {
unsafe {
ffi::nm_setting_ovs_port_clear_trunks(self.to_glib_none().0);
}
}
#[cfg(feature = "v1_10")]
#[cfg_attr(docsrs, doc(cfg(feature = "v1_10")))]
#[doc(alias = "nm_setting_ovs_port_get_bond_downdelay")]
#[doc(alias = "get_bond_downdelay")]
#[doc(alias = "bond-downdelay")]
pub fn bond_downdelay(&self) -> u32 {
unsafe { ffi::nm_setting_ovs_port_get_bond_downdelay(self.to_glib_none().0) }
}
#[cfg(feature = "v1_10")]
#[cfg_attr(docsrs, doc(cfg(feature = "v1_10")))]
#[doc(alias = "nm_setting_ovs_port_get_bond_mode")]
#[doc(alias = "get_bond_mode")]
#[doc(alias = "bond-mode")]
pub fn bond_mode(&self) -> glib::GString {
unsafe {
from_glib_none(ffi::nm_setting_ovs_port_get_bond_mode(
self.to_glib_none().0,
))
}
}
#[cfg(feature = "v1_10")]
#[cfg_attr(docsrs, doc(cfg(feature = "v1_10")))]
#[doc(alias = "nm_setting_ovs_port_get_bond_updelay")]
#[doc(alias = "get_bond_updelay")]
#[doc(alias = "bond-updelay")]
pub fn bond_updelay(&self) -> u32 {
unsafe { ffi::nm_setting_ovs_port_get_bond_updelay(self.to_glib_none().0) }
}
#[cfg(feature = "v1_10")]
#[cfg_attr(docsrs, doc(cfg(feature = "v1_10")))]
#[doc(alias = "nm_setting_ovs_port_get_lacp")]
#[doc(alias = "get_lacp")]
pub fn lacp(&self) -> glib::GString {
unsafe { from_glib_none(ffi::nm_setting_ovs_port_get_lacp(self.to_glib_none().0)) }
}
#[cfg(feature = "v1_42")]
#[cfg_attr(docsrs, doc(cfg(feature = "v1_42")))]
#[doc(alias = "nm_setting_ovs_port_get_num_trunks")]
#[doc(alias = "get_num_trunks")]
pub fn num_trunks(&self) -> u32 {
unsafe { ffi::nm_setting_ovs_port_get_num_trunks(self.to_glib_none().0) }
}
#[cfg(feature = "v1_10")]
#[cfg_attr(docsrs, doc(cfg(feature = "v1_10")))]
#[doc(alias = "nm_setting_ovs_port_get_tag")]
#[doc(alias = "get_tag")]
pub fn tag(&self) -> u32 {
unsafe { ffi::nm_setting_ovs_port_get_tag(self.to_glib_none().0) }
}
#[cfg(feature = "v1_42")]
#[cfg_attr(docsrs, doc(cfg(feature = "v1_42")))]
#[doc(alias = "nm_setting_ovs_port_get_trunk")]
#[doc(alias = "get_trunk")]
pub fn trunk(&self, idx: u32) -> Range {
unsafe {
from_glib_none(ffi::nm_setting_ovs_port_get_trunk(
self.to_glib_none().0,
idx,
))
}
}
#[cfg(feature = "v1_10")]
#[cfg_attr(docsrs, doc(cfg(feature = "v1_10")))]
#[doc(alias = "nm_setting_ovs_port_get_vlan_mode")]
#[doc(alias = "get_vlan_mode")]
#[doc(alias = "vlan-mode")]
pub fn vlan_mode(&self) -> glib::GString {
unsafe {
from_glib_none(ffi::nm_setting_ovs_port_get_vlan_mode(
self.to_glib_none().0,
))
}
}
#[cfg(feature = "v1_42")]
#[cfg_attr(docsrs, doc(cfg(feature = "v1_42")))]
#[doc(alias = "nm_setting_ovs_port_remove_trunk")]
pub fn remove_trunk(&self, idx: u32) {
unsafe {
ffi::nm_setting_ovs_port_remove_trunk(self.to_glib_none().0, idx);
}
}
#[cfg(feature = "v1_42")]
#[cfg_attr(docsrs, doc(cfg(feature = "v1_42")))]
#[doc(alias = "nm_setting_ovs_port_remove_trunk_by_value")]
pub fn remove_trunk_by_value(&self, start: u32, end: u32) -> bool {
unsafe {
from_glib(ffi::nm_setting_ovs_port_remove_trunk_by_value(
self.to_glib_none().0,
start,
end,
))
}
}
#[cfg(feature = "v1_10")]
#[cfg_attr(docsrs, doc(cfg(feature = "v1_10")))]
#[doc(alias = "bond-downdelay")]
pub fn set_bond_downdelay(&self, bond_downdelay: u32) {
ObjectExt::set_property(self, "bond-downdelay", bond_downdelay)
}
#[cfg(feature = "v1_10")]
#[cfg_attr(docsrs, doc(cfg(feature = "v1_10")))]
#[doc(alias = "bond-mode")]
pub fn set_bond_mode(&self, bond_mode: Option<&str>) {
ObjectExt::set_property(self, "bond-mode", bond_mode)
}
#[cfg(feature = "v1_10")]
#[cfg_attr(docsrs, doc(cfg(feature = "v1_10")))]
#[doc(alias = "bond-updelay")]
pub fn set_bond_updelay(&self, bond_updelay: u32) {
ObjectExt::set_property(self, "bond-updelay", bond_updelay)
}
#[cfg(feature = "v1_10")]
#[cfg_attr(docsrs, doc(cfg(feature = "v1_10")))]
pub fn set_lacp(&self, lacp: Option<&str>) {
ObjectExt::set_property(self, "lacp", lacp)
}
#[cfg(feature = "v1_10")]
#[cfg_attr(docsrs, doc(cfg(feature = "v1_10")))]
pub fn set_tag(&self, tag: u32) {
ObjectExt::set_property(self, "tag", tag)
}
#[cfg(feature = "v1_42")]
#[cfg_attr(docsrs, doc(cfg(feature = "v1_42")))]
pub fn trunks(&self) -> Vec<Range> {
let vals = ObjectExt::property::<glib::ValueArray>(self, "trunks");
vals.iter()
.map(|value| {
use glib::value::FromValue;
unsafe { Range::from_value(value) }
})
.collect()
}
#[cfg(feature = "v1_42")]
#[cfg_attr(docsrs, doc(cfg(feature = "v1_42")))]
pub fn set_trunks(&self, trunks: &[&Range]) {
ObjectExt::set_property(
self,
"trunks",
trunks
.iter()
.map(|trunk| trunk.to_value())
.collect::<glib::ValueArray>(),
)
}
#[cfg(feature = "v1_10")]
#[cfg_attr(docsrs, doc(cfg(feature = "v1_10")))]
#[doc(alias = "vlan-mode")]
pub fn set_vlan_mode(&self, vlan_mode: Option<&str>) {
ObjectExt::set_property(self, "vlan-mode", vlan_mode)
}
#[cfg(feature = "v1_10")]
#[cfg_attr(docsrs, doc(cfg(feature = "v1_10")))]
#[doc(alias = "bond-downdelay")]
pub fn connect_bond_downdelay_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
unsafe extern "C" fn notify_bond_downdelay_trampoline<F: Fn(&SettingOvsPort) + 'static>(
this: *mut ffi::NMSettingOvsPort,
_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::bond-downdelay".as_ptr() as *const _,
Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
notify_bond_downdelay_trampoline::<F> as *const (),
)),
Box_::into_raw(f),
)
}
}
#[cfg(feature = "v1_10")]
#[cfg_attr(docsrs, doc(cfg(feature = "v1_10")))]
#[doc(alias = "bond-mode")]
pub fn connect_bond_mode_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
unsafe extern "C" fn notify_bond_mode_trampoline<F: Fn(&SettingOvsPort) + 'static>(
this: *mut ffi::NMSettingOvsPort,
_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::bond-mode".as_ptr() as *const _,
Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
notify_bond_mode_trampoline::<F> as *const (),
)),
Box_::into_raw(f),
)
}
}
#[cfg(feature = "v1_10")]
#[cfg_attr(docsrs, doc(cfg(feature = "v1_10")))]
#[doc(alias = "bond-updelay")]
pub fn connect_bond_updelay_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
unsafe extern "C" fn notify_bond_updelay_trampoline<F: Fn(&SettingOvsPort) + 'static>(
this: *mut ffi::NMSettingOvsPort,
_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::bond-updelay".as_ptr() as *const _,
Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
notify_bond_updelay_trampoline::<F> as *const (),
)),
Box_::into_raw(f),
)
}
}
#[cfg(feature = "v1_10")]
#[cfg_attr(docsrs, doc(cfg(feature = "v1_10")))]
#[doc(alias = "lacp")]
pub fn connect_lacp_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
unsafe extern "C" fn notify_lacp_trampoline<F: Fn(&SettingOvsPort) + 'static>(
this: *mut ffi::NMSettingOvsPort,
_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::lacp".as_ptr() as *const _,
Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
notify_lacp_trampoline::<F> as *const (),
)),
Box_::into_raw(f),
)
}
}
#[cfg(feature = "v1_10")]
#[cfg_attr(docsrs, doc(cfg(feature = "v1_10")))]
#[doc(alias = "tag")]
pub fn connect_tag_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
unsafe extern "C" fn notify_tag_trampoline<F: Fn(&SettingOvsPort) + 'static>(
this: *mut ffi::NMSettingOvsPort,
_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::tag".as_ptr() as *const _,
Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
notify_tag_trampoline::<F> as *const (),
)),
Box_::into_raw(f),
)
}
}
#[cfg(feature = "v1_42")]
#[cfg_attr(docsrs, doc(cfg(feature = "v1_42")))]
#[doc(alias = "trunks")]
pub fn connect_trunks_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
unsafe extern "C" fn notify_trunks_trampoline<F: Fn(&SettingOvsPort) + 'static>(
this: *mut ffi::NMSettingOvsPort,
_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::trunks".as_ptr() as *const _,
Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
notify_trunks_trampoline::<F> as *const (),
)),
Box_::into_raw(f),
)
}
}
#[cfg(feature = "v1_10")]
#[cfg_attr(docsrs, doc(cfg(feature = "v1_10")))]
#[doc(alias = "vlan-mode")]
pub fn connect_vlan_mode_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
unsafe extern "C" fn notify_vlan_mode_trampoline<F: Fn(&SettingOvsPort) + 'static>(
this: *mut ffi::NMSettingOvsPort,
_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::vlan-mode".as_ptr() as *const _,
Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
notify_vlan_mode_trampoline::<F> as *const (),
)),
Box_::into_raw(f),
)
}
}
}
#[cfg(feature = "v1_10")]
#[cfg_attr(docsrs, doc(cfg(feature = "v1_10")))]
impl Default for SettingOvsPort {
fn default() -> Self {
Self::new()
}
}
#[must_use = "The builder must be built to be used"]
pub struct SettingOvsPortBuilder {
builder: glib::object::ObjectBuilder<'static, SettingOvsPort>,
}
impl SettingOvsPortBuilder {
fn new() -> Self {
Self {
builder: glib::object::Object::builder(),
}
}
#[cfg(feature = "v1_10")]
#[cfg_attr(docsrs, doc(cfg(feature = "v1_10")))]
pub fn bond_downdelay(self, bond_downdelay: u32) -> Self {
Self {
builder: self.builder.property("bond-downdelay", bond_downdelay),
}
}
#[cfg(feature = "v1_10")]
#[cfg_attr(docsrs, doc(cfg(feature = "v1_10")))]
pub fn bond_mode(self, bond_mode: impl Into<glib::GString>) -> Self {
Self {
builder: self.builder.property("bond-mode", bond_mode.into()),
}
}
#[cfg(feature = "v1_10")]
#[cfg_attr(docsrs, doc(cfg(feature = "v1_10")))]
pub fn bond_updelay(self, bond_updelay: u32) -> Self {
Self {
builder: self.builder.property("bond-updelay", bond_updelay),
}
}
#[cfg(feature = "v1_10")]
#[cfg_attr(docsrs, doc(cfg(feature = "v1_10")))]
pub fn lacp(self, lacp: impl Into<glib::GString>) -> Self {
Self {
builder: self.builder.property("lacp", lacp.into()),
}
}
#[cfg(feature = "v1_10")]
#[cfg_attr(docsrs, doc(cfg(feature = "v1_10")))]
pub fn tag(self, tag: u32) -> Self {
Self {
builder: self.builder.property("tag", tag),
}
}
#[cfg(feature = "v1_42")]
#[cfg_attr(docsrs, doc(cfg(feature = "v1_42")))]
pub fn trunks(self, trunks: &[&Range]) -> Self {
Self {
builder: self.builder.property(
"trunks",
trunks
.iter()
.map(|trunk| trunk.to_value())
.collect::<glib::ValueArray>(),
),
}
}
#[cfg(feature = "v1_10")]
#[cfg_attr(docsrs, doc(cfg(feature = "v1_10")))]
pub fn vlan_mode(self, vlan_mode: impl Into<glib::GString>) -> Self {
Self {
builder: self.builder.property("vlan-mode", vlan_mode.into()),
}
}
#[must_use = "Building the object from the builder is usually expensive and is not expected to have side effects"]
pub fn build(self) -> SettingOvsPort {
assert_initialized_main_thread!();
self.builder.build()
}
}