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_14")]
#[cfg_attr(docsrs, doc(cfg(feature = "v1_14")))]
use crate::{SriovVFVlanProtocol};
#[cfg(feature = "v1_14")]
#[cfg_attr(docsrs, doc(cfg(feature = "v1_14")))]
use glib::{translate::*};

glib::wrapper! {
    #[derive(Debug, PartialOrd, Ord, Hash)]
    pub struct SriovVF(Shared<ffi::NMSriovVF>);

    match fn {
        ref => |ptr| ffi::nm_sriov_vf_ref(ptr),
        unref => |ptr| ffi::nm_sriov_vf_unref(ptr),
        type_ => || ffi::nm_sriov_vf_get_type(),
    }
}

impl SriovVF {
    /// Creates a new #NMSriovVF object.
    /// ## `index`
    /// the VF index
    ///
    /// # Returns
    ///
    /// the new #NMSriovVF object.
    #[cfg(feature = "v1_14")]
    #[cfg_attr(docsrs, doc(cfg(feature = "v1_14")))]
    #[doc(alias = "nm_sriov_vf_new")]
    pub fn new(index: u32) -> SriovVF {
        assert_initialized_main_thread!();
        unsafe {
            from_glib_full(ffi::nm_sriov_vf_new(index))
        }
    }

    /// Adds a VLAN to the VF. Currently kernel only supports one VLAN per VF.
    /// ## `vlan_id`
    /// the VLAN id
    ///
    /// # Returns
    ///
    /// [`true`] if the VLAN was added; [`false`] if it already existed
    #[cfg(feature = "v1_14")]
    #[cfg_attr(docsrs, doc(cfg(feature = "v1_14")))]
    #[doc(alias = "nm_sriov_vf_add_vlan")]
    pub fn add_vlan(&self, vlan_id: u32) -> bool {
        unsafe {
            from_glib(ffi::nm_sriov_vf_add_vlan(self.to_glib_none().0, vlan_id))
        }
    }

    /// Creates a copy of @self.
    ///
    /// # Returns
    ///
    /// a copy of @self
    #[cfg(feature = "v1_14")]
    #[cfg_attr(docsrs, doc(cfg(feature = "v1_14")))]
    #[doc(alias = "nm_sriov_vf_dup")]
#[must_use]
    pub fn dup(&self) -> SriovVF {
        unsafe {
            from_glib_full(ffi::nm_sriov_vf_dup(self.to_glib_none().0))
        }
    }

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

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

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

    /// Gets the index property of this VF object.
    ///
    /// # Returns
    ///
    /// the VF index
    #[cfg(feature = "v1_14")]
    #[cfg_attr(docsrs, doc(cfg(feature = "v1_14")))]
    #[doc(alias = "nm_sriov_vf_get_index")]
    #[doc(alias = "get_index")]
    pub fn index(&self) -> u32 {
        unsafe {
            ffi::nm_sriov_vf_get_index(self.to_glib_none().0)
        }
    }

    /// Returns the VLANs currently configured on the VF. Currently kernel only
    /// supports one VLAN per VF.
    ///
    /// # Returns
    ///
    /// a list of VLAN ids configured on the VF.
    #[cfg(feature = "v1_14")]
    #[cfg_attr(docsrs, doc(cfg(feature = "v1_14")))]
    #[doc(alias = "nm_sriov_vf_get_vlan_ids")]
    #[doc(alias = "get_vlan_ids")]
    pub fn vlan_ids(&self) -> Vec<u32> {
        unsafe {
            let mut length = std::mem::MaybeUninit::uninit();
            let ret = FromGlibContainer::from_glib_none_num(ffi::nm_sriov_vf_get_vlan_ids(self.to_glib_none().0, length.as_mut_ptr()), length.assume_init() as _);
            ret
        }
    }

