1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
//! Typed active connection models.
use super::ActiveConnectionState;
/// A typed active NetworkManager connection.
#[non_exhaustive]
#[derive(Debug, Clone)]
pub enum ActiveConnection {
/// Active wired Ethernet connection.
Wired(ActiveWiredConnection),
/// Active Wi-Fi connection.
Wifi(ActiveWifiConnection),
/// Active VPN connection.
Vpn(ActiveVpnConnection),
/// Active connection type not modeled by the higher-level variants.
Other(ActiveOtherConnection),
}
/// An active wired Ethernet connection.
#[non_exhaustive]
#[derive(Debug, Clone)]
pub struct ActiveWiredConnection {
/// Human-visible connection id.
pub id: String,
/// Connection UUID.
pub uuid: String,
/// Interface name, if NetworkManager exposes the device.
pub interface: Option<String>,
/// Current hardware address, if exposed.
pub hw_address: Option<String>,
/// Raw Ethernet link speed in megabits per second, if exposed.
pub speed_mbps: Option<u32>,
/// Assigned IPv4 address with CIDR notation, if connected.
pub ip4_address: Option<String>,
/// Assigned IPv6 address with CIDR notation, if connected.
pub ip6_address: Option<String>,
/// Active connection state.
pub state: ActiveConnectionState,
}
/// An active Wi-Fi connection.
#[non_exhaustive]
#[derive(Debug, Clone)]
pub struct ActiveWifiConnection {
/// Human-visible connection id.
pub id: String,
/// Connection UUID.
pub uuid: String,
/// SSID of the active access point, or the connection id when unavailable.
pub ssid: String,
/// Interface name, if NetworkManager exposes the device.
pub interface: Option<String>,
/// BSSID of the active access point, if known.
pub bssid: Option<String>,
/// Signal strength percentage, if known.
pub strength: Option<u8>,
/// Assigned IPv4 address with CIDR notation, if connected.
pub ip4_address: Option<String>,
/// Assigned IPv6 address with CIDR notation, if connected.
pub ip6_address: Option<String>,
/// Active connection state.
pub state: ActiveConnectionState,
}
/// An active VPN connection.
#[non_exhaustive]
#[derive(Debug, Clone)]
pub struct ActiveVpnConnection {
/// Human-visible connection id.
pub id: String,
/// Connection UUID.
pub uuid: String,
/// Interface name, if NetworkManager exposes a VPN device.
pub interface: Option<String>,
/// Assigned IPv4 address with CIDR notation, if connected.
pub ip4_address: Option<String>,
/// Assigned IPv6 address with CIDR notation, if connected.
pub ip6_address: Option<String>,
/// Active connection state.
pub state: ActiveConnectionState,
}
/// An active connection not covered by the typed variants.
#[non_exhaustive]
#[derive(Debug, Clone)]
pub struct ActiveOtherConnection {
/// Human-visible connection id.
pub id: String,
/// Connection UUID.
pub uuid: String,
/// NM connection type string, if it could be resolved from settings.
pub connection_type: Option<String>,
/// Interface name, if NetworkManager exposes an associated device.
pub interface: Option<String>,
/// Assigned IPv4 address with CIDR notation, if connected.
pub ip4_address: Option<String>,
/// Assigned IPv6 address with CIDR notation, if connected.
pub ip6_address: Option<String>,
/// Active connection state.
pub state: ActiveConnectionState,
}