Skip to content
Snippets Groups Projects
Verified Commit 7a1d47af authored by Eduardo Trujillo's avatar Eduardo Trujillo
Browse files

style: Run cargo fmt across the project

parent 57190ddf
No related branches found
No related tags found
No related merge requests found
Showing
with 819 additions and 236 deletions
......@@ -7,5 +7,5 @@ pub struct Config {
// Rules to evaluate when processing events.
//
// Rules are evaluated serially in the order provided.
pub rules: Vec<Rule>
}
\ No newline at end of file
pub rules: Vec<Rule>,
}
pub mod network_manager;
pub mod network_manager_access_point;
pub mod network_manager_settings;
pub mod network_manager_connection_active;
pub mod network_manager_device;
pub mod network_manager_settings;
This diff is collapsed.
// This code was autogenerated with `dbus-codegen-rust --file third_party/NetworkManager/introspection/org.freedesktop.NetworkManager.AccessPoint.xml -m None -c nonblock -o src/dbus_codegen/network_manager_access_point.rs`, see https://github.com/diwic/dbus-rs
use dbus as dbus;
use dbus;
#[allow(unused_imports)]
use dbus::arg;
use dbus::nonblock;
......@@ -17,45 +17,86 @@ pub trait OrgFreedesktopNetworkManagerAccessPoint {
fn last_seen(&self) -> nonblock::MethodReply<i32>;
}
impl<'a, T: nonblock::NonblockReply, C: ::std::ops::Deref<Target=T>> OrgFreedesktopNetworkManagerAccessPoint for nonblock::Proxy<'a, C> {
impl<'a, T: nonblock::NonblockReply, C: ::std::ops::Deref<Target = T>>
OrgFreedesktopNetworkManagerAccessPoint for nonblock::Proxy<'a, C>
{
fn flags(&self) -> nonblock::MethodReply<u32> {
<Self as nonblock::stdintf::org_freedesktop_dbus::Properties>::get(&self, "org.freedesktop.NetworkManager.AccessPoint", "Flags")
<Self as nonblock::stdintf::org_freedesktop_dbus::Properties>::get(
&self,
"org.freedesktop.NetworkManager.AccessPoint",
"Flags",
)
}
fn wpa_flags(&self) -> nonblock::MethodReply<u32> {
<Self as nonblock::stdintf::org_freedesktop_dbus::Properties>::get(&self, "org.freedesktop.NetworkManager.AccessPoint", "WpaFlags")
<Self as nonblock::stdintf::org_freedesktop_dbus::Properties>::get(
&self,
"org.freedesktop.NetworkManager.AccessPoint",
"WpaFlags",
)
}
fn rsn_flags(&self) -> nonblock::MethodReply<u32> {
<Self as nonblock::stdintf::org_freedesktop_dbus::Properties>::get(&self, "org.freedesktop.NetworkManager.AccessPoint", "RsnFlags")
<Self as nonblock::stdintf::org_freedesktop_dbus::Properties>::get(
&self,
"org.freedesktop.NetworkManager.AccessPoint",
"RsnFlags",
)
}
fn ssid(&self) -> nonblock::MethodReply<Vec<u8>> {
<Self as nonblock::stdintf::org_freedesktop_dbus::Properties>::get(&self, "org.freedesktop.NetworkManager.AccessPoint", "Ssid")
<Self as nonblock::stdintf::org_freedesktop_dbus::Properties>::get(
&self,
"org.freedesktop.NetworkManager.AccessPoint",
"Ssid",
)
}
fn frequency(&self) -> nonblock::MethodReply<u32> {
<Self as nonblock::stdintf::org_freedesktop_dbus::Properties>::get(&self, "org.freedesktop.NetworkManager.AccessPoint", "Frequency")
<Self as nonblock::stdintf::org_freedesktop_dbus::Properties>::get(
&self,
"org.freedesktop.NetworkManager.AccessPoint",
"Frequency",
)
}
fn hw_address(&self) -> nonblock::MethodReply<String> {
<Self as nonblock::stdintf::org_freedesktop_dbus::Properties>::get(&self, "org.freedesktop.NetworkManager.AccessPoint", "HwAddress")
<Self as nonblock::stdintf::org_freedesktop_dbus::Properties>::get(
&self,
"org.freedesktop.NetworkManager.AccessPoint",
"HwAddress",
)
}
fn mode(&self) -> nonblock::MethodReply<u32> {
<Self as nonblock::stdintf::org_freedesktop_dbus::Properties>::get(&self, "org.freedesktop.NetworkManager.AccessPoint", "Mode")
<Self as nonblock::stdintf::org_freedesktop_dbus::Properties>::get(
&self,
"org.freedesktop.NetworkManager.AccessPoint",
"Mode",
)
}
fn max_bitrate(&self) -> nonblock::MethodReply<u32> {
<Self as nonblock::stdintf::org_freedesktop_dbus::Properties>::get(&self, "org.freedesktop.NetworkManager.AccessPoint", "MaxBitrate")
<Self as nonblock::stdintf::org_freedesktop_dbus::Properties>::get(
&self,
"org.freedesktop.NetworkManager.AccessPoint",
"MaxBitrate",
)
}
fn strength(&self) -> nonblock::MethodReply<u8> {
<Self as nonblock::stdintf::org_freedesktop_dbus::Properties>::get(&self, "org.freedesktop.NetworkManager.AccessPoint", "Strength")
<Self as nonblock::stdintf::org_freedesktop_dbus::Properties>::get(
&self,
"org.freedesktop.NetworkManager.AccessPoint",
"Strength",
)
}
fn last_seen(&self) -> nonblock::MethodReply<i32> {
<Self as nonblock::stdintf::org_freedesktop_dbus::Properties>::get(&self, "org.freedesktop.NetworkManager.AccessPoint", "LastSeen")
<Self as nonblock::stdintf::org_freedesktop_dbus::Properties>::get(
&self,
"org.freedesktop.NetworkManager.AccessPoint",
"LastSeen",
)
}
}
// This code was autogenerated with `dbus-codegen-rust --file third_party/NetworkManager/introspection/org.freedesktop.NetworkManager.Connection.Active.xml -m None -c nonblock -o src/dbus_codegen/network_manager_connection_active.rs`, see https://github.com/diwic/dbus-rs
use dbus as dbus;
use dbus;
#[allow(unused_imports)]
use dbus::arg;
use dbus::nonblock;
......@@ -23,70 +23,135 @@ pub trait OrgFreedesktopNetworkManagerConnectionActive {
fn master(&self) -> nonblock::MethodReply<dbus::Path<'static>>;
}
impl<'a, T: nonblock::NonblockReply, C: ::std::ops::Deref<Target=T>> OrgFreedesktopNetworkManagerConnectionActive for nonblock::Proxy<'a, C> {
impl<'a, T: nonblock::NonblockReply, C: ::std::ops::Deref<Target = T>>
OrgFreedesktopNetworkManagerConnectionActive for nonblock::Proxy<'a, C>
{
fn connection(&self) -> nonblock::MethodReply<dbus::Path<'static>> {
<Self as nonblock::stdintf::org_freedesktop_dbus::Properties>::get(&self, "org.freedesktop.NetworkManager.Connection.Active", "Connection")
<Self as nonblock::stdintf::org_freedesktop_dbus::Properties>::get(
&self,
"org.freedesktop.NetworkManager.Connection.Active",
"Connection",
)
}
fn specific_object(&self) -> nonblock::MethodReply<dbus::Path<'static>> {
<Self as nonblock::stdintf::org_freedesktop_dbus::Properties>::get(&self, "org.freedesktop.NetworkManager.Connection.Active", "SpecificObject")
<Self as nonblock::stdintf::org_freedesktop_dbus::Properties>::get(
&self,
"org.freedesktop.NetworkManager.Connection.Active",
"SpecificObject",
)
}
fn id(&self) -> nonblock::MethodReply<String> {
<Self as nonblock::stdintf::org_freedesktop_dbus::Properties>::get(&self, "org.freedesktop.NetworkManager.Connection.Active", "Id")
<Self as nonblock::stdintf::org_freedesktop_dbus::Properties>::get(
&self,
"org.freedesktop.NetworkManager.Connection.Active",
"Id",
)
}
fn uuid(&self) -> nonblock::MethodReply<String> {
<Self as nonblock::stdintf::org_freedesktop_dbus::Properties>::get(&self, "org.freedesktop.NetworkManager.Connection.Active", "Uuid")
<Self as nonblock::stdintf::org_freedesktop_dbus::Properties>::get(
&self,
"org.freedesktop.NetworkManager.Connection.Active",
"Uuid",
)
}
fn type_(&self) -> nonblock::MethodReply<String> {
<Self as nonblock::stdintf::org_freedesktop_dbus::Properties>::get(&self, "org.freedesktop.NetworkManager.Connection.Active", "Type")
<Self as nonblock::stdintf::org_freedesktop_dbus::Properties>::get(
&self,
"org.freedesktop.NetworkManager.Connection.Active",
"Type",
)
}
fn devices(&self) -> nonblock::MethodReply<Vec<dbus::Path<'static>>> {
<Self as nonblock::stdintf::org_freedesktop_dbus::Properties>::get(&self, "org.freedesktop.NetworkManager.Connection.Active", "Devices")
<Self as nonblock::stdintf::org_freedesktop_dbus::Properties>::get(
&self,
"org.freedesktop.NetworkManager.Connection.Active",
"Devices",
)
}
fn state(&self) -> nonblock::MethodReply<u32> {
<Self as nonblock::stdintf::org_freedesktop_dbus::Properties>::get(&self, "org.freedesktop.NetworkManager.Connection.Active", "State")
<Self as nonblock::stdintf::org_freedesktop_dbus::Properties>::get(
&self,
"org.freedesktop.NetworkManager.Connection.Active",
"State",
)
}
fn state_flags(&self) -> nonblock::MethodReply<u32> {
<Self as nonblock::stdintf::org_freedesktop_dbus::Properties>::get(&self, "org.freedesktop.NetworkManager.Connection.Active", "StateFlags")
<Self as nonblock::stdintf::org_freedesktop_dbus::Properties>::get(
&self,
"org.freedesktop.NetworkManager.Connection.Active",
"StateFlags",
)
}
fn default(&self) -> nonblock::MethodReply<bool> {
<Self as nonblock::stdintf::org_freedesktop_dbus::Properties>::get(&self, "org.freedesktop.NetworkManager.Connection.Active", "Default")
<Self as nonblock::stdintf::org_freedesktop_dbus::Properties>::get(
&self,
"org.freedesktop.NetworkManager.Connection.Active",
"Default",
)
}
fn ip4_config(&self) -> nonblock::MethodReply<dbus::Path<'static>> {
<Self as nonblock::stdintf::org_freedesktop_dbus::Properties>::get(&self, "org.freedesktop.NetworkManager.Connection.Active", "Ip4Config")
<Self as nonblock::stdintf::org_freedesktop_dbus::Properties>::get(
&self,
"org.freedesktop.NetworkManager.Connection.Active",
"Ip4Config",
)
}
fn dhcp4_config(&self) -> nonblock::MethodReply<dbus::Path<'static>> {
<Self as nonblock::stdintf::org_freedesktop_dbus::Properties>::get(&self, "org.freedesktop.NetworkManager.Connection.Active", "Dhcp4Config")
<Self as nonblock::stdintf::org_freedesktop_dbus::Properties>::get(
&self,
"org.freedesktop.NetworkManager.Connection.Active",
"Dhcp4Config",
)
}
fn default6(&self) -> nonblock::MethodReply<bool> {
<Self as nonblock::stdintf::org_freedesktop_dbus::Properties>::get(&self, "org.freedesktop.NetworkManager.Connection.Active", "Default6")
<Self as nonblock::stdintf::org_freedesktop_dbus::Properties>::get(
&self,
"org.freedesktop.NetworkManager.Connection.Active",
"Default6",
)
}
fn ip6_config(&self) -> nonblock::MethodReply<dbus::Path<'static>> {
<Self as nonblock::stdintf::org_freedesktop_dbus::Properties>::get(&self, "org.freedesktop.NetworkManager.Connection.Active", "Ip6Config")
<Self as nonblock::stdintf::org_freedesktop_dbus::Properties>::get(
&self,
"org.freedesktop.NetworkManager.Connection.Active",
"Ip6Config",
)
}
fn dhcp6_config(&self) -> nonblock::MethodReply<dbus::Path<'static>> {
<Self as nonblock::stdintf::org_freedesktop_dbus::Properties>::get(&self, "org.freedesktop.NetworkManager.Connection.Active", "Dhcp6Config")
<Self as nonblock::stdintf::org_freedesktop_dbus::Properties>::get(
&self,
"org.freedesktop.NetworkManager.Connection.Active",
"Dhcp6Config",
)
}
fn vpn(&self) -> nonblock::MethodReply<bool> {
<Self as nonblock::stdintf::org_freedesktop_dbus::Properties>::get(&self, "org.freedesktop.NetworkManager.Connection.Active", "Vpn")
<Self as nonblock::stdintf::org_freedesktop_dbus::Properties>::get(
&self,
"org.freedesktop.NetworkManager.Connection.Active",
"Vpn",
)
}
fn master(&self) -> nonblock::MethodReply<dbus::Path<'static>> {
<Self as nonblock::stdintf::org_freedesktop_dbus::Properties>::get(&self, "org.freedesktop.NetworkManager.Connection.Active", "Master")
<Self as nonblock::stdintf::org_freedesktop_dbus::Properties>::get(
&self,
"org.freedesktop.NetworkManager.Connection.Active",
"Master",
)
}
}
......
// This code was autogenerated with `dbus-codegen-rust --file third_party/NetworkManager/introspection/org.freedesktop.NetworkManager.Device.xml -m None -c nonblock -o src/dbus_codegen/network_manager_device.rs`, see https://github.com/diwic/dbus-rs
use dbus as dbus;
use dbus;
#[allow(unused_imports)]
use dbus::arg;
use dbus::nonblock;
pub trait OrgFreedesktopNetworkManagerDevice {
fn reapply(&self, connection: ::std::collections::HashMap<&str, arg::PropMap>, version_id: u64, flags: u32) -> nonblock::MethodReply<()>;
fn get_applied_connection(&self, flags: u32) -> nonblock::MethodReply<(::std::collections::HashMap<String, arg::PropMap>, u64)>;
fn reapply(
&self,
connection: ::std::collections::HashMap<&str, arg::PropMap>,
version_id: u64,
flags: u32,
) -> nonblock::MethodReply<()>;
fn get_applied_connection(
&self,
flags: u32,
) -> nonblock::MethodReply<(::std::collections::HashMap<String, arg::PropMap>, u64)>;
fn disconnect(&self) -> nonblock::MethodReply<()>;
fn delete(&self) -> nonblock::MethodReply<()>;
fn udi(&self) -> nonblock::MethodReply<String>;
......@@ -44,14 +52,31 @@ pub trait OrgFreedesktopNetworkManagerDevice {
fn hw_address(&self) -> nonblock::MethodReply<String>;
}
impl<'a, T: nonblock::NonblockReply, C: ::std::ops::Deref<Target=T>> OrgFreedesktopNetworkManagerDevice for nonblock::Proxy<'a, C> {
fn reapply(&self, connection: ::std::collections::HashMap<&str, arg::PropMap>, version_id: u64, flags: u32) -> nonblock::MethodReply<()> {
self.method_call("org.freedesktop.NetworkManager.Device", "Reapply", (connection, version_id, flags, ))
}
fn get_applied_connection(&self, flags: u32) -> nonblock::MethodReply<(::std::collections::HashMap<String, arg::PropMap>, u64)> {
self.method_call("org.freedesktop.NetworkManager.Device", "GetAppliedConnection", (flags, ))
impl<'a, T: nonblock::NonblockReply, C: ::std::ops::Deref<Target = T>>
OrgFreedesktopNetworkManagerDevice for nonblock::Proxy<'a, C>
{
fn reapply(
&self,
connection: ::std::collections::HashMap<&str, arg::PropMap>,
version_id: u64,
flags: u32,
) -> nonblock::MethodReply<()> {
self.method_call(
"org.freedesktop.NetworkManager.Device",
"Reapply",
(connection, version_id, flags),
)
}
fn get_applied_connection(
&self,
flags: u32,
) -> nonblock::MethodReply<(::std::collections::HashMap<String, arg::PropMap>, u64)> {
self.method_call(
"org.freedesktop.NetworkManager.Device",
"GetAppliedConnection",
(flags,),
)
}
fn disconnect(&self) -> nonblock::MethodReply<()> {
......@@ -63,135 +88,269 @@ impl<'a, T: nonblock::NonblockReply, C: ::std::ops::Deref<Target=T>> OrgFreedesk
}
fn udi(&self) -> nonblock::MethodReply<String> {
<Self as nonblock::stdintf::org_freedesktop_dbus::Properties>::get(&self, "org.freedesktop.NetworkManager.Device", "Udi")
<Self as nonblock::stdintf::org_freedesktop_dbus::Properties>::get(
&self,
"org.freedesktop.NetworkManager.Device",
"Udi",
)
}
fn path(&self) -> nonblock::MethodReply<String> {
<Self as nonblock::stdintf::org_freedesktop_dbus::Properties>::get(&self, "org.freedesktop.NetworkManager.Device", "Path")
<Self as nonblock::stdintf::org_freedesktop_dbus::Properties>::get(
&self,
"org.freedesktop.NetworkManager.Device",
"Path",
)
}
fn interface(&self) -> nonblock::MethodReply<String> {
<Self as nonblock::stdintf::org_freedesktop_dbus::Properties>::get(&self, "org.freedesktop.NetworkManager.Device", "Interface")
<Self as nonblock::stdintf::org_freedesktop_dbus::Properties>::get(
&self,
"org.freedesktop.NetworkManager.Device",
"Interface",
)
}
fn ip_interface(&self) -> nonblock::MethodReply<String> {
<Self as nonblock::stdintf::org_freedesktop_dbus::Properties>::get(&self, "org.freedesktop.NetworkManager.Device", "IpInterface")
<Self as nonblock::stdintf::org_freedesktop_dbus::Properties>::get(
&self,
"org.freedesktop.NetworkManager.Device",
"IpInterface",
)
}
fn driver(&self) -> nonblock::MethodReply<String> {
<Self as nonblock::stdintf::org_freedesktop_dbus::Properties>::get(&self, "org.freedesktop.NetworkManager.Device", "Driver")
<Self as nonblock::stdintf::org_freedesktop_dbus::Properties>::get(
&self,
"org.freedesktop.NetworkManager.Device",
"Driver",
)
}
fn driver_version(&self) -> nonblock::MethodReply<String> {
<Self as nonblock::stdintf::org_freedesktop_dbus::Properties>::get(&self, "org.freedesktop.NetworkManager.Device", "DriverVersion")
<Self as nonblock::stdintf::org_freedesktop_dbus::Properties>::get(
&self,
"org.freedesktop.NetworkManager.Device",
"DriverVersion",
)
}
fn firmware_version(&self) -> nonblock::MethodReply<String> {
<Self as nonblock::stdintf::org_freedesktop_dbus::Properties>::get(&self, "org.freedesktop.NetworkManager.Device", "FirmwareVersion")
<Self as nonblock::stdintf::org_freedesktop_dbus::Properties>::get(
&self,
"org.freedesktop.NetworkManager.Device",
"FirmwareVersion",
)
}
fn capabilities(&self) -> nonblock::MethodReply<u32> {
<Self as nonblock::stdintf::org_freedesktop_dbus::Properties>::get(&self, "org.freedesktop.NetworkManager.Device", "Capabilities")
<Self as nonblock::stdintf::org_freedesktop_dbus::Properties>::get(
&self,
"org.freedesktop.NetworkManager.Device",
"Capabilities",
)
}
fn ip4_address(&self) -> nonblock::MethodReply<u32> {
<Self as nonblock::stdintf::org_freedesktop_dbus::Properties>::get(&self, "org.freedesktop.NetworkManager.Device", "Ip4Address")
<Self as nonblock::stdintf::org_freedesktop_dbus::Properties>::get(
&self,
"org.freedesktop.NetworkManager.Device",
"Ip4Address",
)
}
fn state(&self) -> nonblock::MethodReply<u32> {
<Self as nonblock::stdintf::org_freedesktop_dbus::Properties>::get(&self, "org.freedesktop.NetworkManager.Device", "State")
<Self as nonblock::stdintf::org_freedesktop_dbus::Properties>::get(
&self,
"org.freedesktop.NetworkManager.Device",
"State",
)
}
fn state_reason(&self) -> nonblock::MethodReply<(u32, u32)> {
<Self as nonblock::stdintf::org_freedesktop_dbus::Properties>::get(&self, "org.freedesktop.NetworkManager.Device", "StateReason")
<Self as nonblock::stdintf::org_freedesktop_dbus::Properties>::get(
&self,
"org.freedesktop.NetworkManager.Device",
"StateReason",
)
}
fn active_connection(&self) -> nonblock::MethodReply<dbus::Path<'static>> {
<Self as nonblock::stdintf::org_freedesktop_dbus::Properties>::get(&self, "org.freedesktop.NetworkManager.Device", "ActiveConnection")
<Self as nonblock::stdintf::org_freedesktop_dbus::Properties>::get(
&self,
"org.freedesktop.NetworkManager.Device",
"ActiveConnection",
)
}
fn ip4_config(&self) -> nonblock::MethodReply<dbus::Path<'static>> {
<Self as nonblock::stdintf::org_freedesktop_dbus::Properties>::get(&self, "org.freedesktop.NetworkManager.Device", "Ip4Config")
<Self as nonblock::stdintf::org_freedesktop_dbus::Properties>::get(
&self,
"org.freedesktop.NetworkManager.Device",
"Ip4Config",
)
}
fn dhcp4_config(&self) -> nonblock::MethodReply<dbus::Path<'static>> {
<Self as nonblock::stdintf::org_freedesktop_dbus::Properties>::get(&self, "org.freedesktop.NetworkManager.Device", "Dhcp4Config")
<Self as nonblock::stdintf::org_freedesktop_dbus::Properties>::get(
&self,
"org.freedesktop.NetworkManager.Device",
"Dhcp4Config",
)
}
fn ip6_config(&self) -> nonblock::MethodReply<dbus::Path<'static>> {
<Self as nonblock::stdintf::org_freedesktop_dbus::Properties>::get(&self, "org.freedesktop.NetworkManager.Device", "Ip6Config")
<Self as nonblock::stdintf::org_freedesktop_dbus::Properties>::get(
&self,
"org.freedesktop.NetworkManager.Device",
"Ip6Config",
)
}
fn dhcp6_config(&self) -> nonblock::MethodReply<dbus::Path<'static>> {
<Self as nonblock::stdintf::org_freedesktop_dbus::Properties>::get(&self, "org.freedesktop.NetworkManager.Device", "Dhcp6Config")
<Self as nonblock::stdintf::org_freedesktop_dbus::Properties>::get(
&self,
"org.freedesktop.NetworkManager.Device",
"Dhcp6Config",
)
}
fn managed(&self) -> nonblock::MethodReply<bool> {
<Self as nonblock::stdintf::org_freedesktop_dbus::Properties>::get(&self, "org.freedesktop.NetworkManager.Device", "Managed")
<Self as nonblock::stdintf::org_freedesktop_dbus::Properties>::get(
&self,
"org.freedesktop.NetworkManager.Device",
"Managed",
)
}
fn autoconnect(&self) -> nonblock::MethodReply<bool> {
<Self as nonblock::stdintf::org_freedesktop_dbus::Properties>::get(&self, "org.freedesktop.NetworkManager.Device", "Autoconnect")
<Self as nonblock::stdintf::org_freedesktop_dbus::Properties>::get(
&self,
"org.freedesktop.NetworkManager.Device",
"Autoconnect",
)
}
fn firmware_missing(&self) -> nonblock::MethodReply<bool> {
<Self as nonblock::stdintf::org_freedesktop_dbus::Properties>::get(&self, "org.freedesktop.NetworkManager.Device", "FirmwareMissing")
<Self as nonblock::stdintf::org_freedesktop_dbus::Properties>::get(
&self,
"org.freedesktop.NetworkManager.Device",
"FirmwareMissing",
)
}
fn nm_plugin_missing(&self) -> nonblock::MethodReply<bool> {
<Self as nonblock::stdintf::org_freedesktop_dbus::Properties>::get(&self, "org.freedesktop.NetworkManager.Device", "NmPluginMissing")
<Self as nonblock::stdintf::org_freedesktop_dbus::Properties>::get(
&self,
"org.freedesktop.NetworkManager.Device",
"NmPluginMissing",
)
}
fn device_type(&self) -> nonblock::MethodReply<u32> {
<Self as nonblock::stdintf::org_freedesktop_dbus::Properties>::get(&self, "org.freedesktop.NetworkManager.Device", "DeviceType")
<Self as nonblock::stdintf::org_freedesktop_dbus::Properties>::get(
&self,
"org.freedesktop.NetworkManager.Device",
"DeviceType",
)
}
fn available_connections(&self) -> nonblock::MethodReply<Vec<dbus::Path<'static>>> {
<Self as nonblock::stdintf::org_freedesktop_dbus::Properties>::get(&self, "org.freedesktop.NetworkManager.Device", "AvailableConnections")
<Self as nonblock::stdintf::org_freedesktop_dbus::Properties>::get(
&self,
"org.freedesktop.NetworkManager.Device",
"AvailableConnections",
)
}
fn physical_port_id(&self) -> nonblock::MethodReply<String> {
<Self as nonblock::stdintf::org_freedesktop_dbus::Properties>::get(&self, "org.freedesktop.NetworkManager.Device", "PhysicalPortId")
<Self as nonblock::stdintf::org_freedesktop_dbus::Properties>::get(
&self,
"org.freedesktop.NetworkManager.Device",
"PhysicalPortId",
)
}
fn mtu(&self) -> nonblock::MethodReply<u32> {
<Self as nonblock::stdintf::org_freedesktop_dbus::Properties>::get(&self, "org.freedesktop.NetworkManager.Device", "Mtu")
<Self as nonblock::stdintf::org_freedesktop_dbus::Properties>::get(
&self,
"org.freedesktop.NetworkManager.Device",
"Mtu",
)
}
fn metered(&self) -> nonblock::MethodReply<u32> {
<Self as nonblock::stdintf::org_freedesktop_dbus::Properties>::get(&self, "org.freedesktop.NetworkManager.Device", "Metered")
<Self as nonblock::stdintf::org_freedesktop_dbus::Properties>::get(
&self,
"org.freedesktop.NetworkManager.Device",
"Metered",
)
}
fn lldp_neighbors(&self) -> nonblock::MethodReply<Vec<arg::PropMap>> {
<Self as nonblock::stdintf::org_freedesktop_dbus::Properties>::get(&self, "org.freedesktop.NetworkManager.Device", "LldpNeighbors")
<Self as nonblock::stdintf::org_freedesktop_dbus::Properties>::get(
&self,
"org.freedesktop.NetworkManager.Device",
"LldpNeighbors",
)
}
fn real(&self) -> nonblock::MethodReply<bool> {
<Self as nonblock::stdintf::org_freedesktop_dbus::Properties>::get(&self, "org.freedesktop.NetworkManager.Device", "Real")
<Self as nonblock::stdintf::org_freedesktop_dbus::Properties>::get(
&self,
"org.freedesktop.NetworkManager.Device",
"Real",
)
}
fn ip4_connectivity(&self) -> nonblock::MethodReply<u32> {
<Self as nonblock::stdintf::org_freedesktop_dbus::Properties>::get(&self, "org.freedesktop.NetworkManager.Device", "Ip4Connectivity")
<Self as nonblock::stdintf::org_freedesktop_dbus::Properties>::get(
&self,
"org.freedesktop.NetworkManager.Device",
"Ip4Connectivity",
)
}
fn ip6_connectivity(&self) -> nonblock::MethodReply<u32> {
<Self as nonblock::stdintf::org_freedesktop_dbus::Properties>::get(&self, "org.freedesktop.NetworkManager.Device", "Ip6Connectivity")
<Self as nonblock::stdintf::org_freedesktop_dbus::Properties>::get(
&self,
"org.freedesktop.NetworkManager.Device",
"Ip6Connectivity",
)
}
fn interface_flags(&self) -> nonblock::MethodReply<u32> {
<Self as nonblock::stdintf::org_freedesktop_dbus::Properties>::get(&self, "org.freedesktop.NetworkManager.Device", "InterfaceFlags")
<Self as nonblock::stdintf::org_freedesktop_dbus::Properties>::get(
&self,
"org.freedesktop.NetworkManager.Device",
"InterfaceFlags",
)
}
fn hw_address(&self) -> nonblock::MethodReply<String> {
<Self as nonblock::stdintf::org_freedesktop_dbus::Properties>::get(&self, "org.freedesktop.NetworkManager.Device", "HwAddress")
<Self as nonblock::stdintf::org_freedesktop_dbus::Properties>::get(
&self,
"org.freedesktop.NetworkManager.Device",
"HwAddress",
)
}
fn set_managed(&self, value: bool) -> nonblock::MethodReply<()> {
<Self as nonblock::stdintf::org_freedesktop_dbus::Properties>::set(&self, "org.freedesktop.NetworkManager.Device", "Managed", value)
<Self as nonblock::stdintf::org_freedesktop_dbus::Properties>::set(
&self,
"org.freedesktop.NetworkManager.Device",
"Managed",
value,
)
}
fn set_autoconnect(&self, value: bool) -> nonblock::MethodReply<()> {
<Self as nonblock::stdintf::org_freedesktop_dbus::Properties>::set(&self, "org.freedesktop.NetworkManager.Device", "Autoconnect", value)
<Self as nonblock::stdintf::org_freedesktop_dbus::Properties>::set(
&self,
"org.freedesktop.NetworkManager.Device",
"Autoconnect",
value,
)
}
}
......
// This code was autogenerated with `dbus-codegen-rust --file third_party/NetworkManager/introspection/org.freedesktop.NetworkManager.Settings.xml -m None -c nonblock -o src/dbus_codegen/network_manager_settings.rs`, see https://github.com/diwic/dbus-rs
use dbus as dbus;
use dbus;
#[allow(unused_imports)]
use dbus::arg;
use dbus::nonblock;
......@@ -7,9 +7,20 @@ use dbus::nonblock;
pub trait OrgFreedesktopNetworkManagerSettings {
fn list_connections(&self) -> nonblock::MethodReply<Vec<dbus::Path<'static>>>;
fn get_connection_by_uuid(&self, uuid: &str) -> nonblock::MethodReply<dbus::Path<'static>>;
fn add_connection(&self, connection: ::std::collections::HashMap<&str, arg::PropMap>) -> nonblock::MethodReply<dbus::Path<'static>>;
fn add_connection_unsaved(&self, connection: ::std::collections::HashMap<&str, arg::PropMap>) -> nonblock::MethodReply<dbus::Path<'static>>;
fn add_connection2(&self, settings: ::std::collections::HashMap<&str, arg::PropMap>, flags: u32, args: arg::PropMap) -> nonblock::MethodReply<(dbus::Path<'static>, arg::PropMap)>;
fn add_connection(
&self,
connection: ::std::collections::HashMap<&str, arg::PropMap>,
) -> nonblock::MethodReply<dbus::Path<'static>>;
fn add_connection_unsaved(
&self,
connection: ::std::collections::HashMap<&str, arg::PropMap>,
) -> nonblock::MethodReply<dbus::Path<'static>>;
fn add_connection2(
&self,
settings: ::std::collections::HashMap<&str, arg::PropMap>,
flags: u32,
args: arg::PropMap,
) -> nonblock::MethodReply<(dbus::Path<'static>, arg::PropMap)>;
fn load_connections(&self, filenames: Vec<&str>) -> nonblock::MethodReply<(bool, Vec<String>)>;
fn reload_connections(&self) -> nonblock::MethodReply<bool>;
fn save_hostname(&self, hostname: &str) -> nonblock::MethodReply<()>;
......@@ -18,55 +29,111 @@ pub trait OrgFreedesktopNetworkManagerSettings {
fn can_modify(&self) -> nonblock::MethodReply<bool>;
}
impl<'a, T: nonblock::NonblockReply, C: ::std::ops::Deref<Target=T>> OrgFreedesktopNetworkManagerSettings for nonblock::Proxy<'a, C> {
impl<'a, T: nonblock::NonblockReply, C: ::std::ops::Deref<Target = T>>
OrgFreedesktopNetworkManagerSettings for nonblock::Proxy<'a, C>
{
fn list_connections(&self) -> nonblock::MethodReply<Vec<dbus::Path<'static>>> {
self.method_call("org.freedesktop.NetworkManager.Settings", "ListConnections", ())
.and_then(|r: (Vec<dbus::Path<'static>>, )| Ok(r.0, ))
self.method_call(
"org.freedesktop.NetworkManager.Settings",
"ListConnections",
(),
)
.and_then(|r: (Vec<dbus::Path<'static>>,)| Ok(r.0))
}
fn get_connection_by_uuid(&self, uuid: &str) -> nonblock::MethodReply<dbus::Path<'static>> {
self.method_call("org.freedesktop.NetworkManager.Settings", "GetConnectionByUuid", (uuid, ))
.and_then(|r: (dbus::Path<'static>, )| Ok(r.0, ))
self.method_call(
"org.freedesktop.NetworkManager.Settings",
"GetConnectionByUuid",
(uuid,),
)
.and_then(|r: (dbus::Path<'static>,)| Ok(r.0))
}
fn add_connection(&self, connection: ::std::collections::HashMap<&str, arg::PropMap>) -> nonblock::MethodReply<dbus::Path<'static>> {
self.method_call("org.freedesktop.NetworkManager.Settings", "AddConnection", (connection, ))
.and_then(|r: (dbus::Path<'static>, )| Ok(r.0, ))
fn add_connection(
&self,
connection: ::std::collections::HashMap<&str, arg::PropMap>,
) -> nonblock::MethodReply<dbus::Path<'static>> {
self.method_call(
"org.freedesktop.NetworkManager.Settings",
"AddConnection",
(connection,),
)
.and_then(|r: (dbus::Path<'static>,)| Ok(r.0))
}
fn add_connection_unsaved(&self, connection: ::std::collections::HashMap<&str, arg::PropMap>) -> nonblock::MethodReply<dbus::Path<'static>> {
self.method_call("org.freedesktop.NetworkManager.Settings", "AddConnectionUnsaved", (connection, ))
.and_then(|r: (dbus::Path<'static>, )| Ok(r.0, ))
fn add_connection_unsaved(
&self,
connection: ::std::collections::HashMap<&str, arg::PropMap>,
) -> nonblock::MethodReply<dbus::Path<'static>> {
self.method_call(
"org.freedesktop.NetworkManager.Settings",
"AddConnectionUnsaved",
(connection,),
)
.and_then(|r: (dbus::Path<'static>,)| Ok(r.0))
}
fn add_connection2(&self, settings: ::std::collections::HashMap<&str, arg::PropMap>, flags: u32, args: arg::PropMap) -> nonblock::MethodReply<(dbus::Path<'static>, arg::PropMap)> {
self.method_call("org.freedesktop.NetworkManager.Settings", "AddConnection2", (settings, flags, args, ))
fn add_connection2(
&self,
settings: ::std::collections::HashMap<&str, arg::PropMap>,
flags: u32,
args: arg::PropMap,
) -> nonblock::MethodReply<(dbus::Path<'static>, arg::PropMap)> {
self.method_call(
"org.freedesktop.NetworkManager.Settings",
"AddConnection2",
(settings, flags, args),
)
}
fn load_connections(&self, filenames: Vec<&str>) -> nonblock::MethodReply<(bool, Vec<String>)> {
self.method_call("org.freedesktop.NetworkManager.Settings", "LoadConnections", (filenames, ))
self.method_call(
"org.freedesktop.NetworkManager.Settings",
"LoadConnections",
(filenames,),
)
}
fn reload_connections(&self) -> nonblock::MethodReply<bool> {
self.method_call("org.freedesktop.NetworkManager.Settings", "ReloadConnections", ())
.and_then(|r: (bool, )| Ok(r.0, ))
self.method_call(
"org.freedesktop.NetworkManager.Settings",
"ReloadConnections",
(),
)
.and_then(|r: (bool,)| Ok(r.0))
}
fn save_hostname(&self, hostname: &str) -> nonblock::MethodReply<()> {
self.method_call("org.freedesktop.NetworkManager.Settings", "SaveHostname", (hostname, ))
self.method_call(
"org.freedesktop.NetworkManager.Settings",
"SaveHostname",
(hostname,),
)
}
fn connections(&self) -> nonblock::MethodReply<Vec<dbus::Path<'static>>> {
<Self as nonblock::stdintf::org_freedesktop_dbus::Properties>::get(&self, "org.freedesktop.NetworkManager.Settings", "Connections")
<Self as nonblock::stdintf::org_freedesktop_dbus::Properties>::get(
&self,
"org.freedesktop.NetworkManager.Settings",
"Connections",
)
}
fn hostname(&self) -> nonblock::MethodReply<String> {
<Self as nonblock::stdintf::org_freedesktop_dbus::Properties>::get(&self, "org.freedesktop.NetworkManager.Settings", "Hostname")
<Self as nonblock::stdintf::org_freedesktop_dbus::Properties>::get(
&self,
"org.freedesktop.NetworkManager.Settings",
"Hostname",
)
}
fn can_modify(&self) -> nonblock::MethodReply<bool> {
<Self as nonblock::stdintf::org_freedesktop_dbus::Properties>::get(&self, "org.freedesktop.NetworkManager.Settings", "CanModify")
<Self as nonblock::stdintf::org_freedesktop_dbus::Properties>::get(
&self,
"org.freedesktop.NetworkManager.Settings",
"CanModify",
)
}
}
......
use std::{sync::Arc, time::Duration};
use dbus::{Path, nonblock::{Proxy, SyncConnection}};
use dbus::{
nonblock::{Proxy, SyncConnection},
Path,
};
use crate::dbus_codegen::{network_manager_connection_active::{OrgFreedesktopNetworkManagerConnectionActive}};
use crate::dbus_codegen::network_manager_connection_active::OrgFreedesktopNetworkManagerConnectionActive;
pub struct ConnectionWrapper<'a> {
conn: Arc<SyncConnection>,
proxy: Box<dyn OrgFreedesktopNetworkManagerConnectionActive + Send + Sync + 'a>,
path: Path<'a>
path: Path<'a>,
}
impl<'a> ConnectionWrapper<'a> {
......@@ -27,7 +30,7 @@ impl<'a> ConnectionWrapper<'a> {
ConnectionWrapper {
conn,
proxy: Box::new(proxy),
path
path,
}
}
......
......@@ -10,4 +10,4 @@ pub enum ConnectivityState {
Portal = 2,
Limited = 3,
Full = 4,
}
\ No newline at end of file
}
......@@ -17,4 +17,4 @@ pub enum DeviceState {
Activated = 100,
Deactivating = 110,
Failed = 120,
}
\ No newline at end of file
}
......@@ -13,7 +13,11 @@ use crate::dbus_codegen::network_manager::{
OrgFreedesktopNetworkManagerDeviceRemoved,
};
use super::{active_connection::ActiveConnectionWrapper, connection::ConnectionWrapper, connectivity_state::ConnectivityState, device::DeviceWrapper, signal::SignalStreamWrapper, state::State};
use super::{
active_connection::ActiveConnectionWrapper, connection::ConnectionWrapper,
connectivity_state::ConnectivityState, device::DeviceWrapper, signal::SignalStreamWrapper,
state::State,
};
const PATH: &str = "/org/freedesktop/NetworkManager";
......@@ -98,8 +102,7 @@ impl<'a> ManagerWrapper<'a> {
}
pub async fn get_state(&self) -> Result<State> {
Ok(FromPrimitive::from_u32(self.inner.state().await?)
.unwrap_or(State::Unknown))
Ok(FromPrimitive::from_u32(self.inner.state().await?).unwrap_or(State::Unknown))
}
pub async fn get_last_connectivity_state(&self) -> Result<ConnectivityState> {
......
......@@ -16,8 +16,7 @@ pub struct ManagerSettingsWrapper<'a> {
}
impl<'a> ManagerSettingsWrapper<'a> {
pub async fn from_connection(conn: &Arc<SyncConnection>) -> ManagerSettingsWrapper<'a>
{
pub async fn from_connection(conn: &Arc<SyncConnection>) -> ManagerSettingsWrapper<'a> {
let proxy: Proxy<'a, Arc<SyncConnection>> = Proxy::new(
"org.freedesktop.NetworkManager",
"/org/freedesktop/NetworkManager/Settings",
......
......@@ -6,4 +6,4 @@ pub mod device_state;
pub mod manager;
pub mod manager_settings;
pub mod signal;
pub mod state;
\ No newline at end of file
pub mod state;
use std::sync::Arc;
use dbus::{Message, MessageType, Path, arg::ReadAll, message::{MatchRule, SignalArgs}, nonblock::{MsgMatch, SyncConnection}, strings::BusName};
use dbus::{
arg::ReadAll,
message::{MatchRule, SignalArgs},
nonblock::{MsgMatch, SyncConnection},
strings::BusName,
Message, MessageType, Path,
};
use futures_channel::mpsc::UnboundedReceiver;
use tokio_stream::{StreamExt, };
use tokio_stream::StreamExt;
pub struct SignalStreamWrapper<T> {
conn: Arc<SyncConnection>,
......@@ -27,7 +33,10 @@ impl<T> SignalStreamWrapper<T> {
conn: &Arc<SyncConnection>,
sender: Option<BusName<'_>>,
path: Option<Path<'_>>,
) -> anyhow::Result<SignalStreamWrapper<T>> where T: ReadAll + Send + SignalArgs + 'static {
) -> anyhow::Result<SignalStreamWrapper<T>>
where
T: ReadAll + Send + SignalArgs + 'static,
{
let mut match_rule = MatchRule::default();
match_rule.sender = sender.map(|s| s.into_static());
......@@ -36,11 +45,7 @@ impl<T> SignalStreamWrapper<T> {
match_rule.interface = Some(T::INTERFACE.into());
match_rule.member = Some(T::NAME.into());
let (msg_match, stream) =
conn
.add_match(match_rule)
.await?
.stream::<T>();
let (msg_match, stream) = conn.add_match(match_rule).await?.stream::<T>();
Ok(Self::from_stream(conn, msg_match, stream))
}
......@@ -50,10 +55,8 @@ impl<T> SignalStreamWrapper<T> {
}
pub async fn dispose(&self) -> anyhow::Result<()> {
let result = self.conn
.remove_match(self.msg_match.token())
.await?;
let result = self.conn.remove_match(self.msg_match.token()).await?;
Ok(result)
}
}
\ No newline at end of file
}
......@@ -13,4 +13,4 @@ pub enum State {
ConnectedLocal = 50,
ConnectedSite = 60,
ConnectedGlobal = 70,
}
\ No newline at end of file
}
......@@ -3,9 +3,15 @@ use std::sync::Arc;
use anyhow::Result;
use dbus::{nonblock::SyncConnection, Path};
use num_traits::FromPrimitive;
use tokio::{sync::{broadcast, mpsc}, task::JoinHandle};
use tokio::{
sync::{broadcast, mpsc},
task::JoinHandle,
};
use crate::{dbus_wrappers::{device::DeviceWrapper, device_state::DeviceState}, event::Event};
use crate::{
dbus_wrappers::{device::DeviceWrapper, device_state::DeviceState},
event::Event,
};
pub async fn watch_device<'a>(
conn: &Arc<SyncConnection>,
......@@ -27,7 +33,7 @@ pub async fn watch_device<'a>(
tokio::select! {
Some((msg, signal)) = state_changed_signal.next() => {
log::debug!("Got StateChanged signal for {}: {:?}", device.get_path(), &msg);
match FromPrimitive::from_u32(signal.new_state) {
Some(DeviceState::Activated) => {
event_tx.send(Event::DeviceActivated {
......
......@@ -8,7 +8,11 @@ use tokio::{
task::JoinHandle,
};
use crate::{config::Config, dbus_wrappers::{connectivity_state::ConnectivityState, state::State}, identifier::DeviceIdentifier};
use crate::{
config::Config,
dbus_wrappers::{connectivity_state::ConnectivityState, state::State},
identifier::DeviceIdentifier,
};
#[derive(Debug)]
pub enum Event {
......@@ -164,10 +168,9 @@ impl Trigger {
}
None => Ok(true),
},
(
Event::StateChanged { state },
Trigger::StateChanged { states },
) => Ok(states.contains(state)),
(Event::StateChanged { state }, Trigger::StateChanged { states }) => {
Ok(states.contains(state))
}
_ => Ok(false),
}
}
......
......@@ -33,7 +33,10 @@ impl DeviceIdentifier {
}
}
pub async fn into_device(&self, conn: &Arc<SyncConnection>) -> Result<Option<DeviceWrapper<'static>>> {
pub async fn into_device(
&self,
conn: &Arc<SyncConnection>,
) -> Result<Option<DeviceWrapper<'static>>> {
match self.into_path(conn).await {
Ok(device_path) => {
let device = DeviceWrapper::from_path(conn.clone(), device_path).await;
......@@ -44,7 +47,7 @@ impl DeviceIdentifier {
log::warn!("Unable to resolve device identifier: {:?} {:?}", self, err);
Ok(None)
},
}
}
}
}
......
use std::{collections::HashMap, sync::Arc};
use anyhow::{Error, Result};
use dbus::{Path, nonblock::SyncConnection};
use tokio::{sync::{broadcast, mpsc}, task::JoinHandle};
use dbus::{nonblock::SyncConnection, Path};
use tokio::{
sync::{broadcast, mpsc},
task::JoinHandle,
};
use crate::{dbus_wrappers::manager::ManagerWrapper, device_watcher::watch_device, event::Event};
......@@ -11,7 +14,11 @@ struct WatchedDevice {
stop_signal_tx: broadcast::Sender<()>,
}
pub async fn watch(conn: &Arc<SyncConnection>, mut stop_signal_rx: broadcast::Receiver<()>, event_tx: mpsc::Sender<Event>) -> Result<JoinHandle<Result<()>>> {
pub async fn watch(
conn: &Arc<SyncConnection>,
mut stop_signal_rx: broadcast::Receiver<()>,
event_tx: mpsc::Sender<Event>,
) -> Result<JoinHandle<Result<()>>> {
let conn2 = conn.clone();
log::info!("Starting NetworkManager watcher task");
......@@ -31,12 +38,21 @@ pub async fn watch(conn: &Arc<SyncConnection>, mut stop_signal_rx: broadcast::Re
for device_path in manager.get_all_device_paths().await? {
let (stop_signal_tx, _stop_signal_rx) = broadcast::channel(1);
let device_watcher_handle = watch_device(&conn2, stop_signal_tx.subscribe(), event_tx.clone(), device_path.clone()).await?;
watched_devices.insert(device_path, WatchedDevice {
handle: device_watcher_handle,
stop_signal_tx
});
let device_watcher_handle = watch_device(
&conn2,
stop_signal_tx.subscribe(),
event_tx.clone(),
device_path.clone(),
)
.await?;
watched_devices.insert(
device_path,
WatchedDevice {
handle: device_watcher_handle,
stop_signal_tx,
},
);
}
loop {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment