1#[cfg(feature = "v1_42")]
7#[cfg_attr(docsrs, doc(cfg(feature = "v1_42")))]
8use crate::Range;
9use crate::{Setting, ffi};
10use glib::prelude::*;
11#[cfg(feature = "v1_10")]
12#[cfg_attr(docsrs, doc(cfg(feature = "v1_10")))]
13use glib::{
14 signal::{SignalHandlerId, connect_raw},
15 translate::*,
16};
17#[cfg(feature = "v1_10")]
18#[cfg_attr(docsrs, doc(cfg(feature = "v1_10")))]
19use std::boxed::Box as Box_;
20
21glib::wrapper! {
22 #[doc(alias = "NMSettingOvsPort")]
87 pub struct SettingOvsPort(Object<ffi::NMSettingOvsPort, ffi::NMSettingOvsPortClass>) @extends Setting;
88
89 match fn {
90 type_ => || ffi::nm_setting_ovs_port_get_type(),
91 }
92}
93
94impl SettingOvsPort {
95 #[cfg(feature = "v1_10")]
101 #[cfg_attr(docsrs, doc(cfg(feature = "v1_10")))]
102 #[doc(alias = "nm_setting_ovs_port_new")]
103 pub fn new() -> SettingOvsPort {
104 assert_initialized_main_thread!();
105 unsafe { Setting::from_glib_full(ffi::nm_setting_ovs_port_new()).unsafe_cast() }
106 }
107
108 pub fn builder() -> SettingOvsPortBuilder {
113 SettingOvsPortBuilder::new()
114 }
115
116 #[cfg(feature = "v1_42")]
121 #[cfg_attr(docsrs, doc(cfg(feature = "v1_42")))]
122 #[doc(alias = "nm_setting_ovs_port_add_trunk")]
123 pub fn add_trunk(&self, trunk: &Range) {
124 unsafe {
125 ffi::nm_setting_ovs_port_add_trunk(self.to_glib_none().0, trunk.to_glib_none().0);
126 }
127 }
128
129 #[cfg(feature = "v1_42")]
131 #[cfg_attr(docsrs, doc(cfg(feature = "v1_42")))]
132 #[doc(alias = "nm_setting_ovs_port_clear_trunks")]
133 pub fn clear_trunks(&self) {
134 unsafe {
135 ffi::nm_setting_ovs_port_clear_trunks(self.to_glib_none().0);
136 }
137 }
138
139 #[cfg(feature = "v1_10")]
144 #[cfg_attr(docsrs, doc(cfg(feature = "v1_10")))]
145 #[doc(alias = "nm_setting_ovs_port_get_bond_downdelay")]
146 #[doc(alias = "get_bond_downdelay")]
147 #[doc(alias = "bond-downdelay")]
148 pub fn bond_downdelay(&self) -> u32 {
149 unsafe { ffi::nm_setting_ovs_port_get_bond_downdelay(self.to_glib_none().0) }
150 }
151
152 #[cfg(feature = "v1_10")]
157 #[cfg_attr(docsrs, doc(cfg(feature = "v1_10")))]
158 #[doc(alias = "nm_setting_ovs_port_get_bond_mode")]
159 #[doc(alias = "get_bond_mode")]
160 #[doc(alias = "bond-mode")]
161 pub fn bond_mode(&self) -> glib::GString {
162 unsafe {
163 from_glib_none(ffi::nm_setting_ovs_port_get_bond_mode(
164 self.to_glib_none().0,
165 ))
166 }
167 }
168
169 #[cfg(feature = "v1_10")]
174 #[cfg_attr(docsrs, doc(cfg(feature = "v1_10")))]
175 #[doc(alias = "nm_setting_ovs_port_get_bond_updelay")]
176 #[doc(alias = "get_bond_updelay")]
177 #[doc(alias = "bond-updelay")]
178 pub fn bond_updelay(&self) -> u32 {
179 unsafe { ffi::nm_setting_ovs_port_get_bond_updelay(self.to_glib_none().0) }
180 }
181
182 #[cfg(feature = "v1_10")]
187 #[cfg_attr(docsrs, doc(cfg(feature = "v1_10")))]
188 #[doc(alias = "nm_setting_ovs_port_get_lacp")]
189 #[doc(alias = "get_lacp")]
190 pub fn lacp(&self) -> glib::GString {
191 unsafe { from_glib_none(ffi::nm_setting_ovs_port_get_lacp(self.to_glib_none().0)) }
192 }
193
194 #[cfg(feature = "v1_42")]
199 #[cfg_attr(docsrs, doc(cfg(feature = "v1_42")))]
200 #[doc(alias = "nm_setting_ovs_port_get_num_trunks")]
201 #[doc(alias = "get_num_trunks")]
202 pub fn num_trunks(&self) -> u32 {
203 unsafe { ffi::nm_setting_ovs_port_get_num_trunks(self.to_glib_none().0) }
204 }
205
206 #[cfg(feature = "v1_10")]
211 #[cfg_attr(docsrs, doc(cfg(feature = "v1_10")))]
212 #[doc(alias = "nm_setting_ovs_port_get_tag")]
213 #[doc(alias = "get_tag")]
214 pub fn tag(&self) -> u32 {
215 unsafe { ffi::nm_setting_ovs_port_get_tag(self.to_glib_none().0) }
216 }
217
218 #[cfg(feature = "v1_42")]
225 #[cfg_attr(docsrs, doc(cfg(feature = "v1_42")))]
226 #[doc(alias = "nm_setting_ovs_port_get_trunk")]
227 #[doc(alias = "get_trunk")]
228 pub fn trunk(&self, idx: u32) -> Range {
229 unsafe {
230 from_glib_none(ffi::nm_setting_ovs_port_get_trunk(
231 self.to_glib_none().0,
232 idx,
233 ))
234 }
235 }
236
237 #[cfg(feature = "v1_10")]
242 #[cfg_attr(docsrs, doc(cfg(feature = "v1_10")))]
243 #[doc(alias = "nm_setting_ovs_port_get_vlan_mode")]
244 #[doc(alias = "get_vlan_mode")]
245 #[doc(alias = "vlan-mode")]
246 pub fn vlan_mode(&self) -> glib::GString {
247 unsafe {
248 from_glib_none(ffi::nm_setting_ovs_port_get_vlan_mode(
249 self.to_glib_none().0,
250 ))
251 }
252 }
253
254 #[cfg(feature = "v1_42")]
258 #[cfg_attr(docsrs, doc(cfg(feature = "v1_42")))]
259 #[doc(alias = "nm_setting_ovs_port_remove_trunk")]
260 pub fn remove_trunk(&self, idx: u32) {
261 unsafe {
262 ffi::nm_setting_ovs_port_remove_trunk(self.to_glib_none().0, idx);
263 }
264 }
265
266 #[cfg(feature = "v1_42")]
276 #[cfg_attr(docsrs, doc(cfg(feature = "v1_42")))]
277 #[doc(alias = "nm_setting_ovs_port_remove_trunk_by_value")]
278 pub fn remove_trunk_by_value(&self, start: u32, end: u32) -> bool {
279 unsafe {
280 from_glib(ffi::nm_setting_ovs_port_remove_trunk_by_value(
281 self.to_glib_none().0,
282 start,
283 end,
284 ))
285 }
286 }
287
288 #[cfg(feature = "v1_10")]
290 #[cfg_attr(docsrs, doc(cfg(feature = "v1_10")))]
291 #[doc(alias = "bond-downdelay")]
292 pub fn set_bond_downdelay(&self, bond_downdelay: u32) {
293 ObjectExt::set_property(self, "bond-downdelay", bond_downdelay)
294 }
295
296 #[cfg(feature = "v1_10")]
298 #[cfg_attr(docsrs, doc(cfg(feature = "v1_10")))]
299 #[doc(alias = "bond-mode")]
300 pub fn set_bond_mode(&self, bond_mode: Option<&str>) {
301 ObjectExt::set_property(self, "bond-mode", bond_mode)
302 }
303
304 #[cfg(feature = "v1_10")]
306 #[cfg_attr(docsrs, doc(cfg(feature = "v1_10")))]
307 #[doc(alias = "bond-updelay")]
308 pub fn set_bond_updelay(&self, bond_updelay: u32) {
309 ObjectExt::set_property(self, "bond-updelay", bond_updelay)
310 }
311
312 #[cfg(feature = "v1_10")]
314 #[cfg_attr(docsrs, doc(cfg(feature = "v1_10")))]
315 pub fn set_lacp(&self, lacp: Option<&str>) {
316 ObjectExt::set_property(self, "lacp", lacp)
317 }
318
319 #[cfg(feature = "v1_10")]
321 #[cfg_attr(docsrs, doc(cfg(feature = "v1_10")))]
322 pub fn set_tag(&self, tag: u32) {
323 ObjectExt::set_property(self, "tag", tag)
324 }
325
326 #[cfg(feature = "v1_42")]
332 #[cfg_attr(docsrs, doc(cfg(feature = "v1_42")))]
333 pub fn trunks(&self) -> Vec<Range> {
334 let vals = ObjectExt::property::<glib::ValueArray>(self, "trunks");
335 vals.iter()
336 .map(|value| {
337 use glib::value::FromValue;
338
339 unsafe { Range::from_value(value) }
340 })
341 .collect()
342 }
343
344 #[cfg(feature = "v1_42")]
350 #[cfg_attr(docsrs, doc(cfg(feature = "v1_42")))]
351 pub fn set_trunks(&self, trunks: &[&Range]) {
352 ObjectExt::set_property(
353 self,
354 "trunks",
355 trunks
356 .iter()
357 .map(|trunk| trunk.to_value())
358 .collect::<glib::ValueArray>(),
359 )
360 }
361
362 #[cfg(feature = "v1_10")]
365 #[cfg_attr(docsrs, doc(cfg(feature = "v1_10")))]
366 #[doc(alias = "vlan-mode")]
367 pub fn set_vlan_mode(&self, vlan_mode: Option<&str>) {
368 ObjectExt::set_property(self, "vlan-mode", vlan_mode)
369 }
370
371 #[cfg(feature = "v1_10")]
372 #[cfg_attr(docsrs, doc(cfg(feature = "v1_10")))]
373 #[doc(alias = "bond-downdelay")]
374 pub fn connect_bond_downdelay_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
375 unsafe extern "C" fn notify_bond_downdelay_trampoline<F: Fn(&SettingOvsPort) + 'static>(
376 this: *mut ffi::NMSettingOvsPort,
377 _param_spec: glib::ffi::gpointer,
378 f: glib::ffi::gpointer,
379 ) {
380 let f: &F = &*(f as *const F);
381 f(&from_glib_borrow(this))
382 }
383 unsafe {
384 let f: Box_<F> = Box_::new(f);
385 connect_raw(
386 self.as_ptr() as *mut _,
387 c"notify::bond-downdelay".as_ptr() as *const _,
388 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
389 notify_bond_downdelay_trampoline::<F> as *const (),
390 )),
391 Box_::into_raw(f),
392 )
393 }
394 }
395
396 #[cfg(feature = "v1_10")]
397 #[cfg_attr(docsrs, doc(cfg(feature = "v1_10")))]
398 #[doc(alias = "bond-mode")]
399 pub fn connect_bond_mode_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
400 unsafe extern "C" fn notify_bond_mode_trampoline<F: Fn(&SettingOvsPort) + 'static>(
401 this: *mut ffi::NMSettingOvsPort,
402 _param_spec: glib::ffi::gpointer,
403 f: glib::ffi::gpointer,
404 ) {
405 let f: &F = &*(f as *const F);
406 f(&from_glib_borrow(this))
407 }
408 unsafe {
409 let f: Box_<F> = Box_::new(f);
410 connect_raw(
411 self.as_ptr() as *mut _,
412 c"notify::bond-mode".as_ptr() as *const _,
413 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
414 notify_bond_mode_trampoline::<F> as *const (),
415 )),
416 Box_::into_raw(f),
417 )
418 }
419 }
420
421 #[cfg(feature = "v1_10")]
422 #[cfg_attr(docsrs, doc(cfg(feature = "v1_10")))]
423 #[doc(alias = "bond-updelay")]
424 pub fn connect_bond_updelay_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
425 unsafe extern "C" fn notify_bond_updelay_trampoline<F: Fn(&SettingOvsPort) + 'static>(
426 this: *mut ffi::NMSettingOvsPort,
427 _param_spec: glib::ffi::gpointer,
428 f: glib::ffi::gpointer,
429 ) {
430 let f: &F = &*(f as *const F);
431 f(&from_glib_borrow(this))
432 }
433 unsafe {
434 let f: Box_<F> = Box_::new(f);
435 connect_raw(
436 self.as_ptr() as *mut _,
437 c"notify::bond-updelay".as_ptr() as *const _,
438 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
439 notify_bond_updelay_trampoline::<F> as *const (),
440 )),
441 Box_::into_raw(f),
442 )
443 }
444 }
445
446 #[cfg(feature = "v1_10")]
447 #[cfg_attr(docsrs, doc(cfg(feature = "v1_10")))]
448 #[doc(alias = "lacp")]
449 pub fn connect_lacp_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
450 unsafe extern "C" fn notify_lacp_trampoline<F: Fn(&SettingOvsPort) + 'static>(
451 this: *mut ffi::NMSettingOvsPort,
452 _param_spec: glib::ffi::gpointer,
453 f: glib::ffi::gpointer,
454 ) {
455 let f: &F = &*(f as *const F);
456 f(&from_glib_borrow(this))
457 }
458 unsafe {
459 let f: Box_<F> = Box_::new(f);
460 connect_raw(
461 self.as_ptr() as *mut _,
462 c"notify::lacp".as_ptr() as *const _,
463 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
464 notify_lacp_trampoline::<F> as *const (),
465 )),
466 Box_::into_raw(f),
467 )
468 }
469 }
470
471 #[cfg(feature = "v1_10")]
472 #[cfg_attr(docsrs, doc(cfg(feature = "v1_10")))]
473 #[doc(alias = "tag")]
474 pub fn connect_tag_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
475 unsafe extern "C" fn notify_tag_trampoline<F: Fn(&SettingOvsPort) + 'static>(
476 this: *mut ffi::NMSettingOvsPort,
477 _param_spec: glib::ffi::gpointer,
478 f: glib::ffi::gpointer,
479 ) {
480 let f: &F = &*(f as *const F);
481 f(&from_glib_borrow(this))
482 }
483 unsafe {
484 let f: Box_<F> = Box_::new(f);
485 connect_raw(
486 self.as_ptr() as *mut _,
487 c"notify::tag".as_ptr() as *const _,
488 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
489 notify_tag_trampoline::<F> as *const (),
490 )),
491 Box_::into_raw(f),
492 )
493 }
494 }
495
496 #[cfg(feature = "v1_42")]
497 #[cfg_attr(docsrs, doc(cfg(feature = "v1_42")))]
498 #[doc(alias = "trunks")]
499 pub fn connect_trunks_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
500 unsafe extern "C" fn notify_trunks_trampoline<F: Fn(&SettingOvsPort) + 'static>(
501 this: *mut ffi::NMSettingOvsPort,
502 _param_spec: glib::ffi::gpointer,
503 f: glib::ffi::gpointer,
504 ) {
505 let f: &F = &*(f as *const F);
506 f(&from_glib_borrow(this))
507 }
508 unsafe {
509 let f: Box_<F> = Box_::new(f);
510 connect_raw(
511 self.as_ptr() as *mut _,
512 c"notify::trunks".as_ptr() as *const _,
513 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
514 notify_trunks_trampoline::<F> as *const (),
515 )),
516 Box_::into_raw(f),
517 )
518 }
519 }
520
521 #[cfg(feature = "v1_10")]
522 #[cfg_attr(docsrs, doc(cfg(feature = "v1_10")))]
523 #[doc(alias = "vlan-mode")]
524 pub fn connect_vlan_mode_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
525 unsafe extern "C" fn notify_vlan_mode_trampoline<F: Fn(&SettingOvsPort) + 'static>(
526 this: *mut ffi::NMSettingOvsPort,
527 _param_spec: glib::ffi::gpointer,
528 f: glib::ffi::gpointer,
529 ) {
530 let f: &F = &*(f as *const F);
531 f(&from_glib_borrow(this))
532 }
533 unsafe {
534 let f: Box_<F> = Box_::new(f);
535 connect_raw(
536 self.as_ptr() as *mut _,
537 c"notify::vlan-mode".as_ptr() as *const _,
538 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
539 notify_vlan_mode_trampoline::<F> as *const (),
540 )),
541 Box_::into_raw(f),
542 )
543 }
544 }
545}
546
547#[cfg(feature = "v1_10")]
548#[cfg_attr(docsrs, doc(cfg(feature = "v1_10")))]
549impl Default for SettingOvsPort {
550 fn default() -> Self {
551 Self::new()
552 }
553}
554
555#[must_use = "The builder must be built to be used"]
560pub struct SettingOvsPortBuilder {
561 builder: glib::object::ObjectBuilder<'static, SettingOvsPort>,
562}
563
564impl SettingOvsPortBuilder {
565 fn new() -> Self {
566 Self {
567 builder: glib::object::Object::builder(),
568 }
569 }
570
571 #[cfg(feature = "v1_10")]
573 #[cfg_attr(docsrs, doc(cfg(feature = "v1_10")))]
574 pub fn bond_downdelay(self, bond_downdelay: u32) -> Self {
575 Self {
576 builder: self.builder.property("bond-downdelay", bond_downdelay),
577 }
578 }
579
580 #[cfg(feature = "v1_10")]
582 #[cfg_attr(docsrs, doc(cfg(feature = "v1_10")))]
583 pub fn bond_mode(self, bond_mode: impl Into<glib::GString>) -> Self {
584 Self {
585 builder: self.builder.property("bond-mode", bond_mode.into()),
586 }
587 }
588
589 #[cfg(feature = "v1_10")]
591 #[cfg_attr(docsrs, doc(cfg(feature = "v1_10")))]
592 pub fn bond_updelay(self, bond_updelay: u32) -> Self {
593 Self {
594 builder: self.builder.property("bond-updelay", bond_updelay),
595 }
596 }
597
598 #[cfg(feature = "v1_10")]
600 #[cfg_attr(docsrs, doc(cfg(feature = "v1_10")))]
601 pub fn lacp(self, lacp: impl Into<glib::GString>) -> Self {
602 Self {
603 builder: self.builder.property("lacp", lacp.into()),
604 }
605 }
606
607 #[cfg(feature = "v1_10")]
609 #[cfg_attr(docsrs, doc(cfg(feature = "v1_10")))]
610 pub fn tag(self, tag: u32) -> Self {
611 Self {
612 builder: self.builder.property("tag", tag),
613 }
614 }
615
616 #[cfg(feature = "v1_42")]
622 #[cfg_attr(docsrs, doc(cfg(feature = "v1_42")))]
623 pub fn trunks(self, trunks: &[&Range]) -> Self {
624 Self {
625 builder: self.builder.property(
626 "trunks",
627 trunks
628 .iter()
629 .map(|trunk| trunk.to_value())
630 .collect::<glib::ValueArray>(),
631 ),
632 }
633 }
634
635 #[cfg(feature = "v1_10")]
638 #[cfg_attr(docsrs, doc(cfg(feature = "v1_10")))]
639 pub fn vlan_mode(self, vlan_mode: impl Into<glib::GString>) -> Self {
640 Self {
641 builder: self.builder.property("vlan-mode", vlan_mode.into()),
642 }
643 }
644
645 #[must_use = "Building the object from the builder is usually expensive and is not expected to have side effects"]
648 pub fn build(self) -> SettingOvsPort {
649 assert_initialized_main_thread!();
650 self.builder.build()
651 }
652}