nm-rs 0.1.3

Rust bindings for the libnm library.
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
// This file was generated by gir (https://github.com/gtk-rs/gir)
// from gir
// from gtk-girs (https://github.com/gtk-rs/gir-files)
// DO NOT EDIT

#[cfg(feature = "v1_42")]
#[cfg_attr(docsrs, doc(cfg(feature = "v1_42")))]
use crate::Range;
use crate::{Setting, ffi};
use glib::prelude::*;
#[cfg(feature = "v1_10")]
#[cfg_attr(docsrs, doc(cfg(feature = "v1_10")))]
use glib::{
    signal::{SignalHandlerId, connect_raw},
    translate::*,
};
#[cfg(feature = "v1_10")]
#[cfg_attr(docsrs, doc(cfg(feature = "v1_10")))]
use std::boxed::Box as Box_;

glib::wrapper! {
    /// OvsPort Link Settings
    ///
    /// ## Properties
    ///
    ///
    /// #### `bond-downdelay`
    ///  The time port must be inactive in order to be considered down.
    ///
    /// Readable | Writeable
    ///
    ///
    /// #### `bond-mode`
    ///  Bonding mode. One of "active-backup", "balance-slb", or "balance-tcp".
    ///
    /// Readable | Writeable
    ///
    ///
    /// #### `bond-updelay`
    ///  The time port must be active before it starts forwarding traffic.
    ///
    /// Readable | Writeable
    ///
    ///
    /// #### `lacp`
    ///  LACP mode. One of "active", "off", or "passive".
    ///
    /// Readable | Writeable
    ///
    ///
    /// #### `tag`
    ///  The VLAN tag in the range 0-4095.
    ///
    /// Readable | Writeable
    ///
    ///
    /// #### `trunks`
    ///  A list of VLAN ranges that this port trunks.
    ///
    /// The property is valid only for ports with mode "trunk",
    /// "native-tagged", or "native-untagged port".
    /// If it is empty, the port trunks all VLANs.
    ///
    /// Readable | Writeable
    ///
    ///
    /// #### `vlan-mode`
    ///  The VLAN mode. One of "access", "native-tagged", "native-untagged",
    /// "trunk", "dot1q-tunnel" or unset.
    ///
    /// Readable | Writeable
    /// <details><summary><h4>Setting</h4></summary>
    ///
    ///
    /// #### `name`
    ///  The setting's name, which uniquely identifies the setting within the
    /// connection.  Each setting type has a name unique to that type, for
    /// example "ppp" or "802-11-wireless" or "802-3-ethernet".
    ///
    /// Readable
    /// </details>
    ///
    /// # Implements
    ///
    /// [`SettingExt`][trait@crate::prelude::SettingExt]
    #[doc(alias = "NMSettingOvsPort")]
    pub struct SettingOvsPort(Object<ffi::NMSettingOvsPort, ffi::NMSettingOvsPortClass>) @extends Setting;

    match fn {
        type_ => || ffi::nm_setting_ovs_port_get_type(),
    }
}

impl SettingOvsPort {
    /// Creates a new #NMSettingOvsPort object with default values.
    ///
    /// # Returns
    ///
    /// the new empty #NMSettingOvsPort object
    #[cfg(feature = "v1_10")]
    #[cfg_attr(docsrs, doc(cfg(feature = "v1_10")))]
    #[doc(alias = "nm_setting_ovs_port_new")]
    pub fn new() -> SettingOvsPort {
        assert_initialized_main_thread!();
        unsafe { Setting::from_glib_full(ffi::nm_setting_ovs_port_new()).unsafe_cast() }
    }

    // rustdoc-stripper-ignore-next
    /// Creates a new builder-pattern struct instance to construct [`SettingOvsPort`] objects.
    ///
    /// This method returns an instance of [`SettingOvsPortBuilder`](crate::builders::SettingOvsPortBuilder) which can be used to create [`SettingOvsPort`] objects.
    pub fn builder() -> SettingOvsPortBuilder {
        SettingOvsPortBuilder::new()
    }

