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,Connection,Object,WimaxNspNetworkType};
use glib::{prelude::*,signal::{connect_raw, SignalHandlerId},translate::*};
use std::{boxed::Box as Box_};

glib::wrapper! {
    /// WiMAX is no longer supported by NetworkManager since 1.2.0.
    ///
    ///
    /// ## Properties
    ///
    ///
    /// #### `name`
    ///  The name of the WiMAX NSP.
    ///
    /// Readable
    ///
    ///
    /// #### `network-type`
    ///  The network type of the WiMAX NSP.
    ///
    /// Readable
    ///
    ///
    /// #### `signal-quality`
    ///  The signal quality of the WiMAX NSP.
    ///
    /// Readable
    /// <details><summary><h4>Object</h4></summary>
    ///
    ///
    /// #### `client`
    ///  The NMClient instance as returned by nm_object_get_client().
    ///
    /// When an NMObject gets removed from the NMClient cache,
    /// the NMObject:path property stays unchanged, but this client
    /// instance gets reset to [`None`]. You can use this property to
    /// track removal of the object from the cache.
    ///
    /// Readable
    ///
    ///
    /// #### `path`
    ///  The D-Bus object path.
    ///
    /// The D-Bus path of an object instance never changes, even if the object
    /// gets removed from the cache. To see whether the object is still in the
    /// cache, check NMObject:client.
    ///
    /// Readable
    /// </details>
    ///
    /// # Implements
    ///
    /// [`ObjectExt`][trait@crate::prelude::ObjectExt]
    #[doc(alias = "NMWimaxNsp")]
    pub struct WimaxNsp(Object<ffi::NMWimaxNsp, ffi::NMWimaxNspClass>) @extends Object;

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

impl WimaxNsp {
    /// Validates a given connection against a given WiMAX NSP to ensure that the
    /// connection may be activated with that NSP.  The connection must match the
    /// @self's network name and other attributes.
    ///
    /// # Deprecated since 1.22
    ///
    /// WiMAX is no longer supported by NetworkManager since 1.2.0.
    /// ## `connection`
    /// an #NMConnection to validate against @self
    ///
    /// # Returns
    ///
    /// [`true`] if the connection may be activated with this WiMAX NSP,
    /// [`false`] if it cannot be.
    #[cfg_attr(feature = "v1_22", deprecated = "Since 1.22")]
    #[allow(deprecated)]
    #[doc(alias = "nm_wimax_nsp_connection_valid")]
    pub fn connection_valid(&self, connection: &impl IsA<Connection>) -> bool {
        unsafe {
            from_glib(ffi::nm_wimax_nsp_connection_valid(self.to_glib_none().0, connection.as_ref().to_glib_none().0))
        }
    }

    /// Filters a given array of connections for a given #NMWimaxNsp object and
    /// return connections which may be activated with the NSP.  Any returned
    /// connections will match the @self's network name and other attributes.
    ///
    /// # Deprecated since 1.22
    ///
    /// WiMAX is no longer supported by NetworkManager since 1.2.0.
    /// ## `connections`
    /// an array of #NMConnections to
    /// filter
    ///
    /// # Returns
    ///
    /// an array of
    /// #NMConnections that could be activated with the given @self.  The array should
    /// be freed with g_ptr_array_unref() when it is no longer required.
    #[cfg_attr(feature = "v1_22", deprecated = "Since 1.22")]
    #[allow(deprecated)]
    #[doc(alias = "nm_wimax_nsp_filter_connections")]
    pub fn filter_connections(&self, connections: &[Connection]) -> Vec<Connection> {
        unsafe {
            FromGlibPtrContainer::from_glib_full(ffi::nm_wimax_nsp_filter_connections(self.to_glib_none().0, connections.to_glib_none().0))
        }
    }

    /// Gets the name of the wimax NSP
    ///
    /// # Deprecated since 1.22
    ///
    /// WiMAX is no longer supported by NetworkManager since 1.2.0.
    ///
    /// # Returns
    ///
    /// the name
    #[cfg_attr(feature = "v1_22", deprecated = "Since 1.22")]
    #[allow(deprecated)]
    #[doc(alias = "nm_wimax_nsp_get_name")]
    #[doc(alias = "get_name")]
    pub fn name(&self) -> glib::GString {
        unsafe {
            from_glib_none(ffi::nm_wimax_nsp_get_name(self.to_glib_none().0))
        }
    }

    /// Gets the network type of the wimax NSP.
    ///
    /// # Deprecated since 1.22
    ///
    /// WiMAX is no longer supported by NetworkManager since 1.2.0.
    ///
    /// # Returns
    ///
    /// the network type
    #[cfg_attr(feature = "v1_22", deprecated = "Since 1.22")]
    #[allow(deprecated)]
    #[doc(alias = "nm_wimax_nsp_get_network_type")]
    #[doc(alias = "get_network_type")]
    #[doc(alias = "network-type")]
    pub fn network_type(&self) -> WimaxNspNetworkType {
        unsafe {
            from_glib(ffi::nm_wimax_nsp_get_network_type(self.to_glib_none().0))
        }
    }

    /// Gets the WPA signal quality of the wimax NSP.
    ///
    /// # Deprecated since 1.22
    ///
    /// WiMAX is no longer supported by NetworkManager since 1.2.0.
    ///
    /// # Returns
    ///
    /// the signal quality
    #[cfg_attr(feature = "v1_22", deprecated = "Since 1.22")]
    #[allow(deprecated)]
    #[doc(alias = "nm_wimax_nsp_get_signal_quality")]
    #[doc(alias = "get_signal_quality")]
    #[doc(alias = "signal-quality")]
    pub fn signal_quality(&self) -> u32 {
        unsafe {
            ffi::nm_wimax_nsp_get_signal_quality(self.to_glib_none().0)
        }
    }

    #[cfg_attr(feature = "v1_22", deprecated = "Since 1.22")]
    #[doc(alias = "name")]
    pub fn connect_name_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
        unsafe extern "C" fn notify_name_trampoline<F: Fn(&WimaxNsp) + 'static>(this: *mut ffi::NMWimaxNsp, _param_spec: glib::ffi::gpointer, f: glib::ffi::gpointer) {
            let f: &F = &*(f as *const F);
            f(&from_glib_borrow(this))
        }
        unsafe {
            let f: Box_<F> = Box_::new(f);
            connect_raw(self.as_ptr() as *mut _, c"notify::name".as_ptr() as *const _,
                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(notify_name_trampoline::<F> as *const ())), Box_::into_raw(f))
        }
    }

    #[cfg_attr(feature = "v1_22", deprecated = "Since 1.22")]
    #[doc(alias = "network-type")]
    pub fn connect_network_type_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
        unsafe extern "C" fn notify_network_type_trampoline<F: Fn(&WimaxNsp) + 'static>(this: *mut ffi::NMWimaxNsp, _param_spec: glib::ffi::gpointer, f: glib::ffi::gpointer) {
            let f: &F = &*(f as *const F);
            f(&from_glib_borrow(this))
        }
        unsafe {
            let f: Box_<F> = Box_::new(f);
            connect_raw(self.as_ptr() as *mut _, c"notify::network-type".as_ptr() as *const _,
                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(notify_network_type_trampoline::<F> as *const ())), Box_::into_raw(f))
        }
    }

    #[cfg_attr(feature = "v1_22", deprecated = "Since 1.22")]
    #[doc(alias = "signal-quality")]
    pub fn connect_signal_quality_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
        unsafe extern "C" fn notify_signal_quality_trampoline<F: Fn(&WimaxNsp) + 'static>(this: *mut ffi::NMWimaxNsp, _param_spec: glib::ffi::gpointer, f: glib::ffi::gpointer) {
            let f: &F = &*(f as *const F);
            f(&from_glib_borrow(this))
        }
        unsafe {
            let f: Box_<F> = Box_::new(f);
            connect_raw(self.as_ptr() as *mut _, c"notify::signal-quality".as_ptr() as *const _,
                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(notify_signal_quality_trampoline::<F> as *const ())), Box_::into_raw(f))
        }
    }
}

impl std::fmt::Display for WimaxNsp {
    #[inline]
    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
        f.write_str(&self.name())
    }
}