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

glib::wrapper! {
    ///
    ///
    /// ## Properties
    ///
    ///
    /// #### `peer`
    ///  The device's peer device.
    ///
    /// Readable
    /// <details><summary><h4>DeviceEthernet</h4></summary>
    ///
    ///
    /// #### `carrier`
    ///  Whether the device has carrier.
    ///
    /// Readable
    ///
    ///
    /// #### `perm-hw-address`
    ///  The permanent hardware (MAC) address of the device.
    ///
    /// Readable
    ///
    ///
    /// #### `s390-subchannels`
    ///  Identifies subchannels of this network device used for
    /// communication with z/VM or s390 host.
    ///
    /// Readable
    ///
    ///
    /// #### `speed`
    ///  The speed of the device.
    ///
    /// Readable
    /// </details>
    /// <details><summary><h4>Device</h4></summary>
    ///
    ///
    /// #### `active-connection`
    ///  The #NMActiveConnection object that "owns" this device during activation.
    ///
    /// Readable
    ///
    ///
    /// #### `autoconnect`
    ///  Whether the device can auto-activate a connection.
    ///
    /// The property setter is a synchronous D-Bus call. This is deprecated since 1.22.
    ///
    /// Readable | Writeable
    ///
    ///
    /// #### `available-connections`
    ///  The available connections of the device
    ///
    /// Readable
    ///
    ///
    /// #### `capabilities`
    ///  The capabilities of the device.
    ///
    /// Readable
    ///
    ///
    /// #### `device-type`
    ///  The numeric type of the device.
    ///
    /// Readable
    ///
    ///
    /// #### `dhcp4-config`
    ///  The IPv4 #NMDhcpConfig of the device.
    ///
    /// Readable
    ///
    ///
    /// #### `dhcp6-config`
    ///  The IPv6 #NMDhcpConfig of the device.
    ///
    /// Readable
    ///
    ///
    /// #### `driver`
    ///  The driver of the device.
    ///
    /// Readable
    ///
    ///
    /// #### `driver-version`
    ///  The version of the device driver.
    ///
    /// Readable
    ///
    ///
    /// #### `firmware-missing`
    ///  When [`true`] indicates the device is likely missing firmware required
    /// for its operation.
    ///
    /// Readable
    ///
    ///
    /// #### `firmware-version`
    ///  The firmware version of the device.
    ///
    /// Readable
    ///
    ///
    /// #### `hw-address`
    ///  The hardware address of the device.
    ///
    /// Readable
    ///
    ///
    /// #### `interface`
    ///  The interface of the device.
    ///
    /// Readable
    ///
    ///
    /// #### `interface-flags`
    ///  The interface flags.
    ///
    /// Readable
    ///
    ///
    /// #### `ip-interface`
    ///  The IP interface of the device which should be used for all IP-related
    /// operations like addressing and routing.
    ///
    /// Readable
    ///
    ///
    /// #### `ip4-config`
    ///  The #NMIP4Config of the device.
    ///
    /// Readable
    ///
    ///
    /// #### `ip4-connectivity`
    ///  The IPv4 connectivity state of the device.
    ///
    /// Readable
    ///
    ///
    /// #### `ip6-config`
    ///  The IPv6 #NMIPConfig of the device.
    ///
    /// Readable
    ///
    ///
    /// #### `ip6-connectivity`
    ///  The IPv6 connectivity state of the device.
    ///
    /// Readable
    ///
    ///
    /// #### `lldp-neighbors`
    ///  The LLDP neighbors.
    ///
    /// Readable
    ///
    ///
    /// #### `managed`
    ///  Whether the device is managed by NetworkManager.
    ///
    /// Readable
    ///
    ///
    /// #### `metered`
    ///  Whether the device is metered.
    ///
    /// Readable
    ///
    ///
    /// #### `mtu`
    ///  The MTU of the device.
    ///
    /// Readable
    ///
    ///
    /// #### `nm-plugin-missing`
    ///  When [`true`] indicates that the NetworkManager plugin for the device
    /// is not installed.
    ///
    /// Readable
    ///
    ///
    /// #### `path`
    ///  The device path as exposed by the udev property ID_PATH.
    ///
    /// The string is backslash escaped (C escaping) for invalid
    /// characters. The escaping can be reverted with g_strcompress(),
    /// however the result may not be valid UTF-8.
    ///
    /// Readable
    ///
    ///
    /// #### `physical-port-id`
    ///  The physical port ID of the device. (See
    /// nm_device_get_physical_port_id().)
    ///
    /// Readable
    ///
    ///
    /// #### `ports`
    ///  The port devices of the controller device. For devices that cannot be
    /// controllers this is likely to be always empty.
    ///
    /// Readable
    ///
    ///
    /// #### `product`
    ///  The product string of the device.
    ///
    /// Readable
    ///
    ///
    /// #### `real`
    ///  Whether the device is real or is a placeholder device that could
    /// be created automatically by NetworkManager if one of its
    /// #NMDevice:available-connections was activated.
    ///
    /// Readable
    ///
    ///
    /// #### `state`
    ///  The state of the device.
    ///
    /// Readable
    ///
    ///
    /// #### `state-reason`
    ///  The reason for the device state.
    ///
    /// Readable
    ///
    ///
    /// #### `udi`
    ///  An operating-system specific device hardware identifier; this is not
    /// unique to a specific hardware device across reboots or hotplugs.  It
    /// is an opaque string which for some device types (Bluetooth, Modem)
    /// contains an identifier provided by the underlying hardware service daemon
    /// such as Bluez or ModemManager, and clients can use this property to
    /// request more information about the device from those services.
    ///
    /// Readable
    ///
    ///
    /// #### `vendor`
    ///  The vendor string of the device.
    ///
    /// Readable
    /// </details>
    /// <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
    ///
    /// [`DeviceEthernetExt`][trait@crate::prelude::DeviceEthernetExt], [`DeviceExt`][trait@crate::prelude::DeviceExt], [`ObjectExt`][trait@crate::prelude::ObjectExt]
    #[doc(alias = "NMDeviceVeth")]
    pub struct DeviceVeth(Object<ffi::NMDeviceVeth, ffi::NMDeviceVethClass>) @extends DeviceEthernet, Device, Object;

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

impl DeviceVeth {
            // rustdoc-stripper-ignore-next
            /// Creates a new builder-pattern struct instance to construct [`DeviceVeth`] objects.
            ///
            /// This method returns an instance of [`DeviceVethBuilder`](crate::builders::DeviceVethBuilder) which can be used to create [`DeviceVeth`] objects.
            pub fn builder() -> DeviceVethBuilder {
                DeviceVethBuilder::new()
            }
        

    ///
    /// # Returns
    ///
    /// the device's peer device
    #[cfg(feature = "v1_42")]
    #[cfg_attr(docsrs, doc(cfg(feature = "v1_42")))]
    #[doc(alias = "nm_device_veth_get_peer")]
    #[doc(alias = "get_peer")]
    pub fn peer(&self) -> Device {
        unsafe {
            from_glib_none(ffi::nm_device_veth_get_peer(self.to_glib_none().0))
        }
    }

    #[cfg(not(feature = "v1_42"))]
    #[cfg_attr(docsrs, doc(cfg(not(feature = "v1_42"))))]
    pub fn peer(&self) -> Option<Device> {
        ObjectExt::property(self, "peer")
    }

    #[cfg(feature = "v1_30")]
    #[cfg_attr(docsrs, doc(cfg(feature = "v1_30")))]
    #[doc(alias = "peer")]
    pub fn connect_peer_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
        unsafe extern "C" fn notify_peer_trampoline<F: Fn(&DeviceVeth) + 'static>(this: *mut ffi::NMDeviceVeth, _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::peer".as_ptr() as *const _,
                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(notify_peer_trampoline::<F> as *const ())), Box_::into_raw(f))
        }
    }
}

// rustdoc-stripper-ignore-next
        /// A [builder-pattern] type to construct [`DeviceVeth`] objects.
        ///
        /// [builder-pattern]: https://doc.rust-lang.org/1.0.0/style/ownership/builders.html
#[must_use = "The builder must be built to be used"]
pub struct DeviceVethBuilder {
            builder: glib::object::ObjectBuilder<'static, DeviceVeth>,
        }

        impl DeviceVethBuilder {
        fn new() -> Self {
            Self { builder: glib::object::Object::builder() }
        }

                            /// Whether the device can auto-activate a connection.
                            ///
                            /// The property setter is a synchronous D-Bus call. This is deprecated since 1.22.
                            pub fn autoconnect(self, autoconnect: bool) -> Self {
                            Self { builder: self.builder.property("autoconnect", autoconnect), }
                        }

    // rustdoc-stripper-ignore-next
    /// Build the [`DeviceVeth`].
    #[must_use = "Building the object from the builder is usually expensive and is not expected to have side effects"]
    pub fn build(self) -> DeviceVeth {
assert_initialized_main_thread!();
    self.builder.build() }
}