    /// Appends a new trunk range to the setting.
    /// This takes a reference to @trunk.
    /// ## `trunk`
    /// the trunk to add
    #[cfg(feature = "v1_42")]
    #[cfg_attr(docsrs, doc(cfg(feature = "v1_42")))]
    #[doc(alias = "nm_setting_ovs_port_add_trunk")]
    pub fn add_trunk(&self, trunk: &Range) {
        unsafe {
            ffi::nm_setting_ovs_port_add_trunk(self.to_glib_none().0, trunk.to_glib_none().0);
        }
    }

    /// Removes all configured trunk ranges.
    #[cfg(feature = "v1_42")]
    #[cfg_attr(docsrs, doc(cfg(feature = "v1_42")))]
    #[doc(alias = "nm_setting_ovs_port_clear_trunks")]
    pub fn clear_trunks(&self) {
        unsafe {
            ffi::nm_setting_ovs_port_clear_trunks(self.to_glib_none().0);
        }
    }

    ///
    /// # Returns
    ///
    /// the #NMSettingOvsPort:bond-downdelay property of the setting
    #[cfg(feature = "v1_10")]
    #[cfg_attr(docsrs, doc(cfg(feature = "v1_10")))]
    #[doc(alias = "nm_setting_ovs_port_get_bond_downdelay")]
    #[doc(alias = "get_bond_downdelay")]
    #[doc(alias = "bond-downdelay")]
    pub fn bond_downdelay(&self) -> u32 {
        unsafe { ffi::nm_setting_ovs_port_get_bond_downdelay(self.to_glib_none().0) }
    }

    ///
    /// # Returns
    ///
    /// the #NMSettingOvsPort:bond-mode property of the setting
    #[cfg(feature = "v1_10")]
    #[cfg_attr(docsrs, doc(cfg(feature = "v1_10")))]
    #[doc(alias = "nm_setting_ovs_port_get_bond_mode")]
    #[doc(alias = "get_bond_mode")]
    #[doc(alias = "bond-mode")]
    pub fn bond_mode(&self) -> glib::GString {
        unsafe {
            from_glib_none(ffi::nm_setting_ovs_port_get_bond_mode(
                self.to_glib_none().0,
            ))
        }
    }

    ///
    /// # Returns
    ///
    /// the #NMSettingOvsPort:bond-updelay property of the setting
    #[cfg(feature = "v1_10")]
    #[cfg_attr(docsrs, doc(cfg(feature = "v1_10")))]
    #[doc(alias = "nm_setting_ovs_port_get_bond_updelay")]
    #[doc(alias = "get_bond_updelay")]
    #[doc(alias = "bond-updelay")]
    pub fn bond_updelay(&self) -> u32 {
        unsafe { ffi::nm_setting_ovs_port_get_bond_updelay(self.to_glib_none().0) }
    }

    ///
    /// # Returns
    ///
    /// the #NMSettingOvsPort:lacp property of the setting
    #[cfg(feature = "v1_10")]
    #[cfg_attr(docsrs, doc(cfg(feature = "v1_10")))]
    #[doc(alias = "nm_setting_ovs_port_get_lacp")]
    #[doc(alias = "get_lacp")]
    pub fn lacp(&self) -> glib::GString {
        unsafe { from_glib_none(ffi::nm_setting_ovs_port_get_lacp(self.to_glib_none().0)) }
    }

    ///
    /// # Returns
    ///
    /// the number of trunk ranges
    #[cfg(feature = "v1_42")]
    #[cfg_attr(docsrs, doc(cfg(feature = "v1_42")))]
    #[doc(alias = "nm_setting_ovs_port_get_num_trunks")]
    #[doc(alias = "get_num_trunks")]
    pub fn num_trunks(&self) -> u32 {
        unsafe { ffi::nm_setting_ovs_port_get_num_trunks(self.to_glib_none().0) }
    }

    ///
    /// # Returns
    ///
    /// the #NMSettingOvsPort:tag property of the setting
    #[cfg(feature = "v1_10")]
    #[cfg_attr(docsrs, doc(cfg(feature = "v1_10")))]
    #[doc(alias = "nm_setting_ovs_port_get_tag")]
    #[doc(alias = "get_tag")]
    pub fn tag(&self) -> u32 {
        unsafe { ffi::nm_setting_ovs_port_get_tag(self.to_glib_none().0) }
    }

    /// ## `idx`
    /// index number of the trunk range to return
    ///
    /// # Returns
    ///
    /// the trunk range at index @idx
    #[cfg(feature = "v1_42")]
    #[cfg_attr(docsrs, doc(cfg(feature = "v1_42")))]
    #[doc(alias = "nm_setting_ovs_port_get_trunk")]
    #[doc(alias = "get_trunk")]
    pub fn trunk(&self, idx: u32) -> Range {
        unsafe {
            from_glib_none(ffi::nm_setting_ovs_port_get_trunk(
                self.to_glib_none().0,
                idx,
            ))
        }
    }

    ///
    /// # Returns
    ///
    /// the #NMSettingOvsPort:vlan-mode property of the setting
    #[cfg(feature = "v1_10")]
    #[cfg_attr(docsrs, doc(cfg(feature = "v1_10")))]
    #[doc(alias = "nm_setting_ovs_port_get_vlan_mode")]
    #[doc(alias = "get_vlan_mode")]
    #[doc(alias = "vlan-mode")]
    pub fn vlan_mode(&self) -> glib::GString {
        unsafe {
            from_glib_none(ffi::nm_setting_ovs_port_get_vlan_mode(
                self.to_glib_none().0,
            ))
        }
    }

    /// Removes the trunk range at index @idx.
    /// ## `idx`
    /// index number of the trunk range.
    #[cfg(feature = "v1_42")]
    #[cfg_attr(docsrs, doc(cfg(feature = "v1_42")))]
    #[doc(alias = "nm_setting_ovs_port_remove_trunk")]
    pub fn remove_trunk(&self, idx: u32) {
        unsafe {
            ffi::nm_setting_ovs_port_remove_trunk(self.to_glib_none().0, idx);
        }
    }

    /// Remove the trunk range with range @start to @end.
    /// ## `start`
    /// the trunk range start index
    /// ## `end`
    /// the trunk range end index
    ///
    /// # Returns
    ///
    /// [`true`] if the trunk range was found and removed; [`false`] otherwise
    #[cfg(feature = "v1_42")]
    #[cfg_attr(docsrs, doc(cfg(feature = "v1_42")))]
    #[doc(alias = "nm_setting_ovs_port_remove_trunk_by_value")]
    pub fn remove_trunk_by_value(&self, start: u32, end: u32) -> bool {
        unsafe {
            from_glib(ffi::nm_setting_ovs_port_remove_trunk_by_value(
                self.to_glib_none().0,
                start,
                end,
            ))
        }
    }

    /// The time port must be inactive in order to be considered down.
    #[cfg(feature = "v1_10")]
    #[cfg_attr(docsrs, doc(cfg(feature = "v1_10")))]
    #[doc(alias = "bond-downdelay")]
    pub fn set_bond_downdelay(&self, bond_downdelay: u32) {
        ObjectExt::set_property(self, "bond-downdelay", bond_downdelay)
    }

    /// Bonding mode. One of "active-backup", "balance-slb", or "balance-tcp".
    #[cfg(feature = "v1_10")]
    #[cfg_attr(docsrs, doc(cfg(feature = "v1_10")))]
    #[doc(alias = "bond-mode")]
    pub fn set_bond_mode(&self, bond_mode: Option<&str>) {
        ObjectExt::set_property(self, "bond-mode", bond_mode)
    }

    /// The time port must be active before it starts forwarding traffic.
    #[cfg(feature = "v1_10")]
    #[cfg_attr(docsrs, doc(cfg(feature = "v1_10")))]
    #[doc(alias = "bond-updelay")]
    pub fn set_bond_updelay(&self, bond_updelay: u32) {
        ObjectExt::set_property(self, "bond-updelay", bond_updelay)
    }

    /// LACP mode. One of "active", "off", or "passive".
    #[cfg(feature = "v1_10")]
    #[cfg_attr(docsrs, doc(cfg(feature = "v1_10")))]
    pub fn set_lacp(&self, lacp: Option<&str>) {
        ObjectExt::set_property(self, "lacp", lacp)
    }

