1use crate::{ffi,Setting};
7#[cfg(feature = "v1_2")]
8#[cfg_attr(docsrs, doc(cfg(feature = "v1_2")))]
9use crate::{SettingTunMode};
10use glib::{prelude::*};
11#[cfg(feature = "v1_2")]
12#[cfg_attr(docsrs, doc(cfg(feature = "v1_2")))]
13use glib::{signal::{connect_raw, SignalHandlerId},translate::*};
14#[cfg(feature = "v1_2")]
15#[cfg_attr(docsrs, doc(cfg(feature = "v1_2")))]
16use std::{boxed::Box as Box_};
17
18glib::wrapper! {
19 #[doc(alias = "NMSettingTun")]
83 pub struct SettingTun(Object<ffi::NMSettingTun, ffi::NMSettingTunClass>) @extends Setting;
84
85 match fn {
86 type_ => || ffi::nm_setting_tun_get_type(),
87 }
88}
89
90impl SettingTun {
91 #[cfg(feature = "v1_2")]
97 #[cfg_attr(docsrs, doc(cfg(feature = "v1_2")))]
98 #[doc(alias = "nm_setting_tun_new")]
99 pub fn new() -> SettingTun {
100 assert_initialized_main_thread!();
101 unsafe {
102 Setting::from_glib_full(ffi::nm_setting_tun_new()).unsafe_cast()
103 }
104 }
105
106 pub fn builder() -> SettingTunBuilder {
111 SettingTunBuilder::new()
112 }
113
114
115 #[cfg(feature = "v1_2")]
120 #[cfg_attr(docsrs, doc(cfg(feature = "v1_2")))]
121 #[doc(alias = "nm_setting_tun_get_group")]
122 #[doc(alias = "get_group")]
123 pub fn group(&self) -> glib::GString {
124 unsafe {
125 from_glib_none(ffi::nm_setting_tun_get_group(self.to_glib_none().0))
126 }
127 }
128
129 #[cfg(feature = "v1_2")]
134 #[cfg_attr(docsrs, doc(cfg(feature = "v1_2")))]
135 #[doc(alias = "nm_setting_tun_get_mode")]
136 #[doc(alias = "get_mode")]
137 pub fn mode(&self) -> SettingTunMode {
138 unsafe {
139 from_glib(ffi::nm_setting_tun_get_mode(self.to_glib_none().0))
140 }
141 }
142
143 #[cfg(feature = "v1_2")]
148 #[cfg_attr(docsrs, doc(cfg(feature = "v1_2")))]
149 #[doc(alias = "nm_setting_tun_get_multi_queue")]
150 #[doc(alias = "get_multi_queue")]
151 #[doc(alias = "multi-queue")]
152 pub fn is_multi_queue(&self) -> bool {
153 unsafe {
154 from_glib(ffi::nm_setting_tun_get_multi_queue(self.to_glib_none().0))
155 }
156 }
157
158 #[cfg(feature = "v1_2")]
163 #[cfg_attr(docsrs, doc(cfg(feature = "v1_2")))]
164 #[doc(alias = "nm_setting_tun_get_owner")]
165 #[doc(alias = "get_owner")]
166 pub fn owner(&self) -> glib::GString {
167 unsafe {
168 from_glib_none(ffi::nm_setting_tun_get_owner(self.to_glib_none().0))
169 }
170 }
171
172 #[cfg(feature = "v1_2")]
177 #[cfg_attr(docsrs, doc(cfg(feature = "v1_2")))]
178 #[doc(alias = "nm_setting_tun_get_pi")]
179 #[doc(alias = "get_pi")]
180 #[doc(alias = "pi")]
181 pub fn is_pi(&self) -> bool {
182 unsafe {
183 from_glib(ffi::nm_setting_tun_get_pi(self.to_glib_none().0))
184 }
185 }
186
187 #[cfg(feature = "v1_2")]
192 #[cfg_attr(docsrs, doc(cfg(feature = "v1_2")))]
193 #[doc(alias = "nm_setting_tun_get_vnet_hdr")]
194 #[doc(alias = "get_vnet_hdr")]
195 #[doc(alias = "vnet-hdr")]
196 pub fn is_vnet_hdr(&self) -> bool {
197 unsafe {
198 from_glib(ffi::nm_setting_tun_get_vnet_hdr(self.to_glib_none().0))
199 }
200 }
201
202 #[cfg(feature = "v1_2")]
205 #[cfg_attr(docsrs, doc(cfg(feature = "v1_2")))]
206 pub fn set_group(&self, group: Option<&str>) {
207 ObjectExt::set_property(self,"group", group)
208 }
209
210 #[cfg(feature = "v1_2")]
215 #[cfg_attr(docsrs, doc(cfg(feature = "v1_2")))]
216 pub fn set_mode(&self, mode: u32) {
217 ObjectExt::set_property(self,"mode", mode)
218 }
219
220 #[cfg(feature = "v1_2")]
225 #[cfg_attr(docsrs, doc(cfg(feature = "v1_2")))]
226 #[doc(alias = "multi-queue")]
227 pub fn set_multi_queue(&self, multi_queue: bool) {
228 ObjectExt::set_property(self,"multi-queue", multi_queue)
229 }
230
231 #[cfg(feature = "v1_2")]
234 #[cfg_attr(docsrs, doc(cfg(feature = "v1_2")))]
235 pub fn set_owner(&self, owner: Option<&str>) {
236 ObjectExt::set_property(self,"owner", owner)
237 }
238
239 #[cfg(feature = "v1_2")]
242 #[cfg_attr(docsrs, doc(cfg(feature = "v1_2")))]
243 pub fn set_pi(&self, pi: bool) {
244 ObjectExt::set_property(self,"pi", pi)
245 }
246
247 #[cfg(feature = "v1_2")]
250 #[cfg_attr(docsrs, doc(cfg(feature = "v1_2")))]
251 #[doc(alias = "vnet-hdr")]
252 pub fn set_vnet_hdr(&self, vnet_hdr: bool) {
253 ObjectExt::set_property(self,"vnet-hdr", vnet_hdr)
254 }
255
256 #[cfg(feature = "v1_2")]
257 #[cfg_attr(docsrs, doc(cfg(feature = "v1_2")))]
258 #[doc(alias = "group")]
259 pub fn connect_group_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
260 unsafe extern "C" fn notify_group_trampoline<F: Fn(&SettingTun) + 'static>(this: *mut ffi::NMSettingTun, _param_spec: glib::ffi::gpointer, f: glib::ffi::gpointer) {
261 let f: &F = &*(f as *const F);
262 f(&from_glib_borrow(this))
263 }
264 unsafe {
265 let f: Box_<F> = Box_::new(f);
266 connect_raw(self.as_ptr() as *mut _, c"notify::group".as_ptr() as *const _,
267 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(notify_group_trampoline::<F> as *const ())), Box_::into_raw(f))
268 }
269 }
270
271 #[cfg(feature = "v1_2")]
272 #[cfg_attr(docsrs, doc(cfg(feature = "v1_2")))]
273 #[doc(alias = "mode")]
274 pub fn connect_mode_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
275 unsafe extern "C" fn notify_mode_trampoline<F: Fn(&SettingTun) + 'static>(this: *mut ffi::NMSettingTun, _param_spec: glib::ffi::gpointer, f: glib::ffi::gpointer) {
276 let f: &F = &*(f as *const F);
277 f(&from_glib_borrow(this))
278 }
279 unsafe {
280 let f: Box_<F> = Box_::new(f);
281 connect_raw(self.as_ptr() as *mut _, c"notify::mode".as_ptr() as *const _,
282 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(notify_mode_trampoline::<F> as *const ())), Box_::into_raw(f))
283 }
284 }
285
286 #[cfg(feature = "v1_2")]
287 #[cfg_attr(docsrs, doc(cfg(feature = "v1_2")))]
288 #[doc(alias = "multi-queue")]
289 pub fn connect_multi_queue_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
290 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) {
291 let f: &F = &*(f as *const F);
292 f(&from_glib_borrow(this))
293 }
294 unsafe {
295 let f: Box_<F> = Box_::new(f);
296 connect_raw(self.as_ptr() as *mut _, c"notify::multi-queue".as_ptr() as *const _,
297 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(notify_multi_queue_trampoline::<F> as *const ())), Box_::into_raw(f))
298 }
299 }
300
301 #[cfg(feature = "v1_2")]
302 #[cfg_attr(docsrs, doc(cfg(feature = "v1_2")))]
303 #[doc(alias = "owner")]
304 pub fn connect_owner_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
305 unsafe extern "C" fn notify_owner_trampoline<F: Fn(&SettingTun) + 'static>(this: *mut ffi::NMSettingTun, _param_spec: glib::ffi::gpointer, f: glib::ffi::gpointer) {
306 let f: &F = &*(f as *const F);
307 f(&from_glib_borrow(this))
308 }
309 unsafe {
310 let f: Box_<F> = Box_::new(f);
311 connect_raw(self.as_ptr() as *mut _, c"notify::owner".as_ptr() as *const _,
312 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(notify_owner_trampoline::<F> as *const ())), Box_::into_raw(f))
313 }
314 }
315
316 #[cfg(feature = "v1_2")]
317 #[cfg_attr(docsrs, doc(cfg(feature = "v1_2")))]
318 #[doc(alias = "pi")]
319 pub fn connect_pi_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
320 unsafe extern "C" fn notify_pi_trampoline<F: Fn(&SettingTun) + 'static>(this: *mut ffi::NMSettingTun, _param_spec: glib::ffi::gpointer, f: glib::ffi::gpointer) {
321 let f: &F = &*(f as *const F);
322 f(&from_glib_borrow(this))
323 }
324 unsafe {
325 let f: Box_<F> = Box_::new(f);
326 connect_raw(self.as_ptr() as *mut _, c"notify::pi".as_ptr() as *const _,
327 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(notify_pi_trampoline::<F> as *const ())), Box_::into_raw(f))
328 }
329 }
330
331 #[cfg(feature = "v1_2")]
332 #[cfg_attr(docsrs, doc(cfg(feature = "v1_2")))]
333 #[doc(alias = "vnet-hdr")]
334 pub fn connect_vnet_hdr_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
335 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) {
336 let f: &F = &*(f as *const F);
337 f(&from_glib_borrow(this))
338 }
339 unsafe {
340 let f: Box_<F> = Box_::new(f);
341 connect_raw(self.as_ptr() as *mut _, c"notify::vnet-hdr".as_ptr() as *const _,
342 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(notify_vnet_hdr_trampoline::<F> as *const ())), Box_::into_raw(f))
343 }
344 }
345}
346
347#[cfg(feature = "v1_2")]
348#[cfg_attr(docsrs, doc(cfg(feature = "v1_2")))]
349impl Default for SettingTun {
350 fn default() -> Self {
351 Self::new()
352 }
353 }
354
355#[must_use = "The builder must be built to be used"]
360pub struct SettingTunBuilder {
361 builder: glib::object::ObjectBuilder<'static, SettingTun>,
362 }
363
364 impl SettingTunBuilder {
365 fn new() -> Self {
366 Self { builder: glib::object::Object::builder() }
367 }
368
369 #[cfg(feature = "v1_2")]
372 #[cfg_attr(docsrs, doc(cfg(feature = "v1_2")))]
373 pub fn group(self, group: impl Into<glib::GString>) -> Self {
374 Self { builder: self.builder.property("group", group.into()), }
375 }
376
377 #[cfg(feature = "v1_2")]
382 #[cfg_attr(docsrs, doc(cfg(feature = "v1_2")))]
383 pub fn mode(self, mode: u32) -> Self {
384 Self { builder: self.builder.property("mode", mode), }
385 }
386
387 #[cfg(feature = "v1_2")]
392 #[cfg_attr(docsrs, doc(cfg(feature = "v1_2")))]
393 pub fn multi_queue(self, multi_queue: bool) -> Self {
394 Self { builder: self.builder.property("multi-queue", multi_queue), }
395 }
396
397 #[cfg(feature = "v1_2")]
400 #[cfg_attr(docsrs, doc(cfg(feature = "v1_2")))]
401 pub fn owner(self, owner: impl Into<glib::GString>) -> Self {
402 Self { builder: self.builder.property("owner", owner.into()), }
403 }
404
405 #[cfg(feature = "v1_2")]
408 #[cfg_attr(docsrs, doc(cfg(feature = "v1_2")))]
409 pub fn pi(self, pi: bool) -> Self {
410 Self { builder: self.builder.property("pi", pi), }
411 }
412
413 #[cfg(feature = "v1_2")]
416 #[cfg_attr(docsrs, doc(cfg(feature = "v1_2")))]
417 pub fn vnet_hdr(self, vnet_hdr: bool) -> Self {
418 Self { builder: self.builder.property("vnet-hdr", vnet_hdr), }
419 }
420
421 #[must_use = "Building the object from the builder is usually expensive and is not expected to have side effects"]
424 pub fn build(self) -> SettingTun {
425assert_initialized_main_thread!();
426 self.builder.build() }
427}