Struct passcod_networkmanager::device::Device
source · pub struct Device { /* private fields */ }Expand description
A network device.
This provides the common interface for all network devices. The actual device types are
accessible via the Device::device_type() method and can be casted to the appropriate type
using the various to_* methods.
Implementations§
source§impl Device
impl Device
sourcepub async fn reapply(
&self,
connection: HashMap<&str, HashMap<&str, Value<'_>>>,
version_id: u64,
flags: u32
) -> Result<(), Error>
pub async fn reapply( &self, connection: HashMap<&str, HashMap<&str, Value<'_>>>, version_id: u64, flags: u32 ) -> Result<(), Error>
Attempts to update the configuration of a device without deactivating it.
NetworkManager has the concept of connections, which are profiles that contain the
configuration for a networking device. Those connections are exposed via D-Bus as
individual objects that can be created, modified and deleted. When activating such a
connection on a device, the profile is duplicated, becomes an applied connection, and is
used to configure the device (see Device::get_applied_connection()).
Subsequent modification of the original connection don’t propagate automatically to the
device’s applied connection profile (with exception of the firewall-zone and metered
properties). For the changes to take effect, you can either re-activate the connection, or
call Device::reapply().
The reapply call allows you to directly update the connection and reconfigure the device. Reapply can also be useful if the currently applied connection is equal to the connection that is about to be reapplied. This allows to reconfigure the device and revert external changes like removing or adding an IP address (which NetworkManager doesn’t revert automatically because it is assumed that the user made these changes intentionally outside of NetworkManager).
Reapply can make the applied connection different from the connection, just like updating the connection can make them different.
sourcepub async fn get_applied_connection(&self) -> Result<AppliedConnection, Error>
pub async fn get_applied_connection(&self) -> Result<AppliedConnection, Error>
Get the currently applied connection on the device.
This is a snapshot of the last activated connection on the device, ie the configuration that is currently applied on the device.
Usually this is the same as Connection::settings()
of the referenced connection. However, it can differ if the connection was subsequently
modified or the applied connection was modified by Device::reapply(). The
applied connection is set when activating a device or when calling reapply.
sourcepub async fn disconnect(&self) -> Result<(), Error>
pub async fn disconnect(&self) -> Result<(), Error>
Disconnects a device and prevents the device from automatically activating further connections without user intervention.
sourcepub async fn delete(&self) -> Result<(), Error>
pub async fn delete(&self) -> Result<(), Error>
Deletes a software device from NetworkManager and removes the interface from the system.
The method returns an error when called for a hardware device.
sourcepub async fn udi(&self) -> Result<String, Error>
pub async fn udi(&self) -> Result<String, Error>
OS-specific transient device hardware identifier.
This is an opaque string representing the underlying hardware for the device, and shouldn’t be used to keep track of individual devices.
For some device types (Bluetooth, Modems) it is an identifier used by the hardware service (ie bluez or ModemManager) to refer to that device, and client programs use it get additional information from those services which NetworkManager does not provide.
The Udi is not guaranteed to be consistent across reboots or hotplugs of the hardware. If you’re looking for a way to uniquely track each device in your application, use the object path. If you’re looking for a way to track a specific piece of hardware across reboot or hotplug, use a MAC address or USB serial number.
sourcepub async fn path(&self) -> Result<String, Error>
pub async fn path(&self) -> Result<String, Error>
The path of the device as exposed by the udev property ID_PATH.
sourcepub async fn interface(&self) -> Result<String, Error>
pub async fn interface(&self) -> Result<String, Error>
The name of the device’s control (and often data) interface.
sourcepub async fn ip_interface(&self) -> Result<String, Error>
pub async fn ip_interface(&self) -> Result<String, Error>
The name of the device’s data interface when available.
This property may not refer to the actual data interface until the device has successfully
established a data connection, indicated by Device::state() becoming
DeviceState::Activated.
sourcepub async fn driver_version(&self) -> Result<String, Error>
pub async fn driver_version(&self) -> Result<String, Error>
The version of the driver handling the device.
sourcepub async fn firmware_version(&self) -> Result<String, Error>
pub async fn firmware_version(&self) -> Result<String, Error>
The firmware version for the device.
sourcepub async fn capabilities(&self) -> Result<CapabilityFlags, Error>
pub async fn capabilities(&self) -> Result<CapabilityFlags, Error>
Flags describing the capabilities of the device.
sourcepub async fn state(&self) -> Result<DeviceState, Error>
pub async fn state(&self) -> Result<DeviceState, Error>
The current state of the device.
sourcepub async fn state_with_reason(
&self
) -> Result<(DeviceState, DeviceStateReason), Error>
pub async fn state_with_reason( &self ) -> Result<(DeviceState, DeviceStateReason), Error>
The current state of the device and the reason for that state.
pub async fn active_connection(&self) -> Result<Connection, Error>
sourcepub async fn is_managed(&self) -> Result<bool, Error>
pub async fn is_managed(&self) -> Result<bool, Error>
Whether or not this device is managed by NetworkManager.
sourcepub async fn set_managed(&self, managed: bool) -> Result<(), Error>
pub async fn set_managed(&self, managed: bool) -> Result<(), Error>
Set whether or not this device is managed by NetworkManager.
This has a similar effect to configuring the device as unmanaged via the
keyfile.unmanaged-devices setting in NetworkManager.conf.
Changes to this value are not persistent and lost after NetworkManager restarts.
sourcepub async fn can_autoconnect(&self) -> Result<bool, Error>
pub async fn can_autoconnect(&self) -> Result<bool, Error>
Indicates the device is allowed to autoconnect.
sourcepub async fn set_autoconnect(&self, autoconnect: bool) -> Result<(), Error>
pub async fn set_autoconnect(&self, autoconnect: bool) -> Result<(), Error>
Set whether or not this device is allowed to autoconnect.
If false, manual intervention is required before the device will automatically connect to a known network, such as activating a connection using the device, or setting this property to true.
This property cannot be set to true for default-unmanaged devices, since they never autoconnect.
sourcepub async fn is_firmware_missing(&self) -> Result<bool, Error>
pub async fn is_firmware_missing(&self) -> Result<bool, Error>
Indicates the device is likely missing firmware necessary for its operation.
sourcepub async fn is_plugin_missing(&self) -> Result<bool, Error>
pub async fn is_plugin_missing(&self) -> Result<bool, Error>
Indicates the NetworkManager plugin for the device is likely missing or misconfigured.
sourcepub async fn physical_port_id(&self) -> Result<Option<String>, Error>
pub async fn physical_port_id(&self) -> Result<Option<String>, Error>
An opaque indicator of the physical network port associated with the device.
This can be used to recognize when two seemingly-separate hardware devices are actually just different virtual interfaces to the same physical port.
sourcepub async fn mtu(&self) -> Result<u32, Error>
pub async fn mtu(&self) -> Result<u32, Error>
The MTU (Maximum Transmission Unit) of the device.
sourcepub async fn is_metered(&self) -> Result<MeteredStatus, Error>
pub async fn is_metered(&self) -> Result<MeteredStatus, Error>
The device’s metered state.
This is determined by the profile which is currently active. If the profile explicitly
specifies MeteredSetting::No or
MeteredSetting::Yes, then the device’s metered state
is as such. If the connection profile leaves it
MeteredSetting::Undecided (the default), then
NetworkManager tries to guess the metered state, for example based on the device type or on
DHCP options (like Android devices exposing a ANDROID_METERED DHCP vendor option). This
then leads to either MeteredStatus::GuessNo or MeteredStatus::GuessYes.
sourcepub async fn lldp_neighbors(
&self
) -> Result<Vec<HashMap<String, OwnedValue>>, Error>
pub async fn lldp_neighbors( &self ) -> Result<Vec<HashMap<String, OwnedValue>>, Error>
Array of LLDP neighbors.
sourcepub async fn is_real(&self) -> Result<bool, Error>
pub async fn is_real(&self) -> Result<bool, Error>
Whether the device is real or a placeholder.
Placeholder devices do not yet exist but could be automatically created by NetworkManager if one of their AvailableConnections was activated.
sourcepub async fn ipv4_connectivity(&self) -> Result<ConnectivityState, Error>
pub async fn ipv4_connectivity(&self) -> Result<ConnectivityState, Error>
The result of the last IPv4 connectivity check.
sourcepub async fn ipv6_connectivity(&self) -> Result<ConnectivityState, Error>
pub async fn ipv6_connectivity(&self) -> Result<ConnectivityState, Error>
The result of the last IPv6 connectivity check.
sourcepub async fn interface_flags(&self) -> Result<DeviceInterfaceFlags, Error>
pub async fn interface_flags(&self) -> Result<DeviceInterfaceFlags, Error>
The flags of the network interface.
sourcepub async fn hardware_address(&self) -> Result<String, Error>
pub async fn hardware_address(&self) -> Result<String, Error>
The hardware address of the device.
source§impl Device
impl Device
sourcepub async fn device_type(&self) -> Result<DeviceType, Error>
pub async fn device_type(&self) -> Result<DeviceType, Error>
The general type of the network device; ie Ethernet, Wi-Fi, etc.
source§impl Device
impl Device
sourcepub async fn to_wireless(&self) -> Result<Option<WirelessDevice>, Error>
pub async fn to_wireless(&self) -> Result<Option<WirelessDevice>, Error>
Cast this device to a wireless::WirelessDevice.