    /// The VLAN tag in the range 0-4095.
    #[cfg(feature = "v1_10")]
    #[cfg_attr(docsrs, doc(cfg(feature = "v1_10")))]
    pub fn set_tag(&self, tag: u32) {
        ObjectExt::set_property(self, "tag", tag)
    }

    /// A list of VLAN ranges that this port trunks.
    ///
    /// The property is valid only for ports with mode "trunk",
    /// "native-tagged", or "native-untagged port".
    /// If it is empty, the port trunks all VLANs.
    #[cfg(feature = "v1_42")]
    #[cfg_attr(docsrs, doc(cfg(feature = "v1_42")))]
    pub fn trunks(&self) -> Vec<Range> {
        let vals = ObjectExt::property::<glib::ValueArray>(self, "trunks");
        vals.iter()
            .map(|value| {
                use glib::value::FromValue;

                unsafe { Range::from_value(value) }
            })
            .collect()
    }

    /// A list of VLAN ranges that this port trunks.
    ///
    /// The property is valid only for ports with mode "trunk",
    /// "native-tagged", or "native-untagged port".
    /// If it is empty, the port trunks all VLANs.
    #[cfg(feature = "v1_42")]
    #[cfg_attr(docsrs, doc(cfg(feature = "v1_42")))]
    pub fn set_trunks(&self, trunks: &[&Range]) {
        ObjectExt::set_property(
            self,
            "trunks",
            trunks
                .iter()
                .map(|trunk| trunk.to_value())
                .collect::<glib::ValueArray>(),
        )
    }

    /// The VLAN mode. One of "access", "native-tagged", "native-untagged",
    /// "trunk", "dot1q-tunnel" or unset.
    #[cfg(feature = "v1_10")]
    #[cfg_attr(docsrs, doc(cfg(feature = "v1_10")))]
    #[doc(alias = "vlan-mode")]
    pub fn set_vlan_mode(&self, vlan_mode: Option<&str>) {
        ObjectExt::set_property(self, "vlan-mode", vlan_mode)
    }

