use crate::{ffi};
#[cfg(feature = "v1_12")]
#[cfg_attr(docsrs, doc(cfg(feature = "v1_12")))]
use glib::{translate::*};
glib::wrapper! {
#[derive(Debug, PartialOrd, Ord, Hash)]
pub struct TCQdisc(Shared<ffi::NMTCQdisc>);
match fn {
ref => |ptr| ffi::nm_tc_qdisc_ref(ptr),
unref => |ptr| ffi::nm_tc_qdisc_unref(ptr),
type_ => || ffi::nm_tc_qdisc_get_type(),
}
}
impl TCQdisc {
#[cfg(feature = "v1_12")]
#[cfg_attr(docsrs, doc(cfg(feature = "v1_12")))]
#[doc(alias = "nm_tc_qdisc_new")]
pub fn new(kind: &str, parent: u32) -> Result<TCQdisc, glib::Error> {
assert_initialized_main_thread!();
unsafe {
let mut error = std::ptr::null_mut();
let ret = ffi::nm_tc_qdisc_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_qdisc_dup")]
#[must_use]
pub fn dup(&self) -> TCQdisc {
unsafe {
from_glib_full(ffi::nm_tc_qdisc_dup(self.to_glib_none().0))
}
}
#[cfg(feature = "v1_12")]
#[cfg_attr(docsrs, doc(cfg(feature = "v1_12")))]
#[doc(alias = "nm_tc_qdisc_equal")]
fn equal(&self, other: &TCQdisc) -> bool {
unsafe {
from_glib(ffi::nm_tc_qdisc_equal(self.to_glib_none().0, other.to_glib_none().0))
}
}
#[cfg(feature = "v1_18")]
#[cfg_attr(docsrs, doc(cfg(feature = "v1_18")))]
#[doc(alias = "nm_tc_qdisc_get_attribute_names")]
#[doc(alias = "get_attribute_names")]
pub fn attribute_names(&self) -> Vec<glib::GString> {
unsafe {
FromGlibPtrContainer::from_glib_container(ffi::nm_tc_qdisc_get_attribute_names(self.to_glib_none().0))
}
}
#[cfg(feature = "v1_12")]
#[cfg_attr(docsrs, doc(cfg(feature = "v1_12")))]
#[doc(alias = "nm_tc_qdisc_get_handle")]
#[doc(alias = "get_handle")]
pub fn handle(&self) -> u32 {
unsafe {
ffi::nm_tc_qdisc_get_handle(self.to_glib_none().0)
}
}
#[cfg(feature = "v1_12")]
#[cfg_attr(docsrs, doc(cfg(feature = "v1_12")))]
#[doc(alias = "nm_tc_qdisc_get_kind")]
#[doc(alias = "get_kind")]
pub fn kind(&self) -> glib::GString {
unsafe {
from_glib_none(ffi::nm_tc_qdisc_get_kind(self.to_glib_none().0))
}
}
#[cfg(feature = "v1_12")]
#[cfg_attr(docsrs, doc(cfg(feature = "v1_12")))]
#[doc(alias = "nm_tc_qdisc_get_parent")]
#[doc(alias = "get_parent")]
pub fn parent(&self) -> u32 {
unsafe {
ffi::nm_tc_qdisc_get_parent(self.to_glib_none().0)
}
}
#[cfg(feature = "v1_12")]
#[cfg_attr(docsrs, doc(cfg(feature = "v1_12")))]
#[doc(alias = "nm_tc_qdisc_set_handle")]
pub fn set_handle(&self, handle: u32) {
unsafe {
ffi::nm_tc_qdisc_set_handle(self.to_glib_none().0, handle);
}
}
}
#[cfg(feature = "v1_12")]
#[cfg_attr(docsrs, doc(cfg(feature = "v1_12")))]
impl PartialEq for TCQdisc {
#[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 TCQdisc {}