nm_rs/auto/
setting_ipvlan.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};
7#[cfg(feature = "v1_52")]
8#[cfg_attr(docsrs, doc(cfg(feature = "v1_52")))]
9use crate::{SettingIpvlanMode};
10use glib::{prelude::*};
11#[cfg(feature = "v1_52")]
12#[cfg_attr(docsrs, doc(cfg(feature = "v1_52")))]
13use glib::{signal::{connect_raw, SignalHandlerId},translate::*};
14#[cfg(feature = "v1_52")]
15#[cfg_attr(docsrs, doc(cfg(feature = "v1_52")))]
16use std::{boxed::Box as Box_};
17
18glib::wrapper! {
19    /// IPVLAN Settings
20    ///
21    /// ## Properties
22    ///
23    ///
24    /// #### `mode`
25    ///  The IPVLAN mode. Valid values: [`SettingIpvlanMode::L2`][crate::SettingIpvlanMode::L2],
26    /// [`SettingIpvlanMode::L3`][crate::SettingIpvlanMode::L3] and [`SettingIpvlanMode::L3s`][crate::SettingIpvlanMode::L3s].
27    ///
28    /// Readable | Writeable
29    ///
30    ///
31    /// #### `parent`
32    ///  If given, specifies the parent interface name or parent connection UUID
33    /// from which this IPVLAN interface should be created. If this property is
34    /// not specified, the connection must contain an #NMSettingWired setting
35    /// with a #NMSettingWired:mac-address property.
36    ///
37    /// Readable | Writeable
38    ///
39    ///
40    /// #### `private`
41    ///  Whether the interface should be put in private mode.
42    ///
43    /// Readable | Writeable
44    ///
45    ///
46    /// #### `vepa`
47    ///  Whether the interface should be put in VEPA mode.
48    ///
49    /// Readable | Writeable
50    /// <details><summary><h4>Setting</h4></summary>
51    ///
52    ///
53    /// #### `name`
54    ///  The setting's name, which uniquely identifies the setting within the
55    /// connection.  Each setting type has a name unique to that type, for
56    /// example "ppp" or "802-11-wireless" or "802-3-ethernet".
57    ///
58    /// Readable
59    /// </details>
60    ///
61    /// # Implements
62    ///
63    /// [`SettingExt`][trait@crate::prelude::SettingExt]
64    #[doc(alias = "NMSettingIpvlan")]
65    pub struct SettingIpvlan(Object<ffi::NMSettingIpvlan, ffi::NMSettingIpvlanClass>) @extends Setting;
66
67    match fn {
68        type_ => || ffi::nm_setting_ipvlan_get_type(),
69    }
70}
71
72impl SettingIpvlan {
73    /// Creates a new #NMSettingIpvlan object with default values.
74    ///
75    /// # Returns
76    ///
77    /// the new empty #NMSettingIpvlan object
78    #[cfg(feature = "v1_52")]
79    #[cfg_attr(docsrs, doc(cfg(feature = "v1_52")))]
80    #[doc(alias = "nm_setting_ipvlan_new")]
81    pub fn new() -> SettingIpvlan {
82        assert_initialized_main_thread!();
83        unsafe {
84            Setting::from_glib_full(ffi::nm_setting_ipvlan_new()).unsafe_cast()
85        }
86    }
87
88            // rustdoc-stripper-ignore-next
89            /// Creates a new builder-pattern struct instance to construct [`SettingIpvlan`] objects.
90            ///
91            /// This method returns an instance of [`SettingIpvlanBuilder`](crate::builders::SettingIpvlanBuilder) which can be used to create [`SettingIpvlan`] objects.
92            pub fn builder() -> SettingIpvlanBuilder {
93                SettingIpvlanBuilder::new()
94            }
95        
96
97    ///
98    /// # Returns
99    ///
100    /// the #NMSettingIpvlan:mode property of the setting
101    #[cfg(feature = "v1_52")]
102    #[cfg_attr(docsrs, doc(cfg(feature = "v1_52")))]
103    #[doc(alias = "nm_setting_ipvlan_get_mode")]
104    #[doc(alias = "get_mode")]
105    pub fn mode(&self) -> SettingIpvlanMode {
106        unsafe {
107            from_glib(ffi::nm_setting_ipvlan_get_mode(self.to_glib_none().0))
108        }
109    }
110
111    ///
112    /// # Returns
113    ///
114    /// the #NMSettingIpvlan:parent property of the setting
115    #[cfg(feature = "v1_52")]
116    #[cfg_attr(docsrs, doc(cfg(feature = "v1_52")))]
117    #[doc(alias = "nm_setting_ipvlan_get_parent")]
118    #[doc(alias = "get_parent")]
119    pub fn parent(&self) -> glib::GString {
120        unsafe {
121            from_glib_none(ffi::nm_setting_ipvlan_get_parent(self.to_glib_none().0))
122        }
123    }
124
125    ///
126    /// # Returns
127    ///
128    /// the #NMSettingIpvlan:private property of the setting
129    #[cfg(feature = "v1_52")]
130    #[cfg_attr(docsrs, doc(cfg(feature = "v1_52")))]
131    #[doc(alias = "nm_setting_ipvlan_get_private")]
132    #[doc(alias = "get_private")]
133    #[doc(alias = "private")]
134    pub fn is_private(&self) -> bool {
135        unsafe {
136            from_glib(ffi::nm_setting_ipvlan_get_private(self.to_glib_none().0))
137        }
138    }
139
140    ///
141    /// # Returns
142    ///
143    /// the #NMSettingIpvlan:vepa property of the setting
144    #[cfg(feature = "v1_52")]
145    #[cfg_attr(docsrs, doc(cfg(feature = "v1_52")))]
146    #[doc(alias = "nm_setting_ipvlan_get_vepa")]
147    #[doc(alias = "get_vepa")]
148    #[doc(alias = "vepa")]
149    pub fn is_vepa(&self) -> bool {
150        unsafe {
151            from_glib(ffi::nm_setting_ipvlan_get_vepa(self.to_glib_none().0))
152        }
153    }
154
155    /// The IPVLAN mode. Valid values: [`SettingIpvlanMode::L2`][crate::SettingIpvlanMode::L2],
156    /// [`SettingIpvlanMode::L3`][crate::SettingIpvlanMode::L3] and [`SettingIpvlanMode::L3s`][crate::SettingIpvlanMode::L3s].
157    #[cfg(feature = "v1_52")]
158    #[cfg_attr(docsrs, doc(cfg(feature = "v1_52")))]
159    pub fn set_mode(&self, mode: u32) {
160        ObjectExt::set_property(self,"mode", mode)
161    }
162
163    /// If given, specifies the parent interface name or parent connection UUID
164    /// from which this IPVLAN interface should be created. If this property is
165    /// not specified, the connection must contain an #NMSettingWired setting
166    /// with a #NMSettingWired:mac-address property.
167    #[cfg(feature = "v1_52")]
168    #[cfg_attr(docsrs, doc(cfg(feature = "v1_52")))]
169    pub fn set_parent(&self, parent: Option<&str>) {
170        ObjectExt::set_property(self,"parent", parent)
171    }
172
173    /// Whether the interface should be put in private mode.
174    #[cfg(feature = "v1_52")]
175    #[cfg_attr(docsrs, doc(cfg(feature = "v1_52")))]
176    pub fn set_private(&self, private: bool) {
177        ObjectExt::set_property(self,"private", private)
178    }
179
180    /// Whether the interface should be put in VEPA mode.
181    #[cfg(feature = "v1_52")]
182    #[cfg_attr(docsrs, doc(cfg(feature = "v1_52")))]
183    pub fn set_vepa(&self, vepa: bool) {
184        ObjectExt::set_property(self,"vepa", vepa)
185    }
186
187    #[cfg(feature = "v1_52")]
188    #[cfg_attr(docsrs, doc(cfg(feature = "v1_52")))]
189    #[doc(alias = "mode")]
190    pub fn connect_mode_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
191        unsafe extern "C" fn notify_mode_trampoline<F: Fn(&SettingIpvlan) + 'static>(this: *mut ffi::NMSettingIpvlan, _param_spec: glib::ffi::gpointer, f: glib::ffi::gpointer) {
192            let f: &F = &*(f as *const F);
193            f(&from_glib_borrow(this))
194        }
195        unsafe {
196            let f: Box_<F> = Box_::new(f);
197            connect_raw(self.as_ptr() as *mut _, c"notify::mode".as_ptr() as *const _,
198                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(notify_mode_trampoline::<F> as *const ())), Box_::into_raw(f))
199        }
200    }
201
202    #[cfg(feature = "v1_52")]
203    #[cfg_attr(docsrs, doc(cfg(feature = "v1_52")))]
204    #[doc(alias = "parent")]
205    pub fn connect_parent_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
206        unsafe extern "C" fn notify_parent_trampoline<F: Fn(&SettingIpvlan) + 'static>(this: *mut ffi::NMSettingIpvlan, _param_spec: glib::ffi::gpointer, f: glib::ffi::gpointer) {
207            let f: &F = &*(f as *const F);
208            f(&from_glib_borrow(this))
209        }
210        unsafe {
211            let f: Box_<F> = Box_::new(f);
212            connect_raw(self.as_ptr() as *mut _, c"notify::parent".as_ptr() as *const _,
213                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(notify_parent_trampoline::<F> as *const ())), Box_::into_raw(f))
214        }
215    }
216
217    #[cfg(feature = "v1_52")]
218    #[cfg_attr(docsrs, doc(cfg(feature = "v1_52")))]
219    #[doc(alias = "private")]
220    pub fn connect_private_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
221        unsafe extern "C" fn notify_private_trampoline<F: Fn(&SettingIpvlan) + 'static>(this: *mut ffi::NMSettingIpvlan, _param_spec: glib::ffi::gpointer, f: glib::ffi::gpointer) {
222            let f: &F = &*(f as *const F);
223            f(&from_glib_borrow(this))
224        }
225        unsafe {
226            let f: Box_<F> = Box_::new(f);
227            connect_raw(self.as_ptr() as *mut _, c"notify::private".as_ptr() as *const _,
228                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(notify_private_trampoline::<F> as *const ())), Box_::into_raw(f))
229        }
230    }
231
232    #[cfg(feature = "v1_52")]
233    #[cfg_attr(docsrs, doc(cfg(feature = "v1_52")))]
234    #[doc(alias = "vepa")]
235    pub fn connect_vepa_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
236        unsafe extern "C" fn notify_vepa_trampoline<F: Fn(&SettingIpvlan) + 'static>(this: *mut ffi::NMSettingIpvlan, _param_spec: glib::ffi::gpointer, f: glib::ffi::gpointer) {
237            let f: &F = &*(f as *const F);
238            f(&from_glib_borrow(this))
239        }
240        unsafe {
241            let f: Box_<F> = Box_::new(f);
242            connect_raw(self.as_ptr() as *mut _, c"notify::vepa".as_ptr() as *const _,
243                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(notify_vepa_trampoline::<F> as *const ())), Box_::into_raw(f))
244        }
245    }
246}
247
248#[cfg(feature = "v1_52")]
249#[cfg_attr(docsrs, doc(cfg(feature = "v1_52")))]
250impl Default for SettingIpvlan {
251                     fn default() -> Self {
252                         Self::new()
253                     }
254                 }
255
256// rustdoc-stripper-ignore-next
257        /// A [builder-pattern] type to construct [`SettingIpvlan`] objects.
258        ///
259        /// [builder-pattern]: https://doc.rust-lang.org/1.0.0/style/ownership/builders.html
260#[must_use = "The builder must be built to be used"]
261pub struct SettingIpvlanBuilder {
262            builder: glib::object::ObjectBuilder<'static, SettingIpvlan>,
263        }
264
265        impl SettingIpvlanBuilder {
266        fn new() -> Self {
267            Self { builder: glib::object::Object::builder() }
268        }
269
270                            /// The IPVLAN mode. Valid values: [`SettingIpvlanMode::L2`][crate::SettingIpvlanMode::L2],
271                            /// [`SettingIpvlanMode::L3`][crate::SettingIpvlanMode::L3] and [`SettingIpvlanMode::L3s`][crate::SettingIpvlanMode::L3s].
272                            #[cfg(feature = "v1_52")]
273    #[cfg_attr(docsrs, doc(cfg(feature = "v1_52")))]
274    pub fn mode(self, mode: u32) -> Self {
275                            Self { builder: self.builder.property("mode", mode), }
276                        }
277
278                            /// If given, specifies the parent interface name or parent connection UUID
279                            /// from which this IPVLAN interface should be created. If this property is
280                            /// not specified, the connection must contain an #NMSettingWired setting
281                            /// with a #NMSettingWired:mac-address property.
282                            #[cfg(feature = "v1_52")]
283    #[cfg_attr(docsrs, doc(cfg(feature = "v1_52")))]
284    pub fn parent(self, parent: impl Into<glib::GString>) -> Self {
285                            Self { builder: self.builder.property("parent", parent.into()), }
286                        }
287
288                            /// Whether the interface should be put in private mode.
289                            #[cfg(feature = "v1_52")]
290    #[cfg_attr(docsrs, doc(cfg(feature = "v1_52")))]
291    pub fn private(self, private: bool) -> Self {
292                            Self { builder: self.builder.property("private", private), }
293                        }
294
295                            /// Whether the interface should be put in VEPA mode.
296                            #[cfg(feature = "v1_52")]
297    #[cfg_attr(docsrs, doc(cfg(feature = "v1_52")))]
298    pub fn vepa(self, vepa: bool) -> Self {
299                            Self { builder: self.builder.property("vepa", vepa), }
300                        }
301
302    // rustdoc-stripper-ignore-next
303    /// Build the [`SettingIpvlan`].
304    #[must_use = "Building the object from the builder is usually expensive and is not expected to have side effects"]
305    pub fn build(self) -> SettingIpvlan {
306assert_initialized_main_thread!();
307    self.builder.build() }
308}