    #[cfg(feature = "v1_10")]
    #[cfg_attr(docsrs, doc(cfg(feature = "v1_10")))]
    #[doc(alias = "bond-downdelay")]
    pub fn connect_bond_downdelay_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
        unsafe extern "C" fn notify_bond_downdelay_trampoline<F: Fn(&SettingOvsPort) + 'static>(
            this: *mut ffi::NMSettingOvsPort,
            _param_spec: glib::ffi::gpointer,
            f: glib::ffi::gpointer,
        ) {
            let f: &F = &*(f as *const F);
            f(&from_glib_borrow(this))
        }
        unsafe {
            let f: Box_<F> = Box_::new(f);
            connect_raw(
                self.as_ptr() as *mut _,
                c"notify::bond-downdelay".as_ptr() as *const _,
                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
                    notify_bond_downdelay_trampoline::<F> as *const (),
                )),
                Box_::into_raw(f),
            )
        }
    }

    #[cfg(feature = "v1_10")]
    #[cfg_attr(docsrs, doc(cfg(feature = "v1_10")))]
    #[doc(alias = "bond-mode")]
    pub fn connect_bond_mode_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
        unsafe extern "C" fn notify_bond_mode_trampoline<F: Fn(&SettingOvsPort) + 'static>(
            this: *mut ffi::NMSettingOvsPort,
            _param_spec: glib::ffi::gpointer,
            f: glib::ffi::gpointer,
        ) {
            let f: &F = &*(f as *const F);
            f(&from_glib_borrow(this))
        }
        unsafe {
            let f: Box_<F> = Box_::new(f);
            connect_raw(
                self.as_ptr() as *mut _,
                c"notify::bond-mode".as_ptr() as *const _,
                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
                    notify_bond_mode_trampoline::<F> as *const (),
                )),
                Box_::into_raw(f),
            )
        }
    }

    #[cfg(feature = "v1_10")]
    #[cfg_attr(docsrs, doc(cfg(feature = "v1_10")))]
    #[doc(alias = "bond-updelay")]
    pub fn connect_bond_updelay_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
        unsafe extern "C" fn notify_bond_updelay_trampoline<F: Fn(&SettingOvsPort) + 'static>(
            this: *mut ffi::NMSettingOvsPort,
            _param_spec: glib::ffi::gpointer,
            f: glib::ffi::gpointer,
        ) {
            let f: &F = &*(f as *const F);
            f(&from_glib_borrow(this))
        }
        unsafe {
            let f: Box_<F> = Box_::new(f);
            connect_raw(
                self.as_ptr() as *mut _,
                c"notify::bond-updelay".as_ptr() as *const _,
                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
                    notify_bond_updelay_trampoline::<F> as *const (),
                )),
                Box_::into_raw(f),
            )
        }
    }

    #[cfg(feature = "v1_10")]
    #[cfg_attr(docsrs, doc(cfg(feature = "v1_10")))]
    #[doc(alias = "lacp")]
    pub fn connect_lacp_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
        unsafe extern "C" fn notify_lacp_trampoline<F: Fn(&SettingOvsPort) + 'static>(
            this: *mut ffi::NMSettingOvsPort,
            _param_spec: glib::ffi::gpointer,
            f: glib::ffi::gpointer,
        ) {
            let f: &F = &*(f as *const F);
            f(&from_glib_borrow(this))
        }
        unsafe {
            let f: Box_<F> = Box_::new(f);
            connect_raw(
                self.as_ptr() as *mut _,
                c"notify::lacp".as_ptr() as *const _,
                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
                    notify_lacp_trampoline::<F> as *const (),
                )),
                Box_::into_raw(f),
            )
        }
    }

    #[cfg(feature = "v1_10")]
    #[cfg_attr(docsrs, doc(cfg(feature = "v1_10")))]
    #[doc(alias = "tag")]
    pub fn connect_tag_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
        unsafe extern "C" fn notify_tag_trampoline<F: Fn(&SettingOvsPort) + 'static>(
            this: *mut ffi::NMSettingOvsPort,
            _param_spec: glib::ffi::gpointer,
            f: glib::ffi::gpointer,
        ) {
            let f: &F = &*(f as *const F);
            f(&from_glib_borrow(this))
        }
        unsafe {
            let f: Box_<F> = Box_::new(f);
            connect_raw(
                self.as_ptr() as *mut _,
                c"notify::tag".as_ptr() as *const _,
                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
                    notify_tag_trampoline::<F> as *const (),
                )),
                Box_::into_raw(f),
            )
        }
    }

    #[cfg(feature = "v1_42")]
    #[cfg_attr(docsrs, doc(cfg(feature = "v1_42")))]
    #[doc(alias = "trunks")]
    pub fn connect_trunks_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
        unsafe extern "C" fn notify_trunks_trampoline<F: Fn(&SettingOvsPort) + 'static>(
            this: *mut ffi::NMSettingOvsPort,
            _param_spec: glib::ffi::gpointer,
            f: glib::ffi::gpointer,
        ) {
            let f: &F = &*(f as *const F);
            f(&from_glib_borrow(this))
        }
        unsafe {
            let f: Box_<F> = Box_::new(f);
            connect_raw(
                self.as_ptr() as *mut _,
                c"notify::trunks".as_ptr() as *const _,
                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
                    notify_trunks_trampoline::<F> as *const (),
                )),
                Box_::into_raw(f),
            )
        }
    }

    #[cfg(feature = "v1_10")]
    #[cfg_attr(docsrs, doc(cfg(feature = "v1_10")))]
    #[doc(alias = "vlan-mode")]
    pub fn connect_vlan_mode_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
        unsafe extern "C" fn notify_vlan_mode_trampoline<F: Fn(&SettingOvsPort) + 'static>(
            this: *mut ffi::NMSettingOvsPort,
            _param_spec: glib::ffi::gpointer,
            f: glib::ffi::gpointer,
        ) {
            let f: &F = &*(f as *const F);
            f(&from_glib_borrow(this))
        }
        unsafe {
            let f: Box_<F> = Box_::new(f);
            connect_raw(
                self.as_ptr() as *mut _,
                c"notify::vlan-mode".as_ptr() as *const _,
                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
                    notify_vlan_mode_trampoline::<F> as *const (),
                )),
                Box_::into_raw(f),
            )
        }
    }
}

