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

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

    match fn {
        ref => |ptr| ffi::nm_team_link_watcher_ref(ptr),
        unref => |ptr| ffi::nm_team_link_watcher_unref(ptr),
        type_ => || ffi::nm_team_link_watcher_get_type(),
    }
}

impl TeamLinkWatcher {
    /// Creates a new arp_ping #NMTeamLinkWatcher object
    /// ## `init_wait`
    /// init_wait value
    /// ## `interval`
    /// interval value
    /// ## `missed_max`
    /// missed_max value
    /// ## `target_host`
    /// the host name or the ip address that will be used as destination
    ///   address in the arp request
    /// ## `source_host`
    /// the host name or the ip address that will be used as source
    ///   address in the arp request
    /// ## `flags`
    /// the watcher #NMTeamLinkWatcherArpPingFlags
    ///
    /// # Returns
    ///
    /// the new #NMTeamLinkWatcher object, or [`None`] on error
    #[cfg(feature = "v1_12")]
    #[cfg_attr(docsrs, doc(cfg(feature = "v1_12")))]
    #[doc(alias = "nm_team_link_watcher_new_arp_ping")]
    pub fn new_arp_ping(init_wait: i32, interval: i32, missed_max: i32, target_host: &str, source_host: &str, flags: TeamLinkWatcherArpPingFlags) -> Result<TeamLinkWatcher, glib::Error> {
        assert_initialized_main_thread!();
        unsafe {
            let mut error = std::ptr::null_mut();
            let ret = ffi::nm_team_link_watcher_new_arp_ping(init_wait, interval, missed_max, target_host.to_glib_none().0, source_host.to_glib_none().0, flags.into_glib(), &mut error);
            if error.is_null() { Ok(from_glib_full(ret)) } else { Err(from_glib_full(error)) }
        }
    }

    /// Creates a new arp_ping #NMTeamLinkWatcher object
    /// ## `init_wait`
    /// init_wait value
    /// ## `interval`
    /// interval value
    /// ## `missed_max`
    /// missed_max value
    /// ## `vlanid`
    /// vlanid value
    /// ## `target_host`
    /// the host name or the ip address that will be used as destination
    ///   address in the arp request
    /// ## `source_host`
    /// the host name or the ip address that will be used as source
    ///   address in the arp request
    /// ## `flags`
    /// the watcher #NMTeamLinkWatcherArpPingFlags
    ///
    /// # Returns
    ///
    /// the new #NMTeamLinkWatcher object, or [`None`] on error
    #[cfg(feature = "v1_16")]
    #[cfg_attr(docsrs, doc(cfg(feature = "v1_16")))]
    #[doc(alias = "nm_team_link_watcher_new_arp_ping2")]
    pub fn new_arp_ping2(init_wait: i32, interval: i32, missed_max: i32, vlanid: i32, target_host: &str, source_host: &str, flags: TeamLinkWatcherArpPingFlags) -> Result<TeamLinkWatcher, glib::Error> {
        assert_initialized_main_thread!();
        unsafe {
            let mut error = std::ptr::null_mut();
            let ret = ffi::nm_team_link_watcher_new_arp_ping2(init_wait, interval, missed_max, vlanid, target_host.to_glib_none().0, source_host.to_glib_none().0, flags.into_glib(), &mut error);
            if error.is_null() { Ok(from_glib_full(ret)) } else { Err(from_glib_full(error)) }
        }
    }

    /// Creates a new ethtool #NMTeamLinkWatcher object
    /// ## `delay_up`
    /// delay_up value
    /// ## `delay_down`
    /// delay_down value
    ///
    /// # Returns
    ///
    /// the new #NMTeamLinkWatcher object
    #[cfg(feature = "v1_12")]
    #[cfg_attr(docsrs, doc(cfg(feature = "v1_12")))]
    #[doc(alias = "nm_team_link_watcher_new_ethtool")]
    pub fn new_ethtool(delay_up: i32, delay_down: i32) -> Result<TeamLinkWatcher, glib::Error> {
        assert_initialized_main_thread!();
        unsafe {
            let mut error = std::ptr::null_mut();
            let ret = ffi::nm_team_link_watcher_new_ethtool(delay_up, delay_down, &mut error);
            if error.is_null() { Ok(from_glib_full(ret)) } else { Err(from_glib_full(error)) }
        }
    }

