Skip to main content

Device

Struct Device 

Source
pub struct Device {
Show 32 fields pub object_path: OwnedObjectPath, pub udi: Property<String>, pub udev_path: Property<String>, pub interface: Property<String>, pub ip_interface: Property<String>, pub driver: Property<String>, pub driver_version: Property<String>, pub firmware_version: Property<String>, pub capabilities: Property<NMDeviceCapabilities>, pub state: Property<NMDeviceState>, pub state_reason: Property<(NMDeviceState, NMDeviceStateReason)>, pub active_connection: Property<OwnedObjectPath>, pub ip4_config: Property<OwnedObjectPath>, pub dhcp4_config: Property<OwnedObjectPath>, pub ip6_config: Property<OwnedObjectPath>, pub dhcp6_config: Property<OwnedObjectPath>, pub managed: Property<bool>, pub autoconnect: Property<bool>, pub firmware_missing: Property<bool>, pub nm_plugin_missing: Property<bool>, pub device_type: Property<NMDeviceType>, pub available_connections: Property<Vec<OwnedObjectPath>>, pub physical_port_id: Property<String>, pub mtu: Property<u32>, pub metered: Property<NMMetered>, pub lldp_neighbors: Property<Vec<LldpNeighbor>>, pub real: Property<bool>, pub ip4_connectivity: Property<NMConnectivityState>, pub ip6_connectivity: Property<NMConnectivityState>, pub interface_flags: Property<NMDeviceInterfaceFlags>, pub hw_address: Property<String>, pub ports: Property<Vec<OwnedObjectPath>>, /* private fields */
}
Expand description

Network device managed by NetworkManager.

Common functionality for all network interfaces (WiFi, ethernet, etc). Contains hardware information, state, configuration, and statistics.

Fields§

§object_path: OwnedObjectPath

D-Bus object path for this device.

§udi: Property<String>

Operating-system specific transient device hardware identifier. 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 (eg bluez or ModemManager) to refer to that device, and client programs use it get additional information from those services which NM does not provide. The Udi is not guaranteed to be consistent across reboots or hotplugs of the hardware.

§udev_path: Property<String>

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

§interface: Property<String>

The name of the device’s control (and often data) interface. Note that non UTF-8 characters are backslash escaped, so the resulting name may be longer then 15 characters. Use g_strcompress() to revert the escaping.

§ip_interface: Property<String>

The name of the device’s data interface when available. May not refer to the actual data interface until the device has successfully established a data connection, indicated by the device’s State becoming ACTIVATED. Note that non UTF-8 characters are backslash escaped, so the resulting name may be longer then 15 characters. Use g_strcompress() to revert the escaping.

§driver: Property<String>

The driver handling the device. Non-UTF-8 sequences are backslash escaped.

§driver_version: Property<String>

The version of the driver handling the device. Non-UTF-8 sequences are backslash escaped.

§firmware_version: Property<String>

The firmware version for the device. Non-UTF-8 sequences are backslash escaped.

§capabilities: Property<NMDeviceCapabilities>

Flags describing the capabilities of the device. See NMDeviceCapabilities.

§state: Property<NMDeviceState>

The current state of the device.

§state_reason: Property<(NMDeviceState, NMDeviceStateReason)>

The current state and reason for that state.

§active_connection: Property<OwnedObjectPath>

Object path of an ActiveConnection object that “owns” this device during activation. The ActiveConnection object tracks the life-cycle of a connection to a specific network and implements the org.freedesktop.NetworkManager.Connection.Active D-Bus interface.

§ip4_config: Property<OwnedObjectPath>

Object path of the Ip4Config object describing the configuration of the device. Only valid when the device is in the NM_DEVICE_STATE_ACTIVATED state.

§dhcp4_config: Property<OwnedObjectPath>

Object path of the Dhcp4Config object describing the DHCP options returned by the DHCP server. Only valid when the device is in the NM_DEVICE_STATE_ACTIVATED state.

§ip6_config: Property<OwnedObjectPath>

Object path of the Ip6Config object describing the configuration of the device. Only valid when the device is in the NM_DEVICE_STATE_ACTIVATED state.

§dhcp6_config: Property<OwnedObjectPath>

Object path of the Dhcp6Config object describing the DHCP options returned by the DHCP server. Only valid when the device is in the NM_DEVICE_STATE_ACTIVATED state.

§managed: Property<bool>

Whether or not this device is managed by NetworkManager. Setting this property has a similar effect to configuring the device as unmanaged via the keyfile.unmanaged-devices setting in NetworkManager.conf.

§autoconnect: Property<bool>

If TRUE, indicates the 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.

§firmware_missing: Property<bool>

