1use crate::{ffi};
7#[cfg(feature = "v1_12")]
8#[cfg_attr(docsrs, doc(cfg(feature = "v1_12")))]
9use glib::{translate::*};
10
11glib::wrapper! {
12 #[derive(Debug, PartialOrd, Ord, Hash)]
13 pub struct TCAction(Shared<ffi::NMTCAction>);
14
15 match fn {
16 ref => |ptr| ffi::nm_tc_action_ref(ptr),
17 unref => |ptr| ffi::nm_tc_action_unref(ptr),
18 type_ => || ffi::nm_tc_action_get_type(),
19 }
20}
21
22impl TCAction {
23 #[cfg(feature = "v1_12")]
31 #[cfg_attr(docsrs, doc(cfg(feature = "v1_12")))]
32 #[doc(alias = "nm_tc_action_new")]
33 pub fn new(kind: &str) -> Result<TCAction, glib::Error> {
34 assert_initialized_main_thread!();
35 unsafe {
36 let mut error = std::ptr::null_mut();
37 let ret = ffi::nm_tc_action_new(kind.to_glib_none().0, &mut error);
38 if error.is_null() { Ok(from_glib_full(ret)) } else { Err(from_glib_full(error)) }
39 }
40 }
41
42 #[cfg(feature = "v1_12")]
48 #[cfg_attr(docsrs, doc(cfg(feature = "v1_12")))]
49 #[doc(alias = "nm_tc_action_dup")]
50#[must_use]
51 pub fn dup(&self) -> TCAction {
52 unsafe {
53 from_glib_full(ffi::nm_tc_action_dup(self.to_glib_none().0))
54 }
55 }
56
57 #[cfg(feature = "v1_12")]
58 #[cfg_attr(docsrs, doc(cfg(feature = "v1_12")))]
59 #[doc(alias = "nm_tc_action_equal")]
60 fn equal(&self, other: &TCAction) -> bool {
61 unsafe {
62 from_glib(ffi::nm_tc_action_equal(self.to_glib_none().0, other.to_glib_none().0))
63 }
64 }
65
66 #[cfg(feature = "v1_12")]
80 #[cfg_attr(docsrs, doc(cfg(feature = "v1_12")))]
81 #[doc(alias = "nm_tc_action_get_attribute_names")]
82 #[doc(alias = "get_attribute_names")]
83 pub fn attribute_names(&self) -> Vec<glib::GString> {
84 unsafe {
85 FromGlibPtrContainer::from_glib_full(ffi::nm_tc_action_get_attribute_names(self.to_glib_none().0))
86 }
87 }
88
89 #[cfg(feature = "v1_12")]
90 #[cfg_attr(docsrs, doc(cfg(feature = "v1_12")))]
91 #[doc(alias = "nm_tc_action_get_kind")]
92 #[doc(alias = "get_kind")]
93 pub fn kind(&self) -> glib::GString {
94 unsafe {
95 from_glib_none(ffi::nm_tc_action_get_kind(self.to_glib_none().0))
96 }
97 }
98
99 }
106
107#[cfg(feature = "v1_12")]
108#[cfg_attr(docsrs, doc(cfg(feature = "v1_12")))]
109impl PartialEq for TCAction {
110 #[inline]
111 fn eq(&self, other: &Self) -> bool {
112 self.equal(other)
113 }
114}
115#[cfg(feature = "v1_12")]
116#[cfg_attr(docsrs, doc(cfg(feature = "v1_12")))]
117
118impl Eq for TCAction {}