    /// Creates a new nsna_ping #NMTeamLinkWatcher object
    /// ## `init_wait`
    /// init_wait value
    /// ## `interval`
    /// interval value
    /// ## `missed_max`
    /// missed_max value
    /// ## `target_host`
    /// the host name or the ipv6 address that will be used as
    ///   target address in the NS packet
    ///
    /// # Returns
    ///
    /// the new #NMTeamLinkWatcher object, or [`None`] on error
    #[cfg(feature = "v1_12")]
    #[cfg_attr(docsrs, doc(cfg(feature = "v1_12")))]
    #[doc(alias = "nm_team_link_watcher_new_nsna_ping")]
    pub fn new_nsna_ping(init_wait: i32, interval: i32, missed_max: i32, target_host: &str) -> Result<TeamLinkWatcher, glib::Error> {
        assert_initialized_main_thread!();
        unsafe {
            let mut error = std::ptr::null_mut();
            let ret = ffi::nm_team_link_watcher_new_nsna_ping(init_wait, interval, missed_max, target_host.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_team_link_watcher_dup")]
#[must_use]
    pub fn dup(&self) -> TeamLinkWatcher {
        unsafe {
            from_glib_full(ffi::nm_team_link_watcher_dup(self.to_glib_none().0))
        }
    }

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

    /// Gets the delay_down interval (in milliseconds) that elapses between the link
    /// going down and the runner being notified about it.
    #[cfg(feature = "v1_12")]
    #[cfg_attr(docsrs, doc(cfg(feature = "v1_12")))]
    #[doc(alias = "nm_team_link_watcher_get_delay_down")]
    #[doc(alias = "get_delay_down")]
    pub fn delay_down(&self) -> i32 {
        unsafe {
            ffi::nm_team_link_watcher_get_delay_down(self.to_glib_none().0)
        }
    }

    /// Gets the delay_up interval (in milliseconds) that elapses between the link
    /// coming up and the runner being notified about it.
    #[cfg(feature = "v1_12")]
    #[cfg_attr(docsrs, doc(cfg(feature = "v1_12")))]
    #[doc(alias = "nm_team_link_watcher_get_delay_up")]
    #[doc(alias = "get_delay_up")]
    pub fn delay_up(&self) -> i32 {
        unsafe {
            ffi::nm_team_link_watcher_get_delay_up(self.to_glib_none().0)
        }
    }

    /// Gets the arp ping watcher flags.
    #[cfg(feature = "v1_12")]
    #[cfg_attr(docsrs, doc(cfg(feature = "v1_12")))]
    #[doc(alias = "nm_team_link_watcher_get_flags")]
    #[doc(alias = "get_flags")]
    pub fn flags(&self) -> TeamLinkWatcherArpPingFlags {
        unsafe {
            from_glib(ffi::nm_team_link_watcher_get_flags(self.to_glib_none().0))
        }
    }

    /// Gets the init_wait interval (in milliseconds) that the team port should
    /// wait before sending the first packet to the target host.
    #[cfg(feature = "v1_12")]
    #[cfg_attr(docsrs, doc(cfg(feature = "v1_12")))]
    #[doc(alias = "nm_team_link_watcher_get_init_wait")]
    #[doc(alias = "get_init_wait")]
    pub fn init_wait(&self) -> i32 {
        unsafe {
            ffi::nm_team_link_watcher_get_init_wait(self.to_glib_none().0)
        }
    }

    /// Gets the interval (in milliseconds) that the team port should wait between
    /// sending two check packets to the target host.
    #[cfg(feature = "v1_12")]
    #[cfg_attr(docsrs, doc(cfg(feature = "v1_12")))]
    #[doc(alias = "nm_team_link_watcher_get_interval")]
    #[doc(alias = "get_interval")]
    pub fn interval(&self) -> i32 {
        unsafe {
            ffi::nm_team_link_watcher_get_interval(self.to_glib_none().0)
        }
    }

    /// Gets the number of missed replies after which the link is considered down.
    #[cfg(feature = "v1_12")]
    #[cfg_attr(docsrs, doc(cfg(feature = "v1_12")))]
    #[doc(alias = "nm_team_link_watcher_get_missed_max")]
    #[doc(alias = "get_missed_max")]
    pub fn missed_max(&self) -> i32 {
        unsafe {
            ffi::nm_team_link_watcher_get_missed_max(self.to_glib_none().0)
        }
    }

    /// Gets the name of the link watcher to be used.
    #[cfg(feature = "v1_12")]
    #[cfg_attr(docsrs, doc(cfg(feature = "v1_12")))]
    #[doc(alias = "nm_team_link_watcher_get_name")]
    #[doc(alias = "get_name")]
    pub fn name(&self) -> glib::GString {
        unsafe {
            from_glib_none(ffi::nm_team_link_watcher_get_name(self.to_glib_none().0))
        }
    }

    /// Gets the ip address to be used as source for the link probing packets.
    #[cfg(feature = "v1_12")]
    #[cfg_attr(docsrs, doc(cfg(feature = "v1_12")))]
    #[doc(alias = "nm_team_link_watcher_get_source_host")]
    #[doc(alias = "get_source_host")]
    pub fn source_host(&self) -> glib::GString {
        unsafe {
            from_glib_none(ffi::nm_team_link_watcher_get_source_host(self.to_glib_none().0))
        }
    }

    /// Gets the host name/ip address to be used as destination for the link probing
    /// packets.
    #[cfg(feature = "v1_12")]
    #[cfg_attr(docsrs, doc(cfg(feature = "v1_12")))]
    #[doc(alias = "nm_team_link_watcher_get_target_host")]
    #[doc(alias = "get_target_host")]
    pub fn target_host(&self) -> glib::GString {
        unsafe {
            from_glib_none(ffi::nm_team_link_watcher_get_target_host(self.to_glib_none().0))
        }
    }

    /// Gets the VLAN tag ID to be used to outgoing link probes
    #[cfg(feature = "v1_16")]
    #[cfg_attr(docsrs, doc(cfg(feature = "v1_16")))]
    #[doc(alias = "nm_team_link_watcher_get_vlanid")]
    #[doc(alias = "get_vlanid")]
    pub fn vlanid(&self) -> i32 {
        unsafe {
            ffi::nm_team_link_watcher_get_vlanid(self.to_glib_none().0)
        }
    }
}

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

#[cfg(feature = "v1_12")]
#[cfg_attr(docsrs, doc(cfg(feature = "v1_12")))]
impl std::fmt::Display for TeamLinkWatcher {
    #[inline]
    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
        f.write_str(&self.name())
    }
}