use crate::{ffi,Setting};
#[cfg(feature = "v1_2")]
#[cfg_attr(docsrs, doc(cfg(feature = "v1_2")))]
use crate::{SettingTunMode};
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 = "NMSettingTun")]
pub struct SettingTun(Object<ffi::NMSettingTun, ffi::NMSettingTunClass>) @extends Setting;
match fn {
type_ => || ffi::nm_setting_tun_get_type(),
}
}
impl SettingTun {
#[cfg(feature = "v1_2")]
#[cfg_attr(docsrs, doc(cfg(feature = "v1_2")))]
#[doc(alias = "nm_setting_tun_new")]
pub fn new() -> SettingTun {
assert_initialized_main_thread!();
unsafe {
Setting::from_glib_full(ffi::nm_setting_tun_new()).unsafe_cast()
}
}
pub fn builder() -> SettingTunBuilder {
SettingTunBuilder::new()
}
#[cfg(feature = "v1_2")]
#[cfg_attr(docsrs, doc(cfg(feature = "v1_2")))]
#[doc(alias = "nm_setting_tun_get_group")]
#[doc(alias = "get_group")]
pub fn group(&self) -> glib::GString {
unsafe {
from_glib_none(ffi::nm_setting_tun_get_group(self.to_glib_none().0))
}
}
#[cfg(feature = "v1_2")]
#[cfg_attr(docsrs, doc(cfg(feature = "v1_2")))]
#[doc(alias = "nm_setting_tun_get_mode")]
#[doc(alias = "get_mode")]
pub fn mode(&self) -> SettingTunMode {
unsafe {
from_glib(ffi::nm_setting_tun_get_mode(self.to_glib_none().0))
}
}
#[cfg(feature = "v1_2")]
#[cfg_attr(docsrs, doc(cfg(feature = "v1_2")))]
#[doc(alias = "nm_setting_tun_get_multi_queue")]
#[doc(alias = "get_multi_queue")]
#[doc(alias = "multi-queue")]
pub fn is_multi_queue(&self) -> bool {
unsafe {
from_glib(ffi::nm_setting_tun_get_multi_queue(self.to_glib_none().0))
}
}
#[cfg(feature = "v1_2")]
#[cfg_attr(docsrs, doc(cfg(feature = "v1_2")))]
#[doc(alias = "nm_setting_tun_get_owner")]
#[doc(alias = "get_owner")]
pub fn owner(&self) -> glib::GString {
unsafe {
from_glib_none(ffi::nm_setting_tun_get_owner(self.to_glib_none().0))
}
}
#[cfg(feature = "v1_2")]
#[cfg_attr(docsrs, doc(cfg(feature = "v1_2")))]
#[doc(alias = "nm_setting_tun_get_pi")]
#[doc(alias = "get_pi")]
#[doc(alias = "pi")]
pub fn is_pi(&self) -> bool {
unsafe {
from_glib(ffi::nm_setting_tun_get_pi(self.to_glib_none().0))
}
}
#[cfg(feature = "v1_2")]
#[cfg_attr(docsrs, doc(cfg(feature = "v1_2")))]
#[doc(alias = "nm_setting_tun_get_vnet_hdr")]
#[doc(alias = "get_vnet_hdr")]
#[doc(alias = "vnet-hdr")]
pub fn is_vnet_hdr(&self) -> bool {
unsafe {
from_glib(ffi::nm_setting_tun_get_vnet_hdr(self.to_glib_none().0))
}
}
#[cfg(feature = "v1_2")]
#[cfg_attr(docsrs, doc(cfg(feature = "v1_2")))]
pub fn set_group(&self, group: Option<&str>) {
ObjectExt::set_property(self,"group", group)
}
#[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")))]
#[doc(alias = "multi-queue")]
pub fn set_multi_queue(&self, multi_queue: bool) {
ObjectExt::set_property(self,"multi-queue", multi_queue)
}
#[cfg(feature = "v1_2")]
#[cfg_attr(docsrs, doc(cfg(feature = "v1_2")))]
pub fn set_owner(&self, owner: Option<&str>) {
ObjectExt::set_property(self,"owner", owner)
}
#[cfg(feature = "v1_2")]
#[cfg_attr(docsrs, doc(cfg(feature = "v1_2")))]
pub fn set_pi(&self, pi: bool) {
ObjectExt::set_property(self,"pi", pi)
}
#[cfg(feature = "v1_2")]
#[cfg_attr(docsrs, doc(cfg(feature = "v1_2")))]
#[doc(alias = "vnet-hdr")]
pub fn set_vnet_hdr(&self, vnet_hdr: bool) {
ObjectExt::set_property(self,"vnet-hdr", vnet_hdr)
}
#[cfg(feature = "v1_2")]
#[cfg_attr(docsrs, doc(cfg(feature = "v1_2")))]
#[doc(alias = "group")]
pub fn connect_group_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
unsafe extern "C" fn notify_group_trampoline<F: Fn(&SettingTun) + 'static>(this: *mut ffi::NMSettingTun, _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::group".as_ptr() as *const _,
Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(notify_group_trampoline::<F> as *const ())), Box_::into_raw(f))
}
}
#[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(&SettingTun) + 'static>(this: *mut ffi::NMSettingTun, _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 = "multi-queue")]
pub fn connect_multi_queue_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
unsafe extern "C" fn notify_multi_queue_trampoline<F: Fn(&SettingTun) + 'static>(this: *mut ffi::NMSettingTun, _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::multi-queue".as_ptr() as *const _,
Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(notify_multi_queue_trampoline::<F> as *const ())), Box_::into_raw(f))
}
}
#[cfg(feature = "v1_2")]
#[cfg_attr(docsrs, doc(cfg(feature = "v1_2")))]
#[doc(alias = "owner")]
pub fn connect_owner_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
unsafe extern "C" fn notify_owner_trampoline<F: Fn(&SettingTun) + 'static>(this: *mut ffi::NMSettingTun, _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::owner".as_ptr() as *const _,
Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(notify_owner_trampoline::<F> as *const ())), Box_::into_raw(f))
}
}
#[cfg(feature = "v1_2")]
#[cfg_attr(docsrs, doc(cfg(feature = "v1_2")))]
#[doc(alias = "pi")]
pub fn connect_pi_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
unsafe extern "C" fn notify_pi_trampoline<F: Fn(&SettingTun) + 'static>(this: *mut ffi::NMSettingTun, _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::pi".as_ptr() as *const _,
Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(notify_pi_trampoline::<F> as *const ())), Box_::into_raw(f))
}
}
#[cfg(feature = "v1_2")]
#[cfg_attr(docsrs, doc(cfg(feature = "v1_2")))]
#[doc(alias = "vnet-hdr")]
pub fn connect_vnet_hdr_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
unsafe extern "C" fn notify_vnet_hdr_trampoline<F: Fn(&SettingTun) + 'static>(this: *mut ffi::NMSettingTun, _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::vnet-hdr".as_ptr() as *const _,
Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(notify_vnet_hdr_trampoline::<F> as *const ())), Box_::into_raw(f))
}
}
}
#[cfg(feature = "v1_2")]
#[cfg_attr(docsrs, doc(cfg(feature = "v1_2")))]
impl Default for SettingTun {
fn default() -> Self {
Self::new()
}
}
#[must_use = "The builder must be built to be used"]
pub struct SettingTunBuilder {
builder: glib::object::ObjectBuilder<'static, SettingTun>,
}
impl SettingTunBuilder {
fn new() -> Self {
Self { builder: glib::object::Object::builder() }
}
#[cfg(feature = "v1_2")]
#[cfg_attr(docsrs, doc(cfg(feature = "v1_2")))]
pub fn group(self, group: impl Into<glib::GString>) -> Self {
Self { builder: self.builder.property("group", group.into()), }
}
#[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 multi_queue(self, multi_queue: bool) -> Self {
Self { builder: self.builder.property("multi-queue", multi_queue), }
}
#[cfg(feature = "v1_2")]
#[cfg_attr(docsrs, doc(cfg(feature = "v1_2")))]
pub fn owner(self, owner: impl Into<glib::GString>) -> Self {
Self { builder: self.builder.property("owner", owner.into()), }
}
#[cfg(feature = "v1_2")]
#[cfg_attr(docsrs, doc(cfg(feature = "v1_2")))]
pub fn pi(self, pi: bool) -> Self {
Self { builder: self.builder.property("pi", pi), }
}
#[cfg(feature = "v1_2")]
#[cfg_attr(docsrs, doc(cfg(feature = "v1_2")))]
pub fn vnet_hdr(self, vnet_hdr: bool) -> Self {
Self { builder: self.builder.property("vnet-hdr", vnet_hdr), }
}
#[must_use = "Building the object from the builder is usually expensive and is not expected to have side effects"]
pub fn build(self) -> SettingTun {
assert_initialized_main_thread!();
self.builder.build() }
}