1use crate::{ffi,Device,IPTunnelMode,Object};
7#[cfg(feature = "v1_12")]
8#[cfg_attr(docsrs, doc(cfg(feature = "v1_12")))]
9use crate::{IPTunnelFlags};
10use glib::{prelude::*,signal::{connect_raw, SignalHandlerId},translate::*};
11use std::{boxed::Box as Box_};
12
13glib::wrapper! {
14 #[doc(alias = "NMDeviceIPTunnel")]
347 pub struct DeviceIPTunnel(Object<ffi::NMDeviceIPTunnel, ffi::NMDeviceIPTunnelClass>) @extends Device, Object;
348
349 match fn {
350 type_ => || ffi::nm_device_ip_tunnel_get_type(),
351 }
352}
353
354impl DeviceIPTunnel {
355 pub fn builder() -> DeviceIPTunnelBuilder {
360 DeviceIPTunnelBuilder::new()
361 }
362
363
364 #[doc(alias = "nm_device_ip_tunnel_get_encapsulation_limit")]
369 #[doc(alias = "get_encapsulation_limit")]
370 #[doc(alias = "encapsulation-limit")]
371 pub fn encapsulation_limit(&self) -> u8 {
372 unsafe {
373 ffi::nm_device_ip_tunnel_get_encapsulation_limit(self.to_glib_none().0)
374 }
375 }
376
377 #[cfg(feature = "v1_12")]
382 #[cfg_attr(docsrs, doc(cfg(feature = "v1_12")))]
383 #[doc(alias = "nm_device_ip_tunnel_get_flags")]
384 #[doc(alias = "get_flags")]
385 pub fn flags(&self) -> IPTunnelFlags {
386 unsafe {
387 from_glib(ffi::nm_device_ip_tunnel_get_flags(self.to_glib_none().0))
388 }
389 }
390
391 #[doc(alias = "nm_device_ip_tunnel_get_flow_label")]
396 #[doc(alias = "get_flow_label")]
397 #[doc(alias = "flow-label")]
398 pub fn flow_label(&self) -> u32 {
399 unsafe {
400 ffi::nm_device_ip_tunnel_get_flow_label(self.to_glib_none().0)
401 }
402 }
403
404 #[cfg(feature = "v1_46")]
410 #[cfg_attr(docsrs, doc(cfg(feature = "v1_46")))]
411 #[doc(alias = "nm_device_ip_tunnel_get_fwmark")]
412 #[doc(alias = "get_fwmark")]
413 pub fn fwmark(&self) -> u32 {
414 unsafe {
415 ffi::nm_device_ip_tunnel_get_fwmark(self.to_glib_none().0)
416 }
417 }
418
419 #[doc(alias = "nm_device_ip_tunnel_get_input_key")]
424 #[doc(alias = "get_input_key")]
425 #[doc(alias = "input-key")]
426 pub fn input_key(&self) -> glib::GString {
427 unsafe {
428 from_glib_none(ffi::nm_device_ip_tunnel_get_input_key(self.to_glib_none().0))
429 }
430 }
431
432 #[doc(alias = "nm_device_ip_tunnel_get_local")]
437 #[doc(alias = "get_local")]
438 pub fn local(&self) -> glib::GString {
439 unsafe {
440 from_glib_none(ffi::nm_device_ip_tunnel_get_local(self.to_glib_none().0))
441 }
442 }
443
444 #[doc(alias = "nm_device_ip_tunnel_get_mode")]
449 #[doc(alias = "get_mode")]
450 pub fn mode(&self) -> IPTunnelMode {
451 unsafe {
452 from_glib(ffi::nm_device_ip_tunnel_get_mode(self.to_glib_none().0))
453 }
454 }
455
456 #[doc(alias = "nm_device_ip_tunnel_get_output_key")]
461 #[doc(alias = "get_output_key")]
462 #[doc(alias = "output-key")]
463 pub fn output_key(&self) -> glib::GString {
464 unsafe {
465 from_glib_none(ffi::nm_device_ip_tunnel_get_output_key(self.to_glib_none().0))
466 }
467 }
468
469 #[doc(alias = "nm_device_ip_tunnel_get_parent")]
474 #[doc(alias = "get_parent")]
475 pub fn parent(&self) -> Device {
476 unsafe {
477 from_glib_none(ffi::nm_device_ip_tunnel_get_parent(self.to_glib_none().0))
478 }
479 }
480
481 #[doc(alias = "nm_device_ip_tunnel_get_path_mtu_discovery")]
486 #[doc(alias = "get_path_mtu_discovery")]
487 #[doc(alias = "path-mtu-discovery")]
488 pub fn is_path_mtu_discovery(&self) -> bool {
489 unsafe {
490 from_glib(ffi::nm_device_ip_tunnel_get_path_mtu_discovery(self.to_glib_none().0))
491 }
492 }
493
494 #[doc(alias = "nm_device_ip_tunnel_get_remote")]
499 #[doc(alias = "get_remote")]
500 pub fn remote(&self) -> glib::GString {
501 unsafe {
502 from_glib_none(ffi::nm_device_ip_tunnel_get_remote(self.to_glib_none().0))
503 }
504 }
505
506 #[doc(alias = "nm_device_ip_tunnel_get_tos")]
512 #[doc(alias = "get_tos")]
513 pub fn tos(&self) -> u8 {
514 unsafe {
515 ffi::nm_device_ip_tunnel_get_tos(self.to_glib_none().0)
516 }
517 }
518
519 #[doc(alias = "nm_device_ip_tunnel_get_ttl")]
524 #[doc(alias = "get_ttl")]
525 pub fn ttl(&self) -> u8 {
526 unsafe {
527 ffi::nm_device_ip_tunnel_get_ttl(self.to_glib_none().0)
528 }
529 }
530
531 #[cfg(feature = "v1_2")]
532 #[cfg_attr(docsrs, doc(cfg(feature = "v1_2")))]
533 #[doc(alias = "encapsulation-limit")]
534 pub fn connect_encapsulation_limit_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
535 unsafe extern "C" fn notify_encapsulation_limit_trampoline<F: Fn(&DeviceIPTunnel) + 'static>(this: *mut ffi::NMDeviceIPTunnel, _param_spec: glib::ffi::gpointer, f: glib::ffi::gpointer) {
536 let f: &F = &*(f as *const F);
537 f(&from_glib_borrow(this))
538 }
539 unsafe {
540 let f: Box_<F> = Box_::new(f);
541 connect_raw(self.as_ptr() as *mut _, c"notify::encapsulation-limit".as_ptr() as *const _,
542 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(notify_encapsulation_limit_trampoline::<F> as *const ())), Box_::into_raw(f))
543 }
544 }
545
546 #[cfg(feature = "v1_12")]
547 #[cfg_attr(docsrs, doc(cfg(feature = "v1_12")))]
548 #[doc(alias = "flags")]
549 pub fn connect_flags_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
550 unsafe extern "C" fn notify_flags_trampoline<F: Fn(&DeviceIPTunnel) + 'static>(this: *mut ffi::NMDeviceIPTunnel, _param_spec: glib::ffi::gpointer, f: glib::ffi::gpointer) {
551 let f: &F = &*(f as *const F);
552 f(&from_glib_borrow(this))
553 }
554 unsafe {
555 let f: Box_<F> = Box_::new(f);
556 connect_raw(self.as_ptr() as *mut _, c"notify::flags".as_ptr() as *const _,
557 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(notify_flags_trampoline::<F> as *const ())), Box_::into_raw(f))
558 }
559 }
560
561 #[cfg(feature = "v1_2")]
562 #[cfg_attr(docsrs, doc(cfg(feature = "v1_2")))]
563 #[doc(alias = "flow-label")]
564 pub fn connect_flow_label_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
565 unsafe extern "C" fn notify_flow_label_trampoline<F: Fn(&DeviceIPTunnel) + 'static>(this: *mut ffi::NMDeviceIPTunnel, _param_spec: glib::ffi::gpointer, f: glib::ffi::gpointer) {
566 let f: &F = &*(f as *const F);
567 f(&from_glib_borrow(this))
568 }
569 unsafe {
570 let f: Box_<F> = Box_::new(f);
571 connect_raw(self.as_ptr() as *mut _, c"notify::flow-label".as_ptr() as *const _,
572 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(notify_flow_label_trampoline::<F> as *const ())), Box_::into_raw(f))
573 }
574 }
575
576 #[cfg(feature = "v1_46")]
577 #[cfg_attr(docsrs, doc(cfg(feature = "v1_46")))]
578 #[doc(alias = "fwmark")]
579 pub fn connect_fwmark_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
580 unsafe extern "C" fn notify_fwmark_trampoline<F: Fn(&DeviceIPTunnel) + 'static>(this: *mut ffi::NMDeviceIPTunnel, _param_spec: glib::ffi::gpointer, f: glib::ffi::gpointer) {
581 let f: &F = &*(f as *const F);
582 f(&from_glib_borrow(this))
583 }
584 unsafe {
585 let f: Box_<F> = Box_::new(f);
586 connect_raw(self.as_ptr() as *mut _, c"notify::fwmark".as_ptr() as *const _,
587 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(notify_fwmark_trampoline::<F> as *const ())), Box_::into_raw(f))
588 }
589 }
590
591 #[cfg(feature = "v1_2")]
592 #[cfg_attr(docsrs, doc(cfg(feature = "v1_2")))]
593 #[doc(alias = "input-key")]
594 pub fn connect_input_key_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
595 unsafe extern "C" fn notify_input_key_trampoline<F: Fn(&DeviceIPTunnel) + 'static>(this: *mut ffi::NMDeviceIPTunnel, _param_spec: glib::ffi::gpointer, f: glib::ffi::gpointer) {
596 let f: &F = &*(f as *const F);
597 f(&from_glib_borrow(this))
598 }
599 unsafe {
600 let f: Box_<F> = Box_::new(f);
601 connect_raw(self.as_ptr() as *mut _, c"notify::input-key".as_ptr() as *const _,
602 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(notify_input_key_trampoline::<F> as *const ())), Box_::into_raw(f))
603 }
604 }
605
606 #[cfg(feature = "v1_2")]
607 #[cfg_attr(docsrs, doc(cfg(feature = "v1_2")))]
608 #[doc(alias = "local")]
609 pub fn connect_local_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
610 unsafe extern "C" fn notify_local_trampoline<F: Fn(&DeviceIPTunnel) + 'static>(this: *mut ffi::NMDeviceIPTunnel, _param_spec: glib::ffi::gpointer, f: glib::ffi::gpointer) {
611 let f: &F = &*(f as *const F);
612 f(&from_glib_borrow(this))
613 }
614 unsafe {
615 let f: Box_<F> = Box_::new(f);
616 connect_raw(self.as_ptr() as *mut _, c"notify::local".as_ptr() as *const _,
617 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(notify_local_trampoline::<F> as *const ())), Box_::into_raw(f))
618 }
619 }
620
621 #[cfg(feature = "v1_2")]
622 #[cfg_attr(docsrs, doc(cfg(feature = "v1_2")))]
623 #[doc(alias = "mode")]
624 pub fn connect_mode_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
625 unsafe extern "C" fn notify_mode_trampoline<F: Fn(&DeviceIPTunnel) + 'static>(this: *mut ffi::NMDeviceIPTunnel, _param_spec: glib::ffi::gpointer, f: glib::ffi::gpointer) {
626 let f: &F = &*(f as *const F);
627 f(&from_glib_borrow(this))
628 }
629 unsafe {
630 let f: Box_<F> = Box_::new(f);
631 connect_raw(self.as_ptr() as *mut _, c"notify::mode".as_ptr() as *const _,
632 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(notify_mode_trampoline::<F> as *const ())), Box_::into_raw(f))
633 }
634 }
635
636 #[cfg(feature = "v1_2")]
637 #[cfg_attr(docsrs, doc(cfg(feature = "v1_2")))]
638 #[doc(alias = "output-key")]
639 pub fn connect_output_key_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
640 unsafe extern "C" fn notify_output_key_trampoline<F: Fn(&DeviceIPTunnel) + 'static>(this: *mut ffi::NMDeviceIPTunnel, _param_spec: glib::ffi::gpointer, f: glib::ffi::gpointer) {
641 let f: &F = &*(f as *const F);
642 f(&from_glib_borrow(this))
643 }
644 unsafe {
645 let f: Box_<F> = Box_::new(f);
646 connect_raw(self.as_ptr() as *mut _, c"notify::output-key".as_ptr() as *const _,
647 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(notify_output_key_trampoline::<F> as *const ())), Box_::into_raw(f))
648 }
649 }
650
651 #[cfg(feature = "v1_2")]
652 #[cfg_attr(docsrs, doc(cfg(feature = "v1_2")))]
653 #[doc(alias = "parent")]
654 pub fn connect_parent_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
655 unsafe extern "C" fn notify_parent_trampoline<F: Fn(&DeviceIPTunnel) + 'static>(this: *mut ffi::NMDeviceIPTunnel, _param_spec: glib::ffi::gpointer, f: glib::ffi::gpointer) {
656 let f: &F = &*(f as *const F);
657 f(&from_glib_borrow(this))
658 }
659 unsafe {
660 let f: Box_<F> = Box_::new(f);
661 connect_raw(self.as_ptr() as *mut _, c"notify::parent".as_ptr() as *const _,
662 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(notify_parent_trampoline::<F> as *const ())), Box_::into_raw(f))
663 }
664 }
665
666 #[cfg(feature = "v1_2")]
667 #[cfg_attr(docsrs, doc(cfg(feature = "v1_2")))]
668 #[doc(alias = "path-mtu-discovery")]
669 pub fn connect_path_mtu_discovery_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
670 unsafe extern "C" fn notify_path_mtu_discovery_trampoline<F: Fn(&DeviceIPTunnel) + 'static>(this: *mut ffi::NMDeviceIPTunnel, _param_spec: glib::ffi::gpointer, f: glib::ffi::gpointer) {
671 let f: &F = &*(f as *const F);
672 f(&from_glib_borrow(this))
673 }
674 unsafe {
675 let f: Box_<F> = Box_::new(f);
676 connect_raw(self.as_ptr() as *mut _, c"notify::path-mtu-discovery".as_ptr() as *const _,
677 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(notify_path_mtu_discovery_trampoline::<F> as *const ())), Box_::into_raw(f))
678 }
679 }
680
681 #[cfg(feature = "v1_2")]
682 #[cfg_attr(docsrs, doc(cfg(feature = "v1_2")))]
683 #[doc(alias = "remote")]
684 pub fn connect_remote_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
685 unsafe extern "C" fn notify_remote_trampoline<F: Fn(&DeviceIPTunnel) + 'static>(this: *mut ffi::NMDeviceIPTunnel, _param_spec: glib::ffi::gpointer, f: glib::ffi::gpointer) {
686 let f: &F = &*(f as *const F);
687 f(&from_glib_borrow(this))
688 }
689 unsafe {
690 let f: Box_<F> = Box_::new(f);
691 connect_raw(self.as_ptr() as *mut _, c"notify::remote".as_ptr() as *const _,
692 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(notify_remote_trampoline::<F> as *const ())), Box_::into_raw(f))
693 }
694 }
695
696 #[cfg(feature = "v1_2")]
697 #[cfg_attr(docsrs, doc(cfg(feature = "v1_2")))]
698 #[doc(alias = "tos")]
699 pub fn connect_tos_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
700 unsafe extern "C" fn notify_tos_trampoline<F: Fn(&DeviceIPTunnel) + 'static>(this: *mut ffi::NMDeviceIPTunnel, _param_spec: glib::ffi::gpointer, f: glib::ffi::gpointer) {
701 let f: &F = &*(f as *const F);
702 f(&from_glib_borrow(this))
703 }
704 unsafe {
705 let f: Box_<F> = Box_::new(f);
706 connect_raw(self.as_ptr() as *mut _, c"notify::tos".as_ptr() as *const _,
707 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(notify_tos_trampoline::<F> as *const ())), Box_::into_raw(f))
708 }
709 }
710
711 #[cfg(feature = "v1_2")]
712 #[cfg_attr(docsrs, doc(cfg(feature = "v1_2")))]
713 #[doc(alias = "ttl")]
714 pub fn connect_ttl_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
715 unsafe extern "C" fn notify_ttl_trampoline<F: Fn(&DeviceIPTunnel) + 'static>(this: *mut ffi::NMDeviceIPTunnel, _param_spec: glib::ffi::gpointer, f: glib::ffi::gpointer) {
716 let f: &F = &*(f as *const F);
717 f(&from_glib_borrow(this))
718 }
719 unsafe {
720 let f: Box_<F> = Box_::new(f);
721 connect_raw(self.as_ptr() as *mut _, c"notify::ttl".as_ptr() as *const _,
722 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(notify_ttl_trampoline::<F> as *const ())), Box_::into_raw(f))
723 }
724 }
725}
726
727#[must_use = "The builder must be built to be used"]
732pub struct DeviceIPTunnelBuilder {
733 builder: glib::object::ObjectBuilder<'static, DeviceIPTunnel>,
734 }
735
736 impl DeviceIPTunnelBuilder {
737 fn new() -> Self {
738 Self { builder: glib::object::Object::builder() }
739 }
740
741 pub fn autoconnect(self, autoconnect: bool) -> Self {
745 Self { builder: self.builder.property("autoconnect", autoconnect), }
746 }
747
748 #[must_use = "Building the object from the builder is usually expensive and is not expected to have side effects"]
751 pub fn build(self) -> DeviceIPTunnel {
752assert_initialized_main_thread!();
753 self.builder.build() }
754}