nm_rs/auto/
setting_macvlan.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_2")]
8#[cfg_attr(docsrs, doc(cfg(feature = "v1_2")))]
9use crate::{SettingMacvlanMode};
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    /// MAC VLAN Settings
20    ///
21    /// ## Properties
22    ///
23    ///
24    /// #### `mode`
25    ///  The macvlan mode, which specifies the communication mechanism between multiple
26    /// macvlans on the same lower device.
27    ///
28    /// Readable | Writeable
29    ///
30    ///
31    /// #### `parent`
32    ///  If given, specifies the parent interface name or parent connection UUID
33    /// from which this MAC-VLAN 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    /// #### `promiscuous`
41    ///  Whether the parent interface should be put in promiscuous mode (true by default).
42    ///
43    /// Readable | Writeable
44    ///
45    ///
46    /// #### `tap`
47    ///  Whether the interface should be a MACVTAP.
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 = "NMSettingMacvlan")]
65    pub struct SettingMacvlan(Object<ffi::NMSettingMacvlan, ffi::NMSettingMacvlanClass>) @extends Setting;
66
67    match fn {
68        type_ => || ffi::nm_setting_macvlan_get_type(),
69    }
70}
71
72impl SettingMacvlan {
73    /// Creates a new #NMSettingMacvlan object with default values.
74    ///
75    /// # Returns
76    ///
77    /// the new empty #NMSettingMacvlan object
78    #[cfg(feature = "v1_2")]
79    #[cfg_attr(docsrs, doc(cfg(feature = "v1_2")))]
80    #[doc(alias = "nm_setting_macvlan_new")]
81    pub fn new() -> SettingMacvlan {
82        assert_initialized_main_thread!();
83        unsafe {
84            Setting::from_glib_full(ffi::nm_setting_macvlan_new()).unsafe_cast()
85        }
86    }
87
88            // rustdoc-stripper-ignore-next
89            /// Creates a new builder-pattern struct instance to construct [`SettingMacvlan`] objects.
90            ///
91            /// This method returns an instance of [`SettingMacvlanBuilder`](crate::builders::SettingMacvlanBuilder) which can be used to create [`SettingMacvlan`] objects.
92            pub fn builder() -> SettingMacvlanBuilder {
93                SettingMacvlanBuilder::new()
94            }
95        
96
97    ///
98    /// # Returns
99    ///
100    /// the #NMSettingMacvlan:mode property of the setting
101    #[cfg(feature = "v1_2")]
102    #[cfg_attr(docsrs, doc(cfg(feature = "v1_2")))]
103    #[doc(alias = "nm_setting_macvlan_get_mode")]
104    #[doc(alias = "get_mode")]
105    pub fn mode(&self) -> SettingMacvlanMode {
106        unsafe {
107            from_glib(ffi::nm_setting_macvlan_get_mode(self.to_glib_none().0))
108        }
109    }
110
111    ///
112    /// # Returns
113    ///
114    /// the #NMSettingMacvlan:parent property of the setting
115    #[cfg(feature = "v1_2")]
116    #[cfg_attr(docsrs, doc(cfg(feature = "v1_2")))]
117    #[doc(alias = "nm_setting_macvlan_get_parent")]
118    #[doc(alias = "get_parent")]
119    pub fn parent(&self) -> glib::GString {
120        unsafe {
121            from_glib_none(ffi::nm_setting_macvlan_get_parent(self.to_glib_none().0))
122        }
123    }
124
125    ///
126    /// # Returns
127    ///
128    /// the #NMSettingMacvlan:promiscuous property of the setting
129    #[cfg(feature = "v1_2")]
130    #[cfg_attr(docsrs, doc(cfg(feature = "v1_2")))]
131    #[doc(alias = "nm_setting_macvlan_get_promiscuous")]
132    #[doc(alias = "get_promiscuous")]
133    #[doc(alias = "promiscuous")]
134    pub fn is_promiscuous(&self) -> bool {
135        unsafe {
136            from_glib(ffi::nm_setting_macvlan_get_promiscuous(self.to_glib_none().0))
137        }
138    }
139
140    ///
141    /// # Returns
142    ///
143    /// the #NMSettingMacvlan:tap property of the setting
144    #[cfg(feature = "v1_2")]
145    #[cfg_attr(docsrs, doc(cfg(feature = "v1_2")))]
146    #[doc(alias = "nm_setting_macvlan_get_tap")]
147    #[doc(alias = "get_tap")]
148    #[doc(alias = "tap")]
149    pub fn is_tap(&self) -> bool {
150        unsafe {
151            from_glib(ffi::nm_setting_macvlan_get_tap(self.to_glib_none().0))
152        }
153    }
154
155    /// The macvlan mode, which specifies the communication mechanism between multiple
156    /// macvlans on the same lower device.
157    #[cfg(feature = "v1_2")]
158    #[cfg_attr(docsrs, doc(cfg(feature = "v1_2")))]
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 MAC-VLAN 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_2")]
168    #[cfg_attr(docsrs, doc(cfg(feature = "v1_2")))]
169    pub fn set_parent(&self, parent: Option<&str>) {
170        ObjectExt::set_property(self,"parent", parent)
171    }
172
173    /// Whether the parent interface should be put in promiscuous mode (true by default).
174    #[cfg(feature = "v1_2")]
175    #[cfg_attr(docsrs, doc(cfg(feature = "v1_2")))]
176    pub fn set_promiscuous(&self, promiscuous: bool) {
177        ObjectExt::set_property(self,"promiscuous", promiscuous)
178    }
179
180    /// Whether the interface should be a MACVTAP.
181    #[cfg(feature = "v1_2")]
182    #[cfg_attr(docsrs, doc(cfg(feature = "v1_2")))]
183    pub fn set_tap(&self, tap: bool) {
184        ObjectExt::set_property(self,"tap", tap)
185    }
186
187    #[cfg(feature = "v1_2")]
188    #[cfg_attr(docsrs, doc(cfg(feature = "v1_2")))]
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(&SettingMacvlan) + 'static>(this: *mut ffi::NMSettingMacvlan, _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_2")]
203    #[cfg_attr(docsrs, doc(cfg(feature = "v1_2")))]
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(&SettingMacvlan) + 'static>(this: *mut ffi::NMSettingMacvlan, _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_2")]
218    #[cfg_attr(docsrs, doc(cfg(feature = "v1_2")))]
219    #[doc(alias = "promiscuous")]
220    pub fn connect_promiscuous_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
221        unsafe extern "C" fn notify_promiscuous_trampoline<F: Fn(&SettingMacvlan) + 'static>(this: *mut ffi::NMSettingMacvlan, _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::promiscuous".as_ptr() as *const _,
228                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(notify_promiscuous_trampoline::<F> as *const ())), Box_::into_raw(f))
229        }
230    }
231
232    #[cfg(feature = "v1_2")]
233    #[cfg_attr(docsrs, doc(cfg(feature = "v1_2")))]
234    #[doc(alias = "tap")]
235    pub fn connect_tap_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
236        unsafe extern "C" fn notify_tap_trampoline<F: Fn(&SettingMacvlan) + 'static>(this: *mut ffi::NMSettingMacvlan, _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::tap".as_ptr() as *const _,
243                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(notify_tap_trampoline::<F> as *const ())), Box_::into_raw(f))
244        }
245    }
246}
247
248#[cfg(feature = "v1_2")]
249#[cfg_attr(docsrs, doc(cfg(feature = "v1_2")))]
250impl Default for SettingMacvlan {
251                     fn default() -> Self {
252                         Self::new()
253                     }
254                 }
255
256// rustdoc-stripper-ignore-next
257        /// A [builder-pattern] type to construct [`SettingMacvlan`] 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 SettingMacvlanBuilder {
262            builder: glib::object::ObjectBuilder<'static, SettingMacvlan>,
263        }
264
265        impl SettingMacvlanBuilder {
266        fn new() -> Self {
267            Self { builder: glib::object::Object::builder() }
268        }
269
270                            /// The macvlan mode, which specifies the communication mechanism between multiple
271                            /// macvlans on the same lower device.
272                            #[cfg(feature = "v1_2")]
273    #[cfg_attr(docsrs, doc(cfg(feature = "v1_2")))]
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 MAC-VLAN 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_2")]
283    #[cfg_attr(docsrs, doc(cfg(feature = "v1_2")))]
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 parent interface should be put in promiscuous mode (true by default).
289                            #[cfg(feature = "v1_2")]
290    #[cfg_attr(docsrs, doc(cfg(feature = "v1_2")))]
291    pub fn promiscuous(self, promiscuous: bool) -> Self {
292                            Self { builder: self.builder.property("promiscuous", promiscuous), }
293                        }
294
295                            /// Whether the interface should be a MACVTAP.
296                            #[cfg(feature = "v1_2")]
297    #[cfg_attr(docsrs, doc(cfg(feature = "v1_2")))]
298    pub fn tap(self, tap: bool) -> Self {
299                            Self { builder: self.builder.property("tap", tap), }
300                        }
301
302    // rustdoc-stripper-ignore-next
303    /// Build the [`SettingMacvlan`].
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) -> SettingMacvlan {
306assert_initialized_main_thread!();
307    self.builder.build() }
308}