1#[cfg(feature = "v1_12")]
7#[cfg_attr(docsrs, doc(cfg(feature = "v1_12")))]
8use crate::TeamLinkWatcher;
9use crate::{Setting, ffi};
10use glib::{
11 prelude::*,
12 signal::{SignalHandlerId, connect_raw},
13 translate::*,
14};
15use std::boxed::Box as Box_;
16
17glib::wrapper! {
18 #[doc(alias = "NMSettingTeamPort")]
89 pub struct SettingTeamPort(Object<ffi::NMSettingTeamPort, ffi::NMSettingTeamPortClass>) @extends Setting;
90
91 match fn {
92 type_ => || ffi::nm_setting_team_port_get_type(),
93 }
94}
95
96impl SettingTeamPort {
97 #[doc(alias = "nm_setting_team_port_new")]
103 pub fn new() -> SettingTeamPort {
104 assert_initialized_main_thread!();
105 unsafe { Setting::from_glib_full(ffi::nm_setting_team_port_new()).unsafe_cast() }
106 }
107
108 pub fn builder() -> SettingTeamPortBuilder {
113 SettingTeamPortBuilder::new()
114 }
115
116 #[cfg(feature = "v1_12")]
125 #[cfg_attr(docsrs, doc(cfg(feature = "v1_12")))]
126 #[doc(alias = "nm_setting_team_port_add_link_watcher")]
127 pub fn add_link_watcher(&self, link_watcher: &TeamLinkWatcher) -> bool {
128 unsafe {
129 from_glib(ffi::nm_setting_team_port_add_link_watcher(
130 self.to_glib_none().0,
131 link_watcher.to_glib_none().0,
132 ))
133 }
134 }
135
136 #[cfg(feature = "v1_12")]
138 #[cfg_attr(docsrs, doc(cfg(feature = "v1_12")))]
139 #[doc(alias = "nm_setting_team_port_clear_link_watchers")]
140 pub fn clear_link_watchers(&self) {
141 unsafe {
142 ffi::nm_setting_team_port_clear_link_watchers(self.to_glib_none().0);
143 }
144 }
145
146 #[doc(alias = "nm_setting_team_port_get_config")]
151 #[doc(alias = "get_config")]
152 pub fn config(&self) -> glib::GString {
153 unsafe { from_glib_none(ffi::nm_setting_team_port_get_config(self.to_glib_none().0)) }
154 }
155
156 #[cfg(feature = "v1_12")]
161 #[cfg_attr(docsrs, doc(cfg(feature = "v1_12")))]
162 #[doc(alias = "nm_setting_team_port_get_lacp_key")]
163 #[doc(alias = "get_lacp_key")]
164 #[doc(alias = "lacp-key")]
165 pub fn lacp_key(&self) -> i32 {
166 unsafe { ffi::nm_setting_team_port_get_lacp_key(self.to_glib_none().0) }
167 }
168
169 #[cfg(feature = "v1_12")]
174 #[cfg_attr(docsrs, doc(cfg(feature = "v1_12")))]
175 #[doc(alias = "nm_setting_team_port_get_lacp_prio")]
176 #[doc(alias = "get_lacp_prio")]
177 #[doc(alias = "lacp-prio")]
178 pub fn lacp_prio(&self) -> i32 {
179 unsafe { ffi::nm_setting_team_port_get_lacp_prio(self.to_glib_none().0) }
180 }
181
182 #[cfg(feature = "v1_12")]
189 #[cfg_attr(docsrs, doc(cfg(feature = "v1_12")))]
190 #[doc(alias = "nm_setting_team_port_get_link_watcher")]
191 #[doc(alias = "get_link_watcher")]
192 pub fn link_watcher(&self, idx: u32) -> TeamLinkWatcher {
193 unsafe {
194 from_glib_none(ffi::nm_setting_team_port_get_link_watcher(
195 self.to_glib_none().0,
196 idx,
197 ))
198 }
199 }
200
201 #[cfg(feature = "v1_12")]
206 #[cfg_attr(docsrs, doc(cfg(feature = "v1_12")))]
207 #[doc(alias = "nm_setting_team_port_get_num_link_watchers")]
208 #[doc(alias = "get_num_link_watchers")]
209 pub fn num_link_watchers(&self) -> u32 {
210 unsafe { ffi::nm_setting_team_port_get_num_link_watchers(self.to_glib_none().0) }
211 }
212
213 #[cfg(feature = "v1_12")]
218 #[cfg_attr(docsrs, doc(cfg(feature = "v1_12")))]
219 #[doc(alias = "nm_setting_team_port_get_prio")]
220 #[doc(alias = "get_prio")]
221 pub fn prio(&self) -> i32 {
222 unsafe { ffi::nm_setting_team_port_get_prio(self.to_glib_none().0) }
223 }
224
225 #[cfg(feature = "v1_12")]
230 #[cfg_attr(docsrs, doc(cfg(feature = "v1_12")))]
231 #[doc(alias = "nm_setting_team_port_get_queue_id")]
232 #[doc(alias = "get_queue_id")]
233 #[doc(alias = "queue-id")]
234 pub fn queue_id(&self) -> i32 {
235 unsafe { ffi::nm_setting_team_port_get_queue_id(self.to_glib_none().0) }
236 }
237
238 #[cfg(feature = "v1_12")]
243 #[cfg_attr(docsrs, doc(cfg(feature = "v1_12")))]
244 #[doc(alias = "nm_setting_team_port_get_sticky")]
245 #[doc(alias = "get_sticky")]
246 #[doc(alias = "sticky")]
247 pub fn is_sticky(&self) -> bool {
248 unsafe { from_glib(ffi::nm_setting_team_port_get_sticky(self.to_glib_none().0)) }
249 }
250
251 #[cfg(feature = "v1_12")]
255 #[cfg_attr(docsrs, doc(cfg(feature = "v1_12")))]
256 #[doc(alias = "nm_setting_team_port_remove_link_watcher")]
257 pub fn remove_link_watcher(&self, idx: u32) {
258 unsafe {
259 ffi::nm_setting_team_port_remove_link_watcher(self.to_glib_none().0, idx);
260 }
261 }
262
263 #[cfg(feature = "v1_12")]
271 #[cfg_attr(docsrs, doc(cfg(feature = "v1_12")))]
272 #[doc(alias = "nm_setting_team_port_remove_link_watcher_by_value")]
273 pub fn remove_link_watcher_by_value(&self, link_watcher: &TeamLinkWatcher) -> bool {
274 unsafe {
275 from_glib(ffi::nm_setting_team_port_remove_link_watcher_by_value(
276 self.to_glib_none().0,
277 link_watcher.to_glib_none().0,
278 ))
279 }
280 }
281
282 pub fn set_config(&self, config: Option<&str>) {
287 ObjectExt::set_property(self, "config", config)
288 }
289
290 #[cfg(feature = "v1_12")]
292 #[cfg_attr(docsrs, doc(cfg(feature = "v1_12")))]
293 #[doc(alias = "lacp-key")]
294 pub fn set_lacp_key(&self, lacp_key: i32) {
295 ObjectExt::set_property(self, "lacp-key", lacp_key)
296 }
297
298 #[cfg(feature = "v1_12")]
300 #[cfg_attr(docsrs, doc(cfg(feature = "v1_12")))]
301 #[doc(alias = "lacp-prio")]
302 pub fn set_lacp_prio(&self, lacp_prio: i32) {
303 ObjectExt::set_property(self, "lacp-prio", lacp_prio)
304 }
305
306 #[cfg(feature = "v1_12")]
315 #[cfg_attr(docsrs, doc(cfg(feature = "v1_12")))]
316 #[doc(alias = "link-watchers")]
317 pub fn link_watchers(&self) -> Vec<TeamLinkWatcher> {
318 let vals = ObjectExt::property::<glib::ValueArray>(self, "link-watchers");
319 vals.iter()
320 .map(|value| {
321 use glib::value::FromValue;
322
323 unsafe { TeamLinkWatcher::from_value(value) }
324 })
325 .collect()
326 }
327
328 #[cfg(feature = "v1_12")]
337 #[cfg_attr(docsrs, doc(cfg(feature = "v1_12")))]
338 #[doc(alias = "link-watchers")]
339 pub fn set_link_watchers(&self, link_watchers: &[&TeamLinkWatcher]) {
340 ObjectExt::set_property(
341 self,
342 "link-watchers",
343 link_watchers
344 .iter()
345 .map(|team_link_watcher| team_link_watcher.to_value())
346 .collect::<glib::ValueArray>(),
347 )
348 }
349
350 #[cfg(feature = "v1_12")]
352 #[cfg_attr(docsrs, doc(cfg(feature = "v1_12")))]
353 pub fn set_prio(&self, prio: i32) {
354 ObjectExt::set_property(self, "prio", prio)
355 }
356
357 #[cfg(feature = "v1_12")]
360 #[cfg_attr(docsrs, doc(cfg(feature = "v1_12")))]
361 #[doc(alias = "queue-id")]
362 pub fn set_queue_id(&self, queue_id: i32) {
363 ObjectExt::set_property(self, "queue-id", queue_id)
364 }
365
366 #[cfg(feature = "v1_12")]
368 #[cfg_attr(docsrs, doc(cfg(feature = "v1_12")))]
369 pub fn set_sticky(&self, sticky: bool) {
370 ObjectExt::set_property(self, "sticky", sticky)
371 }
372
373 #[doc(alias = "config")]
374 pub fn connect_config_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
375 unsafe extern "C" fn notify_config_trampoline<F: Fn(&SettingTeamPort) + 'static>(
376 this: *mut ffi::NMSettingTeamPort,
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::config".as_ptr() as *const _,
388 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
389 notify_config_trampoline::<F> as *const (),
390 )),
391 Box_::into_raw(f),
392 )
393 }
394 }
395
396 #[cfg(feature = "v1_12")]
397 #[cfg_attr(docsrs, doc(cfg(feature = "v1_12")))]
398 #[doc(alias = "lacp-key")]
399 pub fn connect_lacp_key_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
400 unsafe extern "C" fn notify_lacp_key_trampoline<F: Fn(&SettingTeamPort) + 'static>(
401 this: *mut ffi::NMSettingTeamPort,
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::lacp-key".as_ptr() as *const _,
413 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
414 notify_lacp_key_trampoline::<F> as *const (),
415 )),
416 Box_::into_raw(f),
417 )
418 }
419 }
420
421 #[cfg(feature = "v1_12")]
422 #[cfg_attr(docsrs, doc(cfg(feature = "v1_12")))]
423 #[doc(alias = "lacp-prio")]
424 pub fn connect_lacp_prio_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
425 unsafe extern "C" fn notify_lacp_prio_trampoline<F: Fn(&SettingTeamPort) + 'static>(
426 this: *mut ffi::NMSettingTeamPort,
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::lacp-prio".as_ptr() as *const _,
438 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
439 notify_lacp_prio_trampoline::<F> as *const (),
440 )),
441 Box_::into_raw(f),
442 )
443 }
444 }
445
446 #[cfg(feature = "v1_12")]
447 #[cfg_attr(docsrs, doc(cfg(feature = "v1_12")))]
448 #[doc(alias = "link-watchers")]
449 pub fn connect_link_watchers_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
450 unsafe extern "C" fn notify_link_watchers_trampoline<F: Fn(&SettingTeamPort) + 'static>(
451 this: *mut ffi::NMSettingTeamPort,
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::link-watchers".as_ptr() as *const _,
463 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
464 notify_link_watchers_trampoline::<F> as *const (),
465 )),
466 Box_::into_raw(f),
467 )
468 }
469 }
470
471 #[cfg(feature = "v1_12")]
472 #[cfg_attr(docsrs, doc(cfg(feature = "v1_12")))]
473 #[doc(alias = "prio")]
474 pub fn connect_prio_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
475 unsafe extern "C" fn notify_prio_trampoline<F: Fn(&SettingTeamPort) + 'static>(
476 this: *mut ffi::NMSettingTeamPort,
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::prio".as_ptr() as *const _,
488 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
489 notify_prio_trampoline::<F> as *const (),
490 )),
491 Box_::into_raw(f),
492 )
493 }
494 }
495
496 #[cfg(feature = "v1_12")]
497 #[cfg_attr(docsrs, doc(cfg(feature = "v1_12")))]
498 #[doc(alias = "queue-id")]
499 pub fn connect_queue_id_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
500 unsafe extern "C" fn notify_queue_id_trampoline<F: Fn(&SettingTeamPort) + 'static>(
501 this: *mut ffi::NMSettingTeamPort,
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::queue-id".as_ptr() as *const _,
513 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
514 notify_queue_id_trampoline::<F> as *const (),
515 )),
516 Box_::into_raw(f),
517 )
518 }
519 }
520
521 #[cfg(feature = "v1_12")]
522 #[cfg_attr(docsrs, doc(cfg(feature = "v1_12")))]
523 #[doc(alias = "sticky")]
524 pub fn connect_sticky_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
525 unsafe extern "C" fn notify_sticky_trampoline<F: Fn(&SettingTeamPort) + 'static>(
526 this: *mut ffi::NMSettingTeamPort,
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::sticky".as_ptr() as *const _,
538 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
539 notify_sticky_trampoline::<F> as *const (),
540 )),
541 Box_::into_raw(f),
542 )
543 }
544 }
545}
546
547impl Default for SettingTeamPort {
548 fn default() -> Self {
549 Self::new()
550 }
551}
552
553#[must_use = "The builder must be built to be used"]
558pub struct SettingTeamPortBuilder {
559 builder: glib::object::ObjectBuilder<'static, SettingTeamPort>,
560}
561
562impl SettingTeamPortBuilder {
563 fn new() -> Self {
564 Self {
565 builder: glib::object::Object::builder(),
566 }
567 }
568
569 pub fn config(self, config: impl Into<glib::GString>) -> Self {
574 Self {
575 builder: self.builder.property("config", config.into()),
576 }
577 }
578
579 #[cfg(feature = "v1_12")]
581 #[cfg_attr(docsrs, doc(cfg(feature = "v1_12")))]
582 pub fn lacp_key(self, lacp_key: i32) -> Self {
583 Self {
584 builder: self.builder.property("lacp-key", lacp_key),
585 }
586 }
587
588 #[cfg(feature = "v1_12")]
590 #[cfg_attr(docsrs, doc(cfg(feature = "v1_12")))]
591 pub fn lacp_prio(self, lacp_prio: i32) -> Self {
592 Self {
593 builder: self.builder.property("lacp-prio", lacp_prio),
594 }
595 }
596
597 #[cfg(feature = "v1_12")]
606 #[cfg_attr(docsrs, doc(cfg(feature = "v1_12")))]
607 pub fn link_watchers(self, link_watchers: &[&TeamLinkWatcher]) -> Self {
608 Self {
609 builder: self.builder.property(
610 "link-watchers",
611 link_watchers
612 .iter()
613 .map(|team_link_watcher| team_link_watcher.to_value())
614 .collect::<glib::ValueArray>(),
615 ),
616 }
617 }
618
619 #[cfg(feature = "v1_12")]
621 #[cfg_attr(docsrs, doc(cfg(feature = "v1_12")))]
622 pub fn prio(self, prio: i32) -> Self {
623 Self {
624 builder: self.builder.property("prio", prio),
625 }
626 }
627
628 #[cfg(feature = "v1_12")]
631 #[cfg_attr(docsrs, doc(cfg(feature = "v1_12")))]
632 pub fn queue_id(self, queue_id: i32) -> Self {
633 Self {
634 builder: self.builder.property("queue-id", queue_id),
635 }
636 }
637
638 #[cfg(feature = "v1_12")]
640 #[cfg_attr(docsrs, doc(cfg(feature = "v1_12")))]
641 pub fn sticky(self, sticky: bool) -> Self {
642 Self {
643 builder: self.builder.property("sticky", sticky),
644 }
645 }
646
647 #[must_use = "Building the object from the builder is usually expensive and is not expected to have side effects"]
650 pub fn build(self) -> SettingTeamPort {
651 assert_initialized_main_thread!();
652 self.builder.build()
653 }
654}