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
#![allow(deprecated)]

use crate::{ffi,Setting,Ternary};
use glib::{prelude::*,translate::*};

glib::wrapper! {
    /// Ethtool Ethernet Settings
    ///
    /// # Implements
    ///
    /// [`SettingExt`][trait@crate::prelude::SettingExt]
    #[doc(alias = "NMSettingEthtool")]
    pub struct SettingEthtool(Object<ffi::NMSettingEthtool, ffi::NMSettingEthtoolClass>) @extends Setting;

    match fn {
        type_ => || ffi::nm_setting_ethtool_get_type(),
    }
}

impl SettingEthtool {
    /// Creates a new #NMSettingEthtool object with default values.
    ///
    /// # Returns
    ///
    /// the new empty #NMSettingEthtool object
    #[doc(alias = "nm_setting_ethtool_new")]
    pub fn new() -> SettingEthtool {
        assert_initialized_main_thread!();
        unsafe {
            Setting::from_glib_full(ffi::nm_setting_ethtool_new()).unsafe_cast()
        }
    }

    /// Clears all offload features settings
    ///
    /// # Deprecated since 1.26
    ///
    /// use nm_setting_option_clear_by_name() with nm_ethtool_optname_is_feature() predicate instead.
    #[cfg_attr(feature = "v1_26", deprecated = "Since 1.26")]
    #[allow(deprecated)]
    #[doc(alias = "nm_setting_ethtool_clear_features")]
    pub fn clear_features(&self) {
        unsafe {
            ffi::nm_setting_ethtool_clear_features(self.to_glib_none().0);
        }
    }

    /// Gets and offload feature setting. Returns [`Ternary::Default`][crate::Ternary::Default] if the
    /// feature is not set.
    ///
    /// Note that @optname must be a valid name for a feature, according to
    /// nm_ethtool_optname_is_feature().
    ///
    /// # Deprecated since 1.26
    ///
    /// use nm_setting_option_get_boolean() instead.
    /// ## `optname`
    /// option name of the offload feature to get
    ///
    /// # Returns
    ///
    /// a #NMTernary value indicating whether the offload feature
    ///   is enabled, disabled, or left untouched.
    #[cfg_attr(feature = "v1_26", deprecated = "Since 1.26")]
    #[allow(deprecated)]
    #[doc(alias = "nm_setting_ethtool_get_feature")]
    #[doc(alias = "get_feature")]
    pub fn feature(&self, optname: &str) -> Ternary {
        unsafe {
            from_glib(ffi::nm_setting_ethtool_get_feature(self.to_glib_none().0, optname.to_glib_none().0))
        }
    }

    /// This returns all options names that are set. This includes the feature names
    /// like [`ETHTOOL_OPTNAME_FEATURE_GRO`][crate::ETHTOOL_OPTNAME_FEATURE_GRO]. See nm_ethtool_optname_is_feature() to
    /// check whether the option name is valid for offload features.
    ///
    /// # Deprecated since 1.26
    ///
    /// use nm_setting_option_get_all_names() instead.
    ///
    /// # Returns
    ///
    /// list of set option
    ///   names or [`None`] if no options are set. The option names are still owned by
    ///   @self and may get invalidated when @self gets modified.
    ///
    /// ## `out_length`
    /// return location for the number of keys returned, or [`None`]
    #[cfg_attr(feature = "v1_26", deprecated = "Since 1.26")]
    #[cfg(feature = "v1_20")]
    #[cfg_attr(docsrs, doc(cfg(feature = "v1_20")))]
    #[allow(deprecated)]
    #[doc(alias = "nm_setting_ethtool_get_optnames")]
    #[doc(alias = "get_optnames")]
    pub fn optnames(&self) -> (Vec<glib::GString>, u32) {
        unsafe {
            let mut out_length = std::mem::MaybeUninit::uninit();
            let ret = FromGlibPtrContainer::from_glib_container(ffi::nm_setting_ethtool_get_optnames(self.to_glib_none().0, out_length.as_mut_ptr()));
            (ret, out_length.assume_init())
        }
    }

    /// Sets and offload feature setting.
    ///
    /// Note that @optname must be a valid name for a feature, according to
    /// nm_ethtool_optname_is_feature().
    ///
    /// # Deprecated since 1.26
    ///
    /// use nm_setting_option_set() or nm_setting_option_set_boolean() instead.
    /// ## `optname`
    /// option name of the offload feature to get
    /// ## `value`
    /// the new value to set. The special value [`Ternary::Default`][crate::Ternary::Default]
    ///   means to clear the offload feature setting.
    #[cfg_attr(feature = "v1_26", deprecated = "Since 1.26")]
    #[allow(deprecated)]
    #[doc(alias = "nm_setting_ethtool_set_feature")]
    pub fn set_feature(&self, optname: &str, value: Ternary) {
        unsafe {
            ffi::nm_setting_ethtool_set_feature(self.to_glib_none().0, optname.to_glib_none().0, value.into_glib());
        }
    }
}

#[cfg(feature = "v1_14")]
#[cfg_attr(docsrs, doc(cfg(feature = "v1_14")))]
impl Default for SettingEthtool {
                     fn default() -> Self {
                         Self::new()
                     }
                 }