#[cfg(feature = "v1_10")]
#[cfg_attr(docsrs, doc(cfg(feature = "v1_10")))]
impl Default for SettingOvsPort {
    fn default() -> Self {
        Self::new()
    }
}

// rustdoc-stripper-ignore-next
/// A [builder-pattern] type to construct [`SettingOvsPort`] objects.
///
/// [builder-pattern]: https://doc.rust-lang.org/1.0.0/style/ownership/builders.html
#[must_use = "The builder must be built to be used"]
pub struct SettingOvsPortBuilder {
    builder: glib::object::ObjectBuilder<'static, SettingOvsPort>,
}

impl SettingOvsPortBuilder {
    fn new() -> Self {
        Self {
            builder: glib::object::Object::builder(),
        }
    }

    /// The time port must be inactive in order to be considered down.
    #[cfg(feature = "v1_10")]
    #[cfg_attr(docsrs, doc(cfg(feature = "v1_10")))]
    pub fn bond_downdelay(self, bond_downdelay: u32) -> Self {
        Self {
            builder: self.builder.property("bond-downdelay", bond_downdelay),
        }
    }

    /// Bonding mode. One of "active-backup", "balance-slb", or "balance-tcp".
    #[cfg(feature = "v1_10")]
    #[cfg_attr(docsrs, doc(cfg(feature = "v1_10")))]
    pub fn bond_mode(self, bond_mode: impl Into<glib::GString>) -> Self {
        Self {
            builder: self.builder.property("bond-mode", bond_mode.into()),
        }
    }

    /// The time port must be active before it starts forwarding traffic.
    #[cfg(feature = "v1_10")]
    #[cfg_attr(docsrs, doc(cfg(feature = "v1_10")))]
    pub fn bond_updelay(self, bond_updelay: u32) -> Self {
        Self {
            builder: self.builder.property("bond-updelay", bond_updelay),
        }
    }

    /// LACP mode. One of "active", "off", or "passive".
    #[cfg(feature = "v1_10")]
    #[cfg_attr(docsrs, doc(cfg(feature = "v1_10")))]
    pub fn lacp(self, lacp: impl Into<glib::GString>) -> Self {
        Self {
            builder: self.builder.property("lacp", lacp.into()),
        }
    }

    /// The VLAN tag in the range 0-4095.
    #[cfg(feature = "v1_10")]
    #[cfg_attr(docsrs, doc(cfg(feature = "v1_10")))]
    pub fn tag(self, tag: u32) -> Self {
        Self {
            builder: self.builder.property("tag", tag),
        }
    }

    /// A list of VLAN ranges that this port trunks.
    ///
    /// The property is valid only for ports with mode "trunk",
    /// "native-tagged", or "native-untagged port".
    /// If it is empty, the port trunks all VLANs.
    #[cfg(feature = "v1_42")]
    #[cfg_attr(docsrs, doc(cfg(feature = "v1_42")))]
    pub fn trunks(self, trunks: &[&Range]) -> Self {
        Self {
            builder: self.builder.property(
                "trunks",
                trunks
                    .iter()
                    .map(|trunk| trunk.to_value())
                    .collect::<glib::ValueArray>(),
            ),
        }
    }

    /// The VLAN mode. One of "access", "native-tagged", "native-untagged",
    /// "trunk", "dot1q-tunnel" or unset.
    #[cfg(feature = "v1_10")]
    #[cfg_attr(docsrs, doc(cfg(feature = "v1_10")))]
    pub fn vlan_mode(self, vlan_mode: impl Into<glib::GString>) -> Self {
        Self {
            builder: self.builder.property("vlan-mode", vlan_mode.into()),
        }
    }

    // rustdoc-stripper-ignore-next
    /// Build the [`SettingOvsPort`].
    #[must_use = "Building the object from the builder is usually expensive and is not expected to have side effects"]
    pub fn build(self) -> SettingOvsPort {
        assert_initialized_main_thread!();
        self.builder.build()
    }
}