nm_rs/auto/
setting_veth.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::*};
8#[cfg(feature = "v1_30")]
9#[cfg_attr(docsrs, doc(cfg(feature = "v1_30")))]
10use glib::{signal::{connect_raw, SignalHandlerId},translate::*};
11#[cfg(feature = "v1_30")]
12#[cfg_attr(docsrs, doc(cfg(feature = "v1_30")))]
13use std::{boxed::Box as Box_};
14
15glib::wrapper! {
16    /// Veth Settings
17    ///
18    /// ## Properties
19    ///
20    ///
21    /// #### `peer`
22    ///  This property specifies the peer interface name of the veth. This
23    /// property is mandatory.
24    ///
25    /// Readable | Writeable
26    /// <details><summary><h4>Setting</h4></summary>
27    ///
28    ///
29    /// #### `name`
30    ///  The setting's name, which uniquely identifies the setting within the
31    /// connection.  Each setting type has a name unique to that type, for
32    /// example "ppp" or "802-11-wireless" or "802-3-ethernet".
33    ///
34    /// Readable
35    /// </details>
36    ///
37    /// # Implements
38    ///
39    /// [`SettingExt`][trait@crate::prelude::SettingExt]
40    #[doc(alias = "NMSettingVeth")]
41    pub struct SettingVeth(Object<ffi::NMSettingVeth, ffi::NMSettingVethClass>) @extends Setting;
42
43    match fn {
44        type_ => || ffi::nm_setting_veth_get_type(),
45    }
46}
47
48impl SettingVeth {
49    /// Creates a new #NMSettingVeth object with default values.
50    ///
51    /// # Returns
52    ///
53    /// the new empty #NMSettingVeth object
54    #[cfg(feature = "v1_30")]
55    #[cfg_attr(docsrs, doc(cfg(feature = "v1_30")))]
56    #[doc(alias = "nm_setting_veth_new")]
57    pub fn new() -> SettingVeth {
58        assert_initialized_main_thread!();
59        unsafe {
60            Setting::from_glib_full(ffi::nm_setting_veth_new()).unsafe_cast()
61        }
62    }
63
64            // rustdoc-stripper-ignore-next
65            /// Creates a new builder-pattern struct instance to construct [`SettingVeth`] objects.
66            ///
67            /// This method returns an instance of [`SettingVethBuilder`](crate::builders::SettingVethBuilder) which can be used to create [`SettingVeth`] objects.
68            pub fn builder() -> SettingVethBuilder {
69                SettingVethBuilder::new()
70            }
71        
72
73    ///
74    /// # Returns
75    ///
76    /// the #NMSettingVeth:peer property of the setting
77    #[cfg(feature = "v1_30")]
78    #[cfg_attr(docsrs, doc(cfg(feature = "v1_30")))]
79    #[doc(alias = "nm_setting_veth_get_peer")]
80    #[doc(alias = "get_peer")]
81    pub fn peer(&self) -> glib::GString {
82        unsafe {
83            from_glib_none(ffi::nm_setting_veth_get_peer(self.to_glib_none().0))
84        }
85    }
86
87    /// This property specifies the peer interface name of the veth. This
88    /// property is mandatory.
89    #[cfg(feature = "v1_30")]
90    #[cfg_attr(docsrs, doc(cfg(feature = "v1_30")))]
91    pub fn set_peer(&self, peer: Option<&str>) {
92        ObjectExt::set_property(self,"peer", peer)
93    }
94
95    #[cfg(feature = "v1_30")]
96    #[cfg_attr(docsrs, doc(cfg(feature = "v1_30")))]
97    #[doc(alias = "peer")]
98    pub fn connect_peer_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
99        unsafe extern "C" fn notify_peer_trampoline<F: Fn(&SettingVeth) + 'static>(this: *mut ffi::NMSettingVeth, _param_spec: glib::ffi::gpointer, f: glib::ffi::gpointer) {
100            let f: &F = &*(f as *const F);
101            f(&from_glib_borrow(this))
102        }
103        unsafe {
104            let f: Box_<F> = Box_::new(f);
105            connect_raw(self.as_ptr() as *mut _, c"notify::peer".as_ptr() as *const _,
106                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(notify_peer_trampoline::<F> as *const ())), Box_::into_raw(f))
107        }
108    }
109}
110
111#[cfg(feature = "v1_30")]
112#[cfg_attr(docsrs, doc(cfg(feature = "v1_30")))]
113impl Default for SettingVeth {
114                     fn default() -> Self {
115                         Self::new()
116                     }
117                 }
118
119// rustdoc-stripper-ignore-next
120        /// A [builder-pattern] type to construct [`SettingVeth`] objects.
121        ///
122        /// [builder-pattern]: https://doc.rust-lang.org/1.0.0/style/ownership/builders.html
123#[must_use = "The builder must be built to be used"]
124pub struct SettingVethBuilder {
125            builder: glib::object::ObjectBuilder<'static, SettingVeth>,
126        }
127
128        impl SettingVethBuilder {
129        fn new() -> Self {
130            Self { builder: glib::object::Object::builder() }
131        }
132
133                            /// This property specifies the peer interface name of the veth. This
134                            /// property is mandatory.
135                            #[cfg(feature = "v1_30")]
136    #[cfg_attr(docsrs, doc(cfg(feature = "v1_30")))]
137    pub fn peer(self, peer: impl Into<glib::GString>) -> Self {
138                            Self { builder: self.builder.property("peer", peer.into()), }
139                        }
140
141    // rustdoc-stripper-ignore-next
142    /// Build the [`SettingVeth`].
143    #[must_use = "Building the object from the builder is usually expensive and is not expected to have side effects"]
144    pub fn build(self) -> SettingVeth {
145assert_initialized_main_thread!();
146    self.builder.build() }
147}