1use 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 #[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 #[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 pub fn builder() -> SettingOvsBridgeBuilder {
92 SettingOvsBridgeBuilder::new()
93 }
94
95
96 #[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 #[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 #[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 #[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 #[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 #[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 #[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 #[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 #[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 #[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#[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 #[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 #[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 #[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 #[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 #[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 #[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}