nm_rs/auto/
setting_ovs_bridge.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    /// OvsBridge Link Settings
17    ///
18    /// ## Properties
19    ///
20    ///
21    /// #### `datapath-type`
22    ///  The data path type. One of "system", "netdev" or empty.
23    ///
24    /// Readable | Writeable
25    ///
26    ///
27    /// #### `fail-mode`
28    ///  The bridge failure mode. One of "secure", "standalone" or empty.
29    ///
30    /// Readable | Writeable
31    ///
32    ///
33    /// #### `mcast-snooping-enable`
34    ///  Enable or disable multicast snooping.
35    ///
36    /// Readable | Writeable
37    ///
38    ///
39    /// #### `rstp-enable`
40    ///  Enable or disable RSTP.
41    ///
42    /// Readable | Writeable
43    ///
44    ///
45    /// #### `stp-enable`
46    ///  Enable or disable STP.
47    ///
48    /// Readable | Writeable
49    /// <details><summary><h4>Setting</h4></summary>
50    ///
51    ///
52    /// #### `name`
53    ///  The setting's name, which uniquely identifies the setting within the
54    /// connection.  Each setting type has a name unique to that type, for
55    /// example "ppp" or "802-11-wireless" or "802-3-ethernet".
56    ///
57    /// Readable
58    /// </details>
59    ///
60    /// # Implements
61    ///
62    /// [`SettingExt`][trait@crate::prelude::SettingExt]
63    #[doc(alias = "NMSettingOvsBridge")]
64    pub struct SettingOvsBridge(Object<ffi::NMSettingOvsBridge, ffi::NMSettingOvsBridgeClass>) @extends Setting;
65
66    match fn {
67        type_ => || ffi::nm_setting_ovs_bridge_get_type(),
68    }
69}
70
71impl SettingOvsBridge {
72    /// Creates a new #NMSettingOvsBridge object with default values.
73    ///
74    /// # Returns
75    ///
76    /// the new empty #NMSettingOvsBridge object
77    #[cfg(feature = "v1_10")]
78    #[cfg_attr(docsrs, doc(cfg(feature = "v1_10")))]
79    #[doc(alias = "nm_setting_ovs_bridge_new")]
80    pub fn new() -> SettingOvsBridge {
81        assert_initialized_main_thread!();
82        unsafe {
83            Setting::from_glib_full(ffi::nm_setting_ovs_bridge_new()).unsafe_cast()
84        }
85    }
86
87            // rustdoc-stripper-ignore-next
88            /// Creates a new builder-pattern struct instance to construct [`SettingOvsBridge`] objects.
89            ///
90            /// This method returns an instance of [`SettingOvsBridgeBuilder`](crate::builders::SettingOvsBridgeBuilder) which can be used to create [`SettingOvsBridge`] objects.
91            pub fn builder() -> SettingOvsBridgeBuilder {
92                SettingOvsBridgeBuilder::new()
93            }
94        
95
96    ///
97    /// # Returns
98    ///
99    /// the #NMSettingOvsBridge:datapath_type property of the setting
100    #[cfg(feature = "v1_42")]
101    #[cfg_attr(docsrs, doc(cfg(feature = "v1_42")))]
102    #[doc(alias = "nm_setting_ovs_bridge_get_datapath_type")]
103    #[doc(alias = "get_datapath_type")]
104    #[doc(alias = "datapath-type")]
105    pub fn datapath_type(&self) -> glib::GString {
106        unsafe {
107            from_glib_none(ffi::nm_setting_ovs_bridge_get_datapath_type(self.to_glib_none().0))
108        }
109    }
110
111    ///
112    /// # Returns
113    ///
114    /// the #NMSettingOvsBridge:fail_mode property of the setting
115    #[cfg(feature = "v1_10")]
116    #[cfg_attr(docsrs, doc(cfg(feature = "v1_10")))]
117    #[doc(alias = "nm_setting_ovs_bridge_get_fail_mode")]
118    #[doc(alias = "get_fail_mode")]
119    #[doc(alias = "fail-mode")]
120    pub fn fail_mode(&self) -> glib::GString {
121        unsafe {
122            from_glib_none(ffi::nm_setting_ovs_bridge_get_fail_mode(self.to_glib_none().0))
123        }
124    }
125
126    ///
127    /// # Returns
128    ///
129    /// the #NMSettingOvsBridge:mcast_snooping_enable property of the setting
130    #[cfg(feature = "v1_10")]
131    #[cfg_attr(docsrs, doc(cfg(feature = "v1_10")))]
132    #[doc(alias = "nm_setting_ovs_bridge_get_mcast_snooping_enable")]
133    #[doc(alias = "get_mcast_snooping_enable")]
134    #[doc(alias = "mcast-snooping-enable")]
135    pub fn is_mcast_snooping_enable(&self) -> bool {
136        unsafe {
137            from_glib(ffi::nm_setting_ovs_bridge_get_mcast_snooping_enable(self.to_glib_none().0))
138        }
139    }
140
141    ///
142    /// # Returns
143    ///
144    /// the #NMSettingOvsBridge:rstp_enable property of the setting
145    #[cfg(feature = "v1_10")]
146    #[cfg_attr(docsrs, doc(cfg(feature = "v1_10")))]
147    #[doc(alias = "nm_setting_ovs_bridge_get_rstp_enable")]
148    #[doc(alias = "get_rstp_enable")]
149    #[doc(alias = "rstp-enable")]
150    pub fn is_rstp_enable(&self) -> bool {
151        unsafe {
152            from_glib(ffi::nm_setting_ovs_bridge_get_rstp_enable(self.to_glib_none().0))
153        }
154    }
155
156    ///
157    /// # Returns
158    ///
159    /// the #NMSettingOvsBridge:stp_enable property of the setting
160    #[cfg(feature = "v1_10")]
161    #[cfg_attr(docsrs, doc(cfg(feature = "v1_10")))]
162    #[doc(alias = "nm_setting_ovs_bridge_get_stp_enable")]
163    #[doc(alias = "get_stp_enable")]
164    #[doc(alias = "stp-enable")]
165    pub fn is_stp_enable(&self) -> bool {
166        unsafe {
167            from_glib(ffi::nm_setting_ovs_bridge_get_stp_enable(self.to_glib_none().0))
168        }
169    }
170
171    #[cfg(not(feature = "v1_42"))]
172    #[cfg_attr(docsrs, doc(cfg(not(feature = "v1_42"))))]
173    #[doc(alias = "datapath-type")]
174    pub fn datapath_type(&self) -> Option<glib::GString> {
175        ObjectExt::property(self, "datapath-type")
176    }
177
178    /// The data path type. One of "system", "netdev" or empty.
179    #[cfg(feature = "v1_20")]
180    #[cfg_attr(docsrs, doc(cfg(feature = "v1_20")))]
181    #[doc(alias = "datapath-type")]
182    pub fn set_datapath_type(&self, datapath_type: Option<&str>) {
183        ObjectExt::set_property(self,"datapath-type", datapath_type)
184    }
185
186    /// The bridge failure mode. One of "secure", "standalone" or empty.
187    #[cfg(feature = "v1_10")]
188    #[cfg_attr(docsrs, doc(cfg(feature = "v1_10")))]
189    #[doc(alias = "fail-mode")]
190    pub fn set_fail_mode(&self, fail_mode: Option<&str>) {
191        ObjectExt::set_property(self,"fail-mode", fail_mode)
192    }
193
194    /// Enable or disable multicast snooping.
195    #[cfg(feature = "v1_10")]
196    #[cfg_attr(docsrs, doc(cfg(feature = "v1_10")))]
197    #[doc(alias = "mcast-snooping-enable")]
198    pub fn set_mcast_snooping_enable(&self, mcast_snooping_enable: bool) {
199        ObjectExt::set_property(self,"mcast-snooping-enable", mcast_snooping_enable)
200    }
201
202    /// Enable or disable RSTP.
203    #[cfg(feature = "v1_10")]
204    #[cfg_attr(docsrs, doc(cfg(feature = "v1_10")))]
205    #[doc(alias = "rstp-enable")]
206    pub fn set_rstp_enable(&self, rstp_enable: bool) {
207        ObjectExt::set_property(self,"rstp-enable", rstp_enable)
208    }
209
210    /// Enable or disable STP.
211    #[cfg(feature = "v1_10")]
212    #[cfg_attr(docsrs, doc(cfg(feature = "v1_10")))]
213    #[doc(alias = "stp-enable")]
214    pub fn set_stp_enable(&self, stp_enable: bool) {
215        ObjectExt::set_property(self,"stp-enable", stp_enable)
216    }
217
218    #[cfg(feature = "v1_20")]
219    #[cfg_attr(docsrs, doc(cfg(feature = "v1_20")))]
220    #[doc(alias = "datapath-type")]
221    pub fn connect_datapath_type_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
222        unsafe extern "C" fn notify_datapath_type_trampoline<F: Fn(&SettingOvsBridge) + 'static>(this: *mut ffi::NMSettingOvsBridge, _param_spec: glib::ffi::gpointer, f: glib::ffi::gpointer) {
223            let f: &F = &*(f as *const F);
224            f(&from_glib_borrow(this))
225        }
226        unsafe {
227            let f: Box_<F> = Box_::new(f);
228            connect_raw(self.as_ptr() as *mut _, c"notify::datapath-type".as_ptr() as *const _,
229                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(notify_datapath_type_trampoline::<F> as *const ())), Box_::into_raw(f))
230        }
231    }
232
233    #[cfg(feature = "v1_10")]
234    #[cfg_attr(docsrs, doc(cfg(feature = "v1_10")))]
235    #[doc(alias = "fail-mode")]
236    pub fn connect_fail_mode_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
237        unsafe extern "C" fn notify_fail_mode_trampoline<F: Fn(&SettingOvsBridge) + 'static>(this: *mut ffi::NMSettingOvsBridge, _param_spec: glib::ffi::gpointer, f: glib::ffi::gpointer) {
238            let f: &F = &*(f as *const F);
239            f(&from_glib_borrow(this))
240        }
241        unsafe {
242            let f: Box_<F> = Box_::new(f);
243            connect_raw(self.as_ptr() as *mut _, c"notify::fail-mode".as_ptr() as *const _,
244                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(notify_fail_mode_trampoline::<F> as *const ())), Box_::into_raw(f))
245        }
246    }
247
248    #[cfg(feature = "v1_10")]
249    #[cfg_attr(docsrs, doc(cfg(feature = "v1_10")))]
250    #[doc(alias = "mcast-snooping-enable")]
251    pub fn connect_mcast_snooping_enable_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
252        unsafe extern "C" fn notify_mcast_snooping_enable_trampoline<F: Fn(&SettingOvsBridge) + 'static>(this: *mut ffi::NMSettingOvsBridge, _param_spec: glib::ffi::gpointer, f: glib::ffi::gpointer) {
253            let f: &F = &*(f as *const F);
254            f(&from_glib_borrow(this))
255        }
256        unsafe {
257            let f: Box_<F> = Box_::new(f);
258            connect_raw(self.as_ptr() as *mut _, c"notify::mcast-snooping-enable".as_ptr() as *const _,
259                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(notify_mcast_snooping_enable_trampoline::<F> as *const ())), Box_::into_raw(f))
260        }
261    }
262
263    #[cfg(feature = "v1_10")]
264    #[cfg_attr(docsrs, doc(cfg(feature = "v1_10")))]
265    #[doc(alias = "rstp-enable")]
266    pub fn connect_rstp_enable_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
267        unsafe extern "C" fn notify_rstp_enable_trampoline<F: Fn(&SettingOvsBridge) + 'static>(this: *mut ffi::NMSettingOvsBridge, _param_spec: glib::ffi::gpointer, f: glib::ffi::gpointer) {
268            let f: &F = &*(f as *const F);
269            f(&from_glib_borrow(this))
270        }
271        unsafe {
272            let f: Box_<F> = Box_::new(f);
273            connect_raw(self.as_ptr() as *mut _, c"notify::rstp-enable".as_ptr() as *const _,
274                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(notify_rstp_enable_trampoline::<F> as *const ())), Box_::into_raw(f))
275        }
276    }
277
278    #[cfg(feature = "v1_10")]
279    #[cfg_attr(docsrs, doc(cfg(feature = "v1_10")))]
280    #[doc(alias = "stp-enable")]
281    pub fn connect_stp_enable_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
282        unsafe extern "C" fn notify_stp_enable_trampoline<F: Fn(&SettingOvsBridge) + 'static>(this: *mut ffi::NMSettingOvsBridge, _param_spec: glib::ffi::gpointer, f: glib::ffi::gpointer) {
283            let f: &F = &*(f as *const F);
284            f(&from_glib_borrow(this))
285        }
286        unsafe {
287            let f: Box_<F> = Box_::new(f);
288            connect_raw(self.as_ptr() as *mut _, c"notify::stp-enable".as_ptr() as *const _,
289                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(notify_stp_enable_trampoline::<F> as *const ())), Box_::into_raw(f))
290        }
291    }
292}
293
294#[cfg(feature = "v1_10")]
295#[cfg_attr(docsrs, doc(cfg(feature = "v1_10")))]
296impl Default for SettingOvsBridge {
297                     fn default() -> Self {
298                         Self::new()
299                     }
300                 }
301
302// rustdoc-stripper-ignore-next
303        /// A [builder-pattern] type to construct [`SettingOvsBridge`] objects.
304        ///
305        /// [builder-pattern]: https://doc.rust-lang.org/1.0.0/style/ownership/builders.html
306#[must_use = "The builder must be built to be used"]
307pub struct SettingOvsBridgeBuilder {
308            builder: glib::object::ObjectBuilder<'static, SettingOvsBridge>,
309        }
310
311        impl SettingOvsBridgeBuilder {
312        fn new() -> Self {
313            Self { builder: glib::object::Object::builder() }
314        }
315
316                            /// The data path type. One of "system", "netdev" or empty.
317                            #[cfg(feature = "v1_20")]
318    #[cfg_attr(docsrs, doc(cfg(feature = "v1_20")))]
319    pub fn datapath_type(self, datapath_type: impl Into<glib::GString>) -> Self {
320                            Self { builder: self.builder.property("datapath-type", datapath_type.into()), }
321                        }
322
323                            /// The bridge failure mode. One of "secure", "standalone" or empty.
324                            #[cfg(feature = "v1_10")]
325    #[cfg_attr(docsrs, doc(cfg(feature = "v1_10")))]
326    pub fn fail_mode(self, fail_mode: impl Into<glib::GString>) -> Self {
327                            Self { builder: self.builder.property("fail-mode", fail_mode.into()), }
328                        }
329
330                            /// Enable or disable multicast snooping.
331                            #[cfg(feature = "v1_10")]
332    #[cfg_attr(docsrs, doc(cfg(feature = "v1_10")))]
333    pub fn mcast_snooping_enable(self, mcast_snooping_enable: bool) -> Self {
334                            Self { builder: self.builder.property("mcast-snooping-enable", mcast_snooping_enable), }
335                        }
336
337                            /// Enable or disable RSTP.
338                            #[cfg(feature = "v1_10")]
339    #[cfg_attr(docsrs, doc(cfg(feature = "v1_10")))]
340    pub fn rstp_enable(self, rstp_enable: bool) -> Self {
341                            Self { builder: self.builder.property("rstp-enable", rstp_enable), }
342                        }
343
344                            /// Enable or disable STP.
345                            #[cfg(feature = "v1_10")]
346    #[cfg_attr(docsrs, doc(cfg(feature = "v1_10")))]
347    pub fn stp_enable(self, stp_enable: bool) -> Self {
348                            Self { builder: self.builder.property("stp-enable", stp_enable), }
349                        }
350
351    // rustdoc-stripper-ignore-next
352    /// Build the [`SettingOvsBridge`].
353    #[must_use = "Building the object from the builder is usually expensive and is not expected to have side effects"]
354    pub fn build(self) -> SettingOvsBridge {
355assert_initialized_main_thread!();
356    self.builder.build() }
357}