nm_rs/auto/
setting_loopback.rs

1// This file was generated by gir (https://github.com/gtk-rs/gir)
2// from gir
3// from gtk-girs (https://github.com/gtk-rs/gir-files)
4// DO NOT EDIT
5
6use crate::{ffi,Setting};
7use glib::{prelude::*,signal::{connect_raw, SignalHandlerId},translate::*};
8use std::{boxed::Box as Box_};
9
10glib::wrapper! {
11    /// Loopback Link Settings
12    ///
13    /// ## Properties
14    ///
15    ///
16    /// #### `mtu`
17    ///  If non-zero, only transmit packets of the specified size or smaller,
18    /// breaking larger packets up into multiple Ethernet frames.
19    ///
20    /// Readable | Writeable
21    /// <details><summary><h4>Setting</h4></summary>
22    ///
23    ///
24    /// #### `name`
25    ///  The setting's name, which uniquely identifies the setting within the
26    /// connection.  Each setting type has a name unique to that type, for
27    /// example "ppp" or "802-11-wireless" or "802-3-ethernet".
28    ///
29    /// Readable
30    /// </details>
31    ///
32    /// # Implements
33    ///
34    /// [`SettingExt`][trait@crate::prelude::SettingExt]
35    #[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    /// Creates a new #NMSettingLoopback object with default values.
45    ///
46    /// # Returns
47    ///
48    /// the new empty #NMSettingLoopback object
49    #[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            // rustdoc-stripper-ignore-next
58            /// Creates a new builder-pattern struct instance to construct [`SettingLoopback`] objects.
59            ///
60            /// This method returns an instance of [`SettingLoopbackBuilder`](crate::builders::SettingLoopbackBuilder) which can be used to create [`SettingLoopback`] objects.
61            pub fn builder() -> SettingLoopbackBuilder {
62                SettingLoopbackBuilder::new()
63            }
64        
65
66    ///
67    /// # Returns
68    ///
69    /// the #NMSettingLoopback:mtu property of the setting
70    #[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    /// If non-zero, only transmit packets of the specified size or smaller,
79    /// breaking larger packets up into multiple Ethernet frames.
80    #[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// rustdoc-stripper-ignore-next
111        /// A [builder-pattern] type to construct [`SettingLoopback`] objects.
112        ///
113        /// [builder-pattern]: https://doc.rust-lang.org/1.0.0/style/ownership/builders.html
114#[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                            /// If non-zero, only transmit packets of the specified size or smaller,
125                            /// breaking larger packets up into multiple Ethernet frames.
126                            #[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    // rustdoc-stripper-ignore-next
133    /// Build the [`SettingLoopback`].
134    #[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}