If TRUE, indicates the device is likely missing firmware necessary for its operation.

§nm_plugin_missing: Property<bool>

If TRUE, indicates the NetworkManager plugin for the device is likely missing or misconfigured.

§device_type: Property<NMDeviceType>

The general type of the network device.

§available_connections: Property<Vec<OwnedObjectPath>>

An array of object paths of every configured connection that is currently ‘available’ through this device.

§physical_port_id: Property<String>

If non-empty, an (opaque) indicator of the physical network port associated with the device. Can be used to recognize when two seemingly-separate hardware devices are actually just different virtual interfaces to the same physical port.

§mtu: Property<u32>

The MTU of the device.

§metered: Property<NMMetered>

Whether the amount of traffic flowing through the device is subject to limitations, for example set by service providers.

§lldp_neighbors: Property<Vec<LldpNeighbor>>

Array of LLDP neighbors; each element is a dictionary mapping LLDP TLV names to variant boxed values.

§real: Property<bool>

True if the device exists, or False for placeholder devices that do not yet exist but could be automatically created by NetworkManager if one of their AvailableConnections was activated.

§ip4_connectivity: Property<NMConnectivityState>

The result of the last IPv4 connectivity check.

§ip6_connectivity: Property<NMConnectivityState>

The result of the last IPv6 connectivity check.

§interface_flags: Property<NMDeviceInterfaceFlags>

The flags of the network interface. See NMDeviceInterfaceFlags for the currently defined flags.

§hw_address: Property<String>

The hardware address of the device.

§ports: Property<Vec<OwnedObjectPath>>

The port devices of the controller device. Array of object paths of port devices for controller devices. For devices that are not controllers this is an empty array.

Implementations§

Source§

impl Device

Source

pub async fn set_managed(&self, managed: bool) -> Result<(), Error>

Whether or not this device is managed by NetworkManager.

§Errors

Returns error if the D-Bus operation fails.

Source

pub async fn set_autoconnect(&self, autoconnect: bool) -> Result<(), Error>

If TRUE, indicates the device is allowed to autoconnect.

§Errors

Returns error if the D-Bus operation fails.

Source

pub async fn reapply( &self, connection_settings: HashMap<String, HashMap<String, OwnedValue>>, version_id: u64, flags: u32, ) -> Result<(), Error>

Attempts to update device with new connection settings and properties.

§Arguments
  • connection - Optional connection settings
  • version_id - Settings version id (0 for current)
  • flags - Flags (none defined)
§Errors

Returns error if the reapply operation fails.

Source

pub async fn get_applied_connection( &self, flags: u32, ) -> Result<AppliedConnection, Error>

Get the currently applied connection on the device.

§Arguments
  • flags - Flags (none defined)
§Returns
  • Connection settings
  • Version id
§Errors

Returns error if getting the applied connection fails.

Source

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

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

§Errors

Returns error if the disconnect operation fails.

Source

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

Deletes a software device from NetworkManager and removes the interface from the system.

§Errors

Returns error if the delete operation fails.

Source

pub async fn set_managed_ext( &self, managed: NMDeviceManaged, flags: NMDeviceManagedFlags, ) -> Result<(), Error>

Sets the managed state with optional persistence. Since: NM 1.58.

§Errors

Returns error if the operation fails.

Source

pub async fn device_state_changed_signal( &self, ) -> Result<impl Stream<Item = DeviceStateChangedEvent>, Error>

Emitted when the device’s state changes.

§Errors

Returns error if D-Bus proxy creation fails.

Trait Implementations§

Source§

impl Clone for Device

Source§

fn clone(&self) -> Device

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Debug for Device

Source§

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

Formats the value using the given formatter. Read more
Source§

impl ModelMonitoring for Device

Source§

type Error = Error

Error type for monitoring operations.
Source§

async fn start_monitoring(self: Arc<Self>) -> Result<(), Self::Error>

Starts monitoring for state changes with shared ownership. Read more
Source§

impl Reactive for Device

Source§

type Context<'a> = DeviceParams<'a>

Context type for static fetching.
Source§

type LiveContext<'a> = LiveDeviceParams<'a>

Context type for live monitoring.
Source§

type Error = Error

Error type for reactive operations.
Source§

async fn get(params: Self::Context<'_>) -> Result<Self, Self::Error>

Fetches a static snapshot without monitoring.
Source§

async fn get_live( params: Self::LiveContext<'_>, ) -> Result<Arc<Self>, Self::Error>

Fetches with live monitoring and reactive updates.

Auto Trait Implementations§

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

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

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

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> ToOwned for T
where T: Clone,

Source§

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>,

Source§

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>,

Source§

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.
Source§

impl<T> WithSubscriber for T

Source§

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
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

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