nm-rs 0.1.3

Rust bindings for the libnm library.
Documentation
// This file was generated by gir (https://github.com/gtk-rs/gir)
// from gir
// from gtk-girs (https://github.com/gtk-rs/gir-files)
// DO NOT EDIT

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 {
    /// Creates a new #NMTCQdisc object.
    /// ## `kind`
    /// name of the queueing discipline
    /// ## `parent`
    /// the parent queueing discipline
    ///
    /// # Returns
    ///
    /// the new #NMTCQdisc object, or [`None`] on error
    #[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)) }
        }
    }

    /// Creates a copy of @self
    ///
    /// # Returns
    ///
    /// a copy of @self
    #[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")]
    //#[doc(alias = "get_attribute")]
    //pub fn attribute(&self, name: &str) -> /*Ignored*/glib::Variant {
    //    unsafe { TODO: call ffi:nm_tc_qdisc_get_attribute() }
    //}

    /// Gets an array of attribute names defined on @self.
    ///
    /// # Returns
    ///
    /// a [`None`]-terminated array of attribute names
    ///   or [`None`] if no attributes are set.
    #[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))
        }
    }

    ///
    /// # Returns
    ///
    /// the queueing discipline handle
    #[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))
        }
    }

    ///
    /// # Returns
    ///
    /// the parent class
    #[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_18")]
    //#[cfg_attr(docsrs, doc(cfg(feature = "v1_18")))]
    //#[doc(alias = "nm_tc_qdisc_set_attribute")]
    //pub fn set_attribute(&self, name: &str, value: /*Ignored*/Option<&glib::Variant>) {
    //    unsafe { TODO: call ffi:nm_tc_qdisc_set_attribute() }
    //}

    /// Sets the queueing discipline handle.
    /// ## `handle`
    /// the queueing discipline handle
    #[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 {}