1use crate::{ffi};
7#[cfg(feature = "v1_42")]
8#[cfg_attr(docsrs, doc(cfg(feature = "v1_42")))]
9use crate::{TCAction};
10#[cfg(feature = "v1_12")]
11#[cfg_attr(docsrs, doc(cfg(feature = "v1_12")))]
12use glib::{translate::*};
13
14glib::wrapper! {
15 #[derive(Debug, PartialOrd, Ord, Hash)]
16 pub struct TCTfilter(Shared<ffi::NMTCTfilter>);
17
18 match fn {
19 ref => |ptr| ffi::nm_tc_tfilter_ref(ptr),
20 unref => |ptr| ffi::nm_tc_tfilter_unref(ptr),
21 type_ => || ffi::nm_tc_tfilter_get_type(),
22 }
23}
24
25impl TCTfilter {
26 #[cfg(feature = "v1_12")]
36 #[cfg_attr(docsrs, doc(cfg(feature = "v1_12")))]
37 #[doc(alias = "nm_tc_tfilter_new")]
38 pub fn new(kind: &str, parent: u32) -> Result<TCTfilter, glib::Error> {
39 assert_initialized_main_thread!();
40 unsafe {
41 let mut error = std::ptr::null_mut();
42 let ret = ffi::nm_tc_tfilter_new(kind.to_glib_none().0, parent, &mut error);
43 if error.is_null() { Ok(from_glib_full(ret)) } else { Err(from_glib_full(error)) }
44 }
45 }
46
47 #[cfg(feature = "v1_12")]
53 #[cfg_attr(docsrs, doc(cfg(feature = "v1_12")))]
54 #[doc(alias = "nm_tc_tfilter_dup")]
55#[must_use]
56 pub fn dup(&self) -> TCTfilter {
57 unsafe {
58 from_glib_full(ffi::nm_tc_tfilter_dup(self.to_glib_none().0))
59 }
60 }
61
62 #[cfg(feature = "v1_12")]
63 #[cfg_attr(docsrs, doc(cfg(feature = "v1_12")))]
64 #[doc(alias = "nm_tc_tfilter_equal")]
65 fn equal(&self, other: &TCTfilter) -> bool {
66 unsafe {
67 from_glib(ffi::nm_tc_tfilter_equal(self.to_glib_none().0, other.to_glib_none().0))
68 }
69 }
70
71 #[cfg(feature = "v1_42")]
76 #[cfg_attr(docsrs, doc(cfg(feature = "v1_42")))]
77 #[doc(alias = "nm_tc_tfilter_get_action")]
78 #[doc(alias = "get_action")]
79 pub fn action(&self) -> TCAction {
80 unsafe {
81 from_glib_full(ffi::nm_tc_tfilter_get_action(self.to_glib_none().0))
82 }
83 }
84
85 #[cfg(feature = "v1_12")]
90 #[cfg_attr(docsrs, doc(cfg(feature = "v1_12")))]
91 #[doc(alias = "nm_tc_tfilter_get_handle")]
92 #[doc(alias = "get_handle")]
93 pub fn handle(&self) -> u32 {
94 unsafe {
95 ffi::nm_tc_tfilter_get_handle(self.to_glib_none().0)
96 }
97 }
98
99 #[cfg(feature = "v1_12")]
100 #[cfg_attr(docsrs, doc(cfg(feature = "v1_12")))]
101 #[doc(alias = "nm_tc_tfilter_get_kind")]
102 #[doc(alias = "get_kind")]
103 pub fn kind(&self) -> glib::GString {
104 unsafe {
105 from_glib_none(ffi::nm_tc_tfilter_get_kind(self.to_glib_none().0))
106 }
107 }
108
109 #[cfg(feature = "v1_12")]
114 #[cfg_attr(docsrs, doc(cfg(feature = "v1_12")))]
115 #[doc(alias = "nm_tc_tfilter_get_parent")]
116 #[doc(alias = "get_parent")]
117 pub fn parent(&self) -> u32 {
118 unsafe {
119 ffi::nm_tc_tfilter_get_parent(self.to_glib_none().0)
120 }
121 }
122
123 #[cfg(feature = "v1_42")]
127 #[cfg_attr(docsrs, doc(cfg(feature = "v1_42")))]
128 #[doc(alias = "nm_tc_tfilter_set_action")]
129 pub fn set_action(&self, action: &TCAction) {
130 unsafe {
131 ffi::nm_tc_tfilter_set_action(self.to_glib_none().0, action.to_glib_none().0);
132 }
133 }
134
135 #[cfg(feature = "v1_12")]
139 #[cfg_attr(docsrs, doc(cfg(feature = "v1_12")))]
140 #[doc(alias = "nm_tc_tfilter_set_handle")]
141 pub fn set_handle(&self, handle: u32) {
142 unsafe {
143 ffi::nm_tc_tfilter_set_handle(self.to_glib_none().0, handle);
144 }
145 }
146}
147
148#[cfg(feature = "v1_12")]
149#[cfg_attr(docsrs, doc(cfg(feature = "v1_12")))]
150impl PartialEq for TCTfilter {
151 #[inline]
152 fn eq(&self, other: &Self) -> bool {
153 self.equal(other)
154 }
155}
156#[cfg(feature = "v1_12")]
157#[cfg_attr(docsrs, doc(cfg(feature = "v1_12")))]
158
159impl Eq for TCTfilter {}