use crate::{ffi};
#[cfg(feature = "v1_42")]
#[cfg_attr(docsrs, doc(cfg(feature = "v1_42")))]
use crate::{TCAction};
#[cfg(feature = "v1_12")]
#[cfg_attr(docsrs, doc(cfg(feature = "v1_12")))]
use glib::{translate::*};
glib::wrapper! {
#[derive(Debug, PartialOrd, Ord, Hash)]
pub struct TCTfilter(Shared<ffi::NMTCTfilter>);
match fn {
ref => |ptr| ffi::nm_tc_tfilter_ref(ptr),
unref => |ptr| ffi::nm_tc_tfilter_unref(ptr),
type_ => || ffi::nm_tc_tfilter_get_type(),
}
}
impl TCTfilter {
#[cfg(feature = "v1_12")]
#[cfg_attr(docsrs, doc(cfg(feature = "v1_12")))]
#[doc(alias = "nm_tc_tfilter_new")]
pub fn new(kind: &str, parent: u32) -> Result<TCTfilter, glib::Error> {
assert_initialized_main_thread!();
unsafe {
let mut error = std::ptr::null_mut();
let ret = ffi::nm_tc_tfilter_new(kind.to_glib_none().0, parent, &mut error);
if error.is_null() { Ok(from_glib_full(ret)) } else { Err(from_glib_full(error)) }
}
}
#[cfg(feature = "v1_12")]
#[cfg_attr(docsrs, doc(cfg(feature = "v1_12")))]
#[doc(alias = "nm_tc_tfilter_dup")]
#[must_use]
pub fn dup(&self) -> TCTfilter {
unsafe {
from_glib_full(ffi::nm_tc_tfilter_dup(self.to_glib_none().0))
}
}
#[cfg(feature = "v1_12")]
#[cfg_attr(docsrs, doc(cfg(feature = "v1_12")))]
#[doc(alias = "nm_tc_tfilter_equal")]
fn equal(&self, other: &TCTfilter) -> bool {
unsafe {
from_glib(ffi::nm_tc_tfilter_equal(self.to_glib_none().0, other.to_glib_none().0))
}
}
#[cfg(feature = "v1_42")]
#[cfg_attr(docsrs, doc(cfg(feature = "v1_42")))]
#[doc(alias = "nm_tc_tfilter_get_action")]
#[doc(alias = "get_action")]
pub fn action(&self) -> TCAction {
unsafe {
from_glib_full(ffi::nm_tc_tfilter_get_action(self.to_glib_none().0))
}
}
#[cfg(feature = "v1_12")]
#[cfg_attr(docsrs, doc(cfg(feature = "v1_12")))]
#[doc(alias = "nm_tc_tfilter_get_handle")]
#[doc(alias = "get_handle")]
pub fn handle(&self) -> u32 {
unsafe {
ffi::nm_tc_tfilter_get_handle(self.to_glib_none().0)
}
}
#[cfg(feature = "v1_12")]
#[cfg_attr(docsrs, doc(cfg(feature = "v1_12")))]
#[doc(alias = "nm_tc_tfilter_get_kind")]
#[doc(alias = "get_kind")]
pub fn kind(&self) -> glib::GString {
unsafe {
from_glib_none(ffi::nm_tc_tfilter_get_kind(self.to_glib_none().0))
}
}
#[cfg(feature = "v1_12")]
#[cfg_attr(docsrs, doc(cfg(feature = "v1_12")))]
#[doc(alias = "nm_tc_tfilter_get_parent")]
#[doc(alias = "get_parent")]
pub fn parent(&self) -> u32 {
unsafe {
ffi::nm_tc_tfilter_get_parent(self.to_glib_none().0)
}
}
#[cfg(feature = "v1_42")]
#[cfg_attr(docsrs, doc(cfg(feature = "v1_42")))]
#[doc(alias = "nm_tc_tfilter_set_action")]
pub fn set_action(&self, action: &TCAction) {
unsafe {
ffi::nm_tc_tfilter_set_action(self.to_glib_none().0, action.to_glib_none().0);
}
}
#[cfg(feature = "v1_12")]
#[cfg_attr(docsrs, doc(cfg(feature = "v1_12")))]
#[doc(alias = "nm_tc_tfilter_set_handle")]
pub fn set_handle(&self, handle: u32) {
unsafe {
ffi::nm_tc_tfilter_set_handle(self.to_glib_none().0, handle);
}
}
}
#[cfg(feature = "v1_12")]
#[cfg_attr(docsrs, doc(cfg(feature = "v1_12")))]
impl PartialEq for TCTfilter {
#[inline]
fn eq(&self, other: &Self) -> bool {
self.equal(other)
}
}
#[cfg(feature = "v1_12")]
#[cfg_attr(docsrs, doc(cfg(feature = "v1_12")))]
impl Eq for TCTfilter {}