    /// Returns the configured protocol for the given VLAN.
    /// ## `vlan_id`
    /// the VLAN id
    ///
    /// # Returns
    ///
    /// the configured protocol
    #[cfg(feature = "v1_14")]
    #[cfg_attr(docsrs, doc(cfg(feature = "v1_14")))]
    #[doc(alias = "nm_sriov_vf_get_vlan_protocol")]
    #[doc(alias = "get_vlan_protocol")]
    pub fn vlan_protocol(&self, vlan_id: u32) -> SriovVFVlanProtocol {
        unsafe {
            from_glib(ffi::nm_sriov_vf_get_vlan_protocol(self.to_glib_none().0, vlan_id))
        }
    }

    /// Returns the QoS value for the given VLAN.
    /// ## `vlan_id`
    /// the VLAN id
    ///
    /// # Returns
    ///
    /// the QoS value
    #[cfg(feature = "v1_14")]
    #[cfg_attr(docsrs, doc(cfg(feature = "v1_14")))]
    #[doc(alias = "nm_sriov_vf_get_vlan_qos")]
    #[doc(alias = "get_vlan_qos")]
    pub fn vlan_qos(&self, vlan_id: u32) -> u32 {
        unsafe {
            ffi::nm_sriov_vf_get_vlan_qos(self.to_glib_none().0, vlan_id)
        }
    }

    /// Removes a VLAN from a VF.
    /// ## `vlan_id`
    /// the VLAN id
    ///
    /// # Returns
    ///
    /// [`true`] if the VLAN was removed, [`false`] if the VLAN @vlan_id
    ///     did not belong to the VF.
    #[cfg(feature = "v1_14")]
    #[cfg_attr(docsrs, doc(cfg(feature = "v1_14")))]
    #[doc(alias = "nm_sriov_vf_remove_vlan")]
    pub fn remove_vlan(&self, vlan_id: u32) -> bool {
        unsafe {
            from_glib(ffi::nm_sriov_vf_remove_vlan(self.to_glib_none().0, vlan_id))
        }
    }

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

    /// Sets the protocol for the given VLAN.
    /// ## `vlan_id`
    /// the VLAN id
    /// ## `protocol`
    /// the VLAN protocol
    #[cfg(feature = "v1_14")]
    #[cfg_attr(docsrs, doc(cfg(feature = "v1_14")))]
    #[doc(alias = "nm_sriov_vf_set_vlan_protocol")]
    pub fn set_vlan_protocol(&self, vlan_id: u32, protocol: SriovVFVlanProtocol) {
        unsafe {
            ffi::nm_sriov_vf_set_vlan_protocol(self.to_glib_none().0, vlan_id, protocol.into_glib());
        }
    }

    /// Sets a QoS value for the given VLAN.
    /// ## `vlan_id`
    /// the VLAN id
    /// ## `qos`
    /// a QoS (priority) value
    #[cfg(feature = "v1_14")]
    #[cfg_attr(docsrs, doc(cfg(feature = "v1_14")))]
    #[doc(alias = "nm_sriov_vf_set_vlan_qos")]
    pub fn set_vlan_qos(&self, vlan_id: u32, qos: u32) {
        unsafe {
            ffi::nm_sriov_vf_set_vlan_qos(self.to_glib_none().0, vlan_id, qos);
        }
    }

    //#[cfg(feature = "v1_42")]
    //#[cfg_attr(docsrs, doc(cfg(feature = "v1_42")))]
    //#[doc(alias = "nm_sriov_vf_attribute_validate")]
    //pub fn attribute_validate(name: &str, value: /*Ignored*/&glib::Variant) -> Result<bool, glib::Error> {
    //    unsafe { TODO: call ffi:nm_sriov_vf_attribute_validate() }
    //}
}

#[cfg(feature = "v1_14")]
#[cfg_attr(docsrs, doc(cfg(feature = "v1_14")))]
impl PartialEq for SriovVF {
    #[inline]
    fn eq(&self, other: &Self) -> bool {
        self.equal(other)
    }
}
#[cfg(feature = "v1_14")]
#[cfg_attr(docsrs, doc(cfg(feature = "v1_14")))]

impl Eq for SriovVF {}