nm_rs/auto/
setting_loopback.rs1use crate::{ffi,Setting};
7use glib::{prelude::*,signal::{connect_raw, SignalHandlerId},translate::*};
8use std::{boxed::Box as Box_};
9
10glib::wrapper! {
11 #[doc(alias = "NMSettingLoopback")]
36 pub struct SettingLoopback(Object<ffi::NMSettingLoopback, ffi::NMSettingLoopbackClass>) @extends Setting;
37
38 match fn {
39 type_ => || ffi::nm_setting_loopback_get_type(),
40 }
41}
42
43impl SettingLoopback {
44 #[doc(alias = "nm_setting_loopback_new")]
50 pub fn new() -> SettingLoopback {
51 assert_initialized_main_thread!();
52 unsafe {
53 Setting::from_glib_full(ffi::nm_setting_loopback_new()).unsafe_cast()
54 }
55 }
56
57 pub fn builder() -> SettingLoopbackBuilder {
62 SettingLoopbackBuilder::new()
63 }
64
65
66 #[doc(alias = "nm_setting_loopback_get_mtu")]
71 #[doc(alias = "get_mtu")]
72 pub fn mtu(&self) -> u32 {
73 unsafe {
74 ffi::nm_setting_loopback_get_mtu(self.to_glib_none().0)
75 }
76 }
77
78 #[cfg(feature = "v1_42")]
81 #[cfg_attr(docsrs, doc(cfg(feature = "v1_42")))]
82 pub fn set_mtu(&self, mtu: u32) {
83 ObjectExt::set_property(self,"mtu", mtu)
84 }
85
86 #[cfg(feature = "v1_42")]
87 #[cfg_attr(docsrs, doc(cfg(feature = "v1_42")))]
88 #[doc(alias = "mtu")]
89 pub fn connect_mtu_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
90 unsafe extern "C" fn notify_mtu_trampoline<F: Fn(&SettingLoopback) + 'static>(this: *mut ffi::NMSettingLoopback, _param_spec: glib::ffi::gpointer, f: glib::ffi::gpointer) {
91 let f: &F = &*(f as *const F);
92 f(&from_glib_borrow(this))
93 }
94 unsafe {
95 let f: Box_<F> = Box_::new(f);
96 connect_raw(self.as_ptr() as *mut _, c"notify::mtu".as_ptr() as *const _,
97 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(notify_mtu_trampoline::<F> as *const ())), Box_::into_raw(f))
98 }
99 }
100}
101
102#[cfg(feature = "v1_42")]
103#[cfg_attr(docsrs, doc(cfg(feature = "v1_42")))]
104impl Default for SettingLoopback {
105 fn default() -> Self {
106 Self::new()
107 }
108 }
109
110#[must_use = "The builder must be built to be used"]
115pub struct SettingLoopbackBuilder {
116 builder: glib::object::ObjectBuilder<'static, SettingLoopback>,
117 }
118
119 impl SettingLoopbackBuilder {
120 fn new() -> Self {
121 Self { builder: glib::object::Object::builder() }
122 }
123
124 #[cfg(feature = "v1_42")]
127 #[cfg_attr(docsrs, doc(cfg(feature = "v1_42")))]
128 pub fn mtu(self, mtu: u32) -> Self {
129 Self { builder: self.builder.property("mtu", mtu), }
130 }
131
132 #[must_use = "Building the object from the builder is usually expensive and is not expected to have side effects"]
135 pub fn build(self) -> SettingLoopback {
136assert_initialized_main_thread!();
137 self.builder.build() }
138}