nm_rs/auto/
setting_ovs_patch.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_10")]
9#[cfg_attr(docsrs, doc(cfg(feature = "v1_10")))]
10use glib::{signal::{connect_raw, SignalHandlerId},translate::*};
11#[cfg(feature = "v1_10")]
12#[cfg_attr(docsrs, doc(cfg(feature = "v1_10")))]
13use std::{boxed::Box as Box_};
14
15glib::wrapper! {
16    /// OvsPatch Link Settings
17    ///
18    /// ## Properties
19    ///
20    ///
21    /// #### `peer`
22    ///  Specifies the name of the interface for the other side of the patch.
23    /// The patch on the other side must also set this interface as peer.
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 = "NMSettingOvsPatch")]
41    pub struct SettingOvsPatch(Object<ffi::NMSettingOvsPatch, ffi::NMSettingOvsPatchClass>) @extends Setting;
42
43    match fn {
44        type_ => || ffi::nm_setting_ovs_patch_get_type(),
45    }
46}
47
48impl SettingOvsPatch {
49    /// Creates a new #NMSettingOvsPatch object with default values.
50    ///
51    /// # Returns
52    ///
53    /// the new empty #NMSettingOvsPatch object
54    #[cfg(feature = "v1_10")]
55    #[cfg_attr(docsrs, doc(cfg(feature = "v1_10")))]
56    #[doc(alias = "nm_setting_ovs_patch_new")]
57    pub fn new() -> SettingOvsPatch {
58        assert_initialized_main_thread!();
59        unsafe {
60            Setting::from_glib_full(ffi::nm_setting_ovs_patch_new()).unsafe_cast()
61        }
62    }
63
64            // rustdoc-stripper-ignore-next
65            /// Creates a new builder-pattern struct instance to construct [`SettingOvsPatch`] objects.
66            ///
67            /// This method returns an instance of [`SettingOvsPatchBuilder`](crate::builders::SettingOvsPatchBuilder) which can be used to create [`SettingOvsPatch`] objects.
68            pub fn builder() -> SettingOvsPatchBuilder {
69                SettingOvsPatchBuilder::new()
70            }
71        
72
73    ///
74    /// # Returns
75    ///
76    /// the #NMSettingOvsPatch:peer property of the setting
77    #[cfg(feature = "v1_10")]
78    #[cfg_attr(docsrs, doc(cfg(feature = "v1_10")))]
79    #[doc(alias = "nm_setting_ovs_patch_get_peer")]
80    #[doc(alias = "get_peer")]
81    pub fn peer(&self) -> glib::GString {
82        unsafe {
83            from_glib_none(ffi::nm_setting_ovs_patch_get_peer(self.to_glib_none().0))
84        }
85    }
86
87    /// Specifies the name of the interface for the other side of the patch.
88    /// The patch on the other side must also set this interface as peer.
89    #[cfg(feature = "v1_10")]
90    #[cfg_attr(docsrs, doc(cfg(feature = "v1_10")))]
91    pub fn set_peer(&self, peer: Option<&str>) {
92        ObjectExt::set_property(self,"peer", peer)
93    }
94
95    #[cfg(feature = "v1_10")]
96    #[cfg_attr(docsrs, doc(cfg(feature = "v1_10")))]
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(&SettingOvsPatch) + 'static>(this: *mut ffi::NMSettingOvsPatch, _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_10")]
112#[cfg_attr(docsrs, doc(cfg(feature = "v1_10")))]
113impl Default for SettingOvsPatch {
114                     fn default() -> Self {
115                         Self::new()
116                     }
117                 }
118
119// rustdoc-stripper-ignore-next
120        /// A [builder-pattern] type to construct [`SettingOvsPatch`] 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 SettingOvsPatchBuilder {
125            builder: glib::object::ObjectBuilder<'static, SettingOvsPatch>,
126        }
127
128        impl SettingOvsPatchBuilder {
129        fn new() -> Self {
130            Self { builder: glib::object::Object::builder() }
131        }
132
133                            /// Specifies the name of the interface for the other side of the patch.
134                            /// The patch on the other side must also set this interface as peer.
135                            #[cfg(feature = "v1_10")]
136    #[cfg_attr(docsrs, doc(cfg(feature = "v1_10")))]
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 [`SettingOvsPatch`].
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) -> SettingOvsPatch {
145assert_initialized_main_thread!();
146    self.builder.build() }
147}