nm_rs/auto/
setting_tun.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::{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    /// Tunnel Settings
20    ///
21    /// ## Properties
22    ///
23    ///
24    /// #### `group`
25    ///  The group ID which will own the device. If set to [`None`] everyone
26    /// will be able to use the device.
27    ///
28    /// Readable | Writeable
29    ///
30    ///
31    /// #### `mode`
32    ///  The operating mode of the virtual device. Allowed values are
33    /// [`SettingTunMode::Tun`][crate::SettingTunMode::Tun] to create a layer 3 device and
34    /// [`SettingTunMode::Tap`][crate::SettingTunMode::Tap] to create an Ethernet-like layer 2
35    /// one.
36    ///
37    /// Readable | Writeable
38    ///
39    ///
40    /// #### `multi-queue`
41    ///  If the property is set to [`true`], the interface will support
42    /// multiple file descriptors (queues) to parallelize packet
43    /// sending or receiving. Otherwise, the interface will only
44    /// support a single queue.
45    ///
46    /// Readable | Writeable
47    ///
48    ///
49    /// #### `owner`
50    ///  The user ID which will own the device. If set to [`None`] everyone
51    /// will be able to use the device.
52    ///
53    /// Readable | Writeable
54    ///
55    ///
56    /// #### `pi`
57    ///  If [`true`] the interface will prepend a 4 byte header describing the
58    /// physical interface to the packets.
59    ///
60    /// Readable | Writeable
61    ///
62    ///
63    /// #### `vnet-hdr`
64    ///  If [`true`] the IFF_VNET_HDR the tunnel packets will include a virtio
65    /// network header.
66    ///
67    /// Readable | Writeable
68    /// <details><summary><h4>Setting</h4></summary>
69    ///
70    ///
71    /// #### `name`
72    ///  The setting's name, which uniquely identifies the setting within the
73    /// connection.  Each setting type has a name unique to that type, for
74    /// example "ppp" or "802-11-wireless" or "802-3-ethernet".
75    ///
76    /// Readable
77    /// </details>
78    ///
79    /// # Implements
80    ///
81    /// [`SettingExt`][trait@crate::prelude::SettingExt]
82    #[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    /// Creates a new #NMSettingTun object with default values.
92    ///
93    /// # Returns
94    ///
95    /// the new empty #NMSettingTun object
96    #[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            // rustdoc-stripper-ignore-next
107            /// Creates a new builder-pattern struct instance to construct [`SettingTun`] objects.
108            ///
109            /// This method returns an instance of [`SettingTunBuilder`](crate::builders::SettingTunBuilder) which can be used to create [`SettingTun`] objects.
110            pub fn builder() -> SettingTunBuilder {
111                SettingTunBuilder::new()
112            }
113        
114
115    ///
116    /// # Returns
117    ///
118    /// the #NMSettingTun:group property of the setting
119    #[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    ///
130    /// # Returns
131    ///
132    /// the #NMSettingTun:mode property of the setting
133    #[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    ///
144    /// # Returns
145    ///
146    /// the #NMSettingTun:multi-queue property of the setting
147    #[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    ///
159    /// # Returns
160    ///
161    /// the #NMSettingTun:owner property of the setting
162    #[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    ///
173    /// # Returns
174    ///
175    /// the #NMSettingTun:pi property of the setting
176    #[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    ///
188    /// # Returns
189    ///
190    /// the #NMSettingTun:vnet_hdr property of the setting
191    #[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    /// The group ID which will own the device. If set to [`None`] everyone
203    /// will be able to use the device.
204    #[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    /// The operating mode of the virtual device. Allowed values are
211    /// [`SettingTunMode::Tun`][crate::SettingTunMode::Tun] to create a layer 3 device and
212    /// [`SettingTunMode::Tap`][crate::SettingTunMode::Tap] to create an Ethernet-like layer 2
213    /// one.
214    #[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    /// If the property is set to [`true`], the interface will support
221    /// multiple file descriptors (queues) to parallelize packet
222    /// sending or receiving. Otherwise, the interface will only
223    /// support a single queue.
224    #[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    /// The user ID which will own the device. If set to [`None`] everyone
232    /// will be able to use the device.
233    #[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    /// If [`true`] the interface will prepend a 4 byte header describing the
240    /// physical interface to the packets.
241    #[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    /// If [`true`] the IFF_VNET_HDR the tunnel packets will include a virtio
248    /// network header.
249    #[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// rustdoc-stripper-ignore-next
356        /// A [builder-pattern] type to construct [`SettingTun`] objects.
357        ///
358        /// [builder-pattern]: https://doc.rust-lang.org/1.0.0/style/ownership/builders.html
359#[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                            /// The group ID which will own the device. If set to [`None`] everyone
370                            /// will be able to use the device.
371                            #[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                            /// The operating mode of the virtual device. Allowed values are
378                            /// [`SettingTunMode::Tun`][crate::SettingTunMode::Tun] to create a layer 3 device and
379                            /// [`SettingTunMode::Tap`][crate::SettingTunMode::Tap] to create an Ethernet-like layer 2
380                            /// one.
381                            #[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                            /// If the property is set to [`true`], the interface will support
388                            /// multiple file descriptors (queues) to parallelize packet
389                            /// sending or receiving. Otherwise, the interface will only
390                            /// support a single queue.
391                            #[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                            /// The user ID which will own the device. If set to [`None`] everyone
398                            /// will be able to use the device.
399                            #[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                            /// If [`true`] the interface will prepend a 4 byte header describing the
406                            /// physical interface to the packets.
407                            #[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                            /// If [`true`] the IFF_VNET_HDR the tunnel packets will include a virtio
414                            /// network header.
415                            #[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    // rustdoc-stripper-ignore-next
422    /// Build the [`SettingTun`].
423    #[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}