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 TCAction(Shared<ffi::NMTCAction>);

    match fn {
        ref => |ptr| ffi::nm_tc_action_ref(ptr),
        unref => |ptr| ffi::nm_tc_action_unref(ptr),
        type_ => || ffi::nm_tc_action_get_type(),
    }
}

impl TCAction {
    /// Creates a new #NMTCAction object.
    /// ## `kind`
    /// name of the queueing discipline
    ///
    /// # Returns
    ///
    /// the new #NMTCAction object, or [`None`] on error
    #[cfg(feature = "v1_12")]
    #[cfg_attr(docsrs, doc(cfg(feature = "v1_12")))]
    #[doc(alias = "nm_tc_action_new")]
    pub fn new(kind: &str) -> Result<TCAction, glib::Error> {
        assert_initialized_main_thread!();
        unsafe {
            let mut error = std::ptr::null_mut();
            let ret = ffi::nm_tc_action_new(kind.to_glib_none().0, &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_action_dup")]
#[must_use]
    pub fn dup(&self) -> TCAction {
        unsafe {
            from_glib_full(ffi::nm_tc_action_dup(self.to_glib_none().0))
        }
    }

    #[cfg(feature = "v1_12")]
    #[cfg_attr(docsrs, doc(cfg(feature = "v1_12")))]
    #[doc(alias = "nm_tc_action_equal")]
     fn equal(&self, other: &TCAction) -> bool {
        unsafe {
            from_glib(ffi::nm_tc_action_equal(self.to_glib_none().0, other.to_glib_none().0))
        }
    }

    //#[cfg(feature = "v1_12")]
    //#[cfg_attr(docsrs, doc(cfg(feature = "v1_12")))]
    //#[doc(alias = "nm_tc_action_get_attribute")]
    //#[doc(alias = "get_attribute")]
    //pub fn attribute(&self, name: &str) -> /*Ignored*/glib::Variant {
    //    unsafe { TODO: call ffi:nm_tc_action_get_attribute() }
    //}

    /// Gets an array of attribute names defined on @self.
    ///
    /// # Returns
    ///
    /// a [`None`]-terminated array of attribute names,
    #[cfg(feature = "v1_12")]
    #[cfg_attr(docsrs, doc(cfg(feature = "v1_12")))]
    #[doc(alias = "nm_tc_action_get_attribute_names")]
    #[doc(alias = "get_attribute_names")]
    pub fn attribute_names(&self) -> Vec<glib::GString> {
        unsafe {
            FromGlibPtrContainer::from_glib_full(ffi::nm_tc_action_get_attribute_names(self.to_glib_none().0))
        }
    }

    #[cfg(feature = "v1_12")]
    #[cfg_attr(docsrs, doc(cfg(feature = "v1_12")))]
    #[doc(alias = "nm_tc_action_get_kind")]
    #[doc(alias = "get_kind")]
    pub fn kind(&self) -> glib::GString {
        unsafe {
            from_glib_none(ffi::nm_tc_action_get_kind(self.to_glib_none().0))
        }
    }

    //#[cfg(feature = "v1_12")]
    //#[cfg_attr(docsrs, doc(cfg(feature = "v1_12")))]
    //#[doc(alias = "nm_tc_action_set_attribute")]
    //pub fn set_attribute(&self, name: &str, value: /*Ignored*/Option<&glib::Variant>) {
    //    unsafe { TODO: call ffi:nm_tc_action_set_attribute() }
    //}
}

#[cfg(feature = "v1_12")]
#[cfg_attr(docsrs, doc(cfg(feature = "v1_12")))]
impl PartialEq for TCAction {
    #[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 TCAction {}