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

source

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.

source

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.

source

pub async fn disconnect(&self) -> Result<(), Error>

Disconnects a device and prevents the device from automatically activating further connections without user intervention.

source

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.

source

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.

source

pub async fn path(&self) -> Result<String, Error>

The path of the device as exposed by the udev property ID_PATH.

source

pub async fn interface(&self) -> Result<String, Error>

The name of the device’s control (and often data) interface.

source

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.

source

pub async fn driver(&self) -> Result<String, Error>

The driver handling the device.

source

pub async fn driver_version(&self) -> Result<String, Error>

The version of the driver handling the device.

source

pub async fn firmware_version(&self) -> Result<String, Error>

The firmware version for the device.

source

pub async fn capabilities(&self) -> Result<CapabilityFlags, Error>

Flags describing the capabilities of the device.

source

pub async fn state(&self) -> Result<DeviceState, Error>

The current state of the device.

source

pub async fn state_with_reason( &self ) -> Result<(DeviceState, DeviceStateReason), Error>

The current state of the device and the reason for that state.

source

pub async fn active_connection(&self) -> Result<Connection, Error>

source

pub async fn is_managed(&self) -> Result<bool, Error>

Whether or not this device is managed by NetworkManager.

source

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.

source

pub async fn can_autoconnect(&self) -> Result<bool, Error>

Indicates the device is allowed to autoconnect.

source

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.

source

pub async fn is_firmware_missing(&self) -> Result<bool, Error>

Indicates the device is likely missing firmware necessary for its operation.

source

pub async fn is_plugin_missing(&self) -> Result<bool, Error>

Indicates the NetworkManager plugin for the device is likely missing or misconfigured.

source

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.

source

pub async fn mtu(&self) -> Result<u32, Error>

The MTU (Maximum Transmission Unit) of the device.

source

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.

source

pub async fn lldp_neighbors( &self ) -> Result<Vec<HashMap<String, OwnedValue>>, Error>

Array of LLDP neighbors.

source

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.

source

pub async fn ipv4_connectivity(&self) -> Result<ConnectivityState, Error>

The result of the last IPv4 connectivity check.

source

pub async fn ipv6_connectivity(&self) -> Result<ConnectivityState, Error>

The result of the last IPv6 connectivity check.

source

pub async fn interface_flags(&self) -> Result<DeviceInterfaceFlags, Error>

The flags of the network interface.

source

pub async fn hardware_address(&self) -> Result<String, Error>

The hardware address of the device.

source§

impl Device

source

pub async fn device_type(&self) -> Result<DeviceType, Error>

The general type of the network device; ie Ethernet, Wi-Fi, etc.

source§

impl Device

source

pub async fn to_wireless(&self) -> Result<Option<WirelessDevice>, Error>

Cast this device to a wireless::WirelessDevice.

Trait Implementations§

source§

impl Clone for Device

source§

fn clone(&self) -> Device

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl Debug for Device

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl !RefUnwindSafe for Device

§

impl Send for Device

§

impl Sync for Device

§

impl Unpin for Device

§

impl !UnwindSafe for Device

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> Same for T

§

type Output = T

Should always be Self
source§

impl<T> ToOwned for T
where T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V

§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more