Skip to content

Commit

Permalink
Run cargo clippy --fix --all
Browse files Browse the repository at this point in the history
  • Loading branch information
X3n0m0rph59 committed Sep 1, 2023
1 parent 3421dd2 commit b7ee203
Show file tree
Hide file tree
Showing 14 changed files with 56 additions and 100 deletions.
6 changes: 3 additions & 3 deletions eruption-gui-gtk3/src/ui/canvas.rs
Original file line number Diff line number Diff line change
Expand Up @@ -511,7 +511,7 @@ pub fn fetch_device_info(_builder: &gtk::Builder) -> Result<()> {

// add keyboard devices
for _device_ids in devices.0 {
let device = get_keyboard_device(index as u64)?;
let device = get_keyboard_device(index)?;

let make = device.get_make_and_model().0;
let model = device.get_make_and_model().1;
Expand All @@ -523,7 +523,7 @@ pub fn fetch_device_info(_builder: &gtk::Builder) -> Result<()> {

// add mouse devices
for _device_ids in devices.1 {
let device = get_mouse_device(index as u64)?;
let device = get_mouse_device(index)?;

let make = device.get_make_and_model().0;
let model = device.get_make_and_model().1;
Expand All @@ -535,7 +535,7 @@ pub fn fetch_device_info(_builder: &gtk::Builder) -> Result<()> {

// add misc devices
for _device_ids in devices.2 {
let device = get_misc_device(index as u64)?;
let device = get_misc_device(index)?;

let make = device.get_make_and_model().0;
let model = device.get_make_and_model().1;
Expand Down
6 changes: 3 additions & 3 deletions eruption-process-monitor/src/sensors/wayland.rs
Original file line number Diff line number Diff line change
Expand Up @@ -395,7 +395,7 @@ impl Dispatch<ZwlrForeignToplevelHandleV1, ()> for AppData {
let _previous = WAYLAND_TOPLEVEL_WINDOWS
.write()
.entry(object)
.or_insert_with(WaylandToplevelAttributes::default)
.or_default()
.title
.replace(title);
}
Expand All @@ -406,7 +406,7 @@ impl Dispatch<ZwlrForeignToplevelHandleV1, ()> for AppData {
let _previous = WAYLAND_TOPLEVEL_WINDOWS
.write()
.entry(object)
.or_insert_with(WaylandToplevelAttributes::default)
.or_default()
.app_id
.replace(app_id);
}
Expand All @@ -423,7 +423,7 @@ impl Dispatch<ZwlrForeignToplevelHandleV1, ()> for AppData {
let _previous = WAYLAND_TOPLEVEL_WINDOWS
.write()
.entry(object)
.or_insert_with(WaylandToplevelAttributes::default)
.or_default()
.state
.replace(state);
}
Expand Down
4 changes: 2 additions & 2 deletions eruption/src/hwdevices/keyboards/roccat_vulcan_1xx.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1023,10 +1023,10 @@ impl KeyboardDeviceTrait for RoccatVulcan1xx {
fn compute_offset(i: usize) -> usize {
// TODO: Implement this

let index = (i / 12) * 36 + (i % 12);

// *COLS_TOPOLOGY.get(index).unwrap_or(&0) as usize

index
(i / 12) * 36 + (i % 12)
}

if self.allocated_zone.enabled {
Expand Down
4 changes: 2 additions & 2 deletions eruption/src/plugins/profiles.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ use crate::plugins::Plugin;

//#[derive(Debug, Fail)]
//pub enum ProfilesPluginError {
////#[error("Unknown error: {}", description)]
////UnknownError { description: String },
///#[error("Unknown error: {}", description)]
///UnknownError { description: String },
//}

/// A plugin that enables Eruption to switch profiles, based on the current system state
Expand Down
2 changes: 1 addition & 1 deletion eruption/src/scripting/script.rs
Original file line number Diff line number Diff line change
Expand Up @@ -487,7 +487,7 @@ fn realize_color_map() -> Result<RunningScriptResult> {
// signal readiness / notify the main thread that we are done
let val = *crate::COLOR_MAPS_READY_CONDITION.0.lock();

let val = val.checked_sub(1).unwrap_or_else(|| {
let val = val.checked_sub(1).unwrap_or({
// this will happen during switching of profiles
// trace!("Incorrect state in locking code detected");

Expand Down
2 changes: 1 addition & 1 deletion eruption/src/util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ pub fn get_script_dirs() -> Vec<PathBuf> {
c.get::<Vec<String>>("global.script_dirs")
.unwrap_or_else(|_| vec![])
})
.unwrap_or_else(std::vec::Vec::new);
.unwrap_or_default();

let mut script_dirs = script_dirs
.iter()
Expand Down
9 changes: 3 additions & 6 deletions support/dbus/interfaces/rust/org.eruption.fx_proxy/effects.rs
Original file line number Diff line number Diff line change
Expand Up @@ -89,8 +89,7 @@ impl<'a, T: blocking::BlockingSender, C: ::std::ops::Deref<Target = T>>
OrgFreedesktopDBusIntrospectable for blocking::Proxy<'a, C>
{
fn introspect(&self) -> Result<String, dbus::Error> {
self.method_call("org.freedesktop.DBus.Introspectable", "Introspect", ())
.and_then(|r: (String,)| Ok(r.0))
self.method_call("org.freedesktop.DBus.Introspectable", "Introspect", ()).map(|r: (String,)| r.0)
}
}

Expand Down Expand Up @@ -153,17 +152,15 @@ impl<'a, T: blocking::BlockingSender, C: ::std::ops::Deref<Target = T>> OrgFreed
"org.freedesktop.DBus.Properties",
"Get",
(interface_name, property_name),
)
.and_then(|r: (arg::Variant<Box<dyn arg::RefArg + 'static>>,)| Ok(r.0))
).map(|r: (arg::Variant<Box<dyn arg::RefArg + 'static>>,)| r.0)
}

fn get_all(&self, interface_name: &str) -> Result<arg::PropMap, dbus::Error> {
self.method_call(
"org.freedesktop.DBus.Properties",
"GetAll",
(interface_name,),
)
.and_then(|r: (arg::PropMap,)| Ok(r.0))
).map(|r: (arg::PropMap,)| r.0)
}

fn set(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,7 @@ impl<'a, T: blocking::BlockingSender, C: ::std::ops::Deref<Target = T>>
OrgEruptionProcessMonitorRules for blocking::Proxy<'a, C>
{
fn enum_rules(&self) -> Result<Vec<(String, String, String, String)>, dbus::Error> {
self.method_call("org.eruption.process_monitor.Rules", "EnumRules", ())
.and_then(|r: (Vec<(String, String, String, String)>,)| Ok(r.0))
self.method_call("org.eruption.process_monitor.Rules", "EnumRules", ()).map(|r: (Vec<(String, String, String, String)>,)| r.0)
}

fn set_rules(&self, rules: Vec<(&str, &str, &str, &str)>) -> Result<(), dbus::Error> {
Expand All @@ -56,7 +55,6 @@ impl<'a, T: blocking::BlockingSender, C: ::std::ops::Deref<Target = T>>
OrgFreedesktopDBusIntrospectable for blocking::Proxy<'a, C>
{
fn introspect(&self) -> Result<String, dbus::Error> {
self.method_call("org.freedesktop.DBus.Introspectable", "Introspect", ())
.and_then(|r: (String,)| Ok(r.0))
self.method_call("org.freedesktop.DBus.Introspectable", "Introspect", ()).map(|r: (String,)| r.0)
}
}
12 changes: 4 additions & 8 deletions support/dbus/interfaces/rust/org.eruption/canvas.rs
Original file line number Diff line number Diff line change
Expand Up @@ -126,8 +126,7 @@ impl<'a, T: blocking::BlockingSender, C: ::std::ops::Deref<Target = T>> OrgErupt
fn get_devices_zone_allocations(
&self,
) -> Result<Vec<(u64, (i32, i32, i32, i32, bool))>, dbus::Error> {
self.method_call("org.eruption.Canvas", "GetDevicesZoneAllocations", ())
.and_then(|r: (Vec<(u64, (i32, i32, i32, i32, bool))>,)| Ok(r.0))
self.method_call("org.eruption.Canvas", "GetDevicesZoneAllocations", ()).map(|r: (Vec<(u64, (i32, i32, i32, i32, bool))>,)| r.0)
}

fn set_device_zone_allocation(
Expand Down Expand Up @@ -211,8 +210,7 @@ impl<'a, T: blocking::BlockingSender, C: ::std::ops::Deref<Target = T>>
OrgFreedesktopDBusIntrospectable for blocking::Proxy<'a, C>
{
fn introspect(&self) -> Result<String, dbus::Error> {
self.method_call("org.freedesktop.DBus.Introspectable", "Introspect", ())
.and_then(|r: (String,)| Ok(r.0))
self.method_call("org.freedesktop.DBus.Introspectable", "Introspect", ()).map(|r: (String,)| r.0)
}
}

Expand Down Expand Up @@ -275,17 +273,15 @@ impl<'a, T: blocking::BlockingSender, C: ::std::ops::Deref<Target = T>> OrgFreed
"org.freedesktop.DBus.Properties",
"Get",
(interface_name, property_name),
)
.and_then(|r: (arg::Variant<Box<dyn arg::RefArg + 'static>>,)| Ok(r.0))
).map(|r: (arg::Variant<Box<dyn arg::RefArg + 'static>>,)| r.0)
}

fn get_all(&self, interface_name: &str) -> Result<arg::PropMap, dbus::Error> {
self.method_call(
"org.freedesktop.DBus.Properties",
"GetAll",
(interface_name,),
)
.and_then(|r: (arg::PropMap,)| Ok(r.0))
).map(|r: (arg::PropMap,)| r.0)
}

fn set(
Expand Down
30 changes: 10 additions & 20 deletions support/dbus/interfaces/rust/org.eruption/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -67,38 +67,31 @@ impl<'a, T: blocking::BlockingSender, C: ::std::ops::Deref<Target = T>> OrgErupt
for blocking::Proxy<'a, C>
{
fn get_color_scheme(&self, name: &str) -> Result<Vec<u8>, dbus::Error> {
self.method_call("org.eruption.Config", "GetColorScheme", (name,))
.and_then(|r: (Vec<u8>,)| Ok(r.0))
self.method_call("org.eruption.Config", "GetColorScheme", (name,)).map(|r: (Vec<u8>,)| r.0)
}

fn get_color_schemes(&self) -> Result<Vec<String>, dbus::Error> {
self.method_call("org.eruption.Config", "GetColorSchemes", ())
.and_then(|r: (Vec<String>,)| Ok(r.0))
self.method_call("org.eruption.Config", "GetColorSchemes", ()).map(|r: (Vec<String>,)| r.0)
}

fn ping(&self) -> Result<bool, dbus::Error> {
self.method_call("org.eruption.Config", "Ping", ())
.and_then(|r: (bool,)| Ok(r.0))
self.method_call("org.eruption.Config", "Ping", ()).map(|r: (bool,)| r.0)
}

fn ping_privileged(&self) -> Result<bool, dbus::Error> {
self.method_call("org.eruption.Config", "PingPrivileged", ())
.and_then(|r: (bool,)| Ok(r.0))
self.method_call("org.eruption.Config", "PingPrivileged", ()).map(|r: (bool,)| r.0)
}

fn remove_color_scheme(&self, name: &str) -> Result<bool, dbus::Error> {
self.method_call("org.eruption.Config", "RemoveColorScheme", (name,))
.and_then(|r: (bool,)| Ok(r.0))
self.method_call("org.eruption.Config", "RemoveColorScheme", (name,)).map(|r: (bool,)| r.0)
}

fn set_color_scheme(&self, name: &str, data: Vec<u8>) -> Result<bool, dbus::Error> {
self.method_call("org.eruption.Config", "SetColorScheme", (name, data))
.and_then(|r: (bool,)| Ok(r.0))
self.method_call("org.eruption.Config", "SetColorScheme", (name, data)).map(|r: (bool,)| r.0)
}

fn write_file(&self, filename: &str, data: &str) -> Result<bool, dbus::Error> {
self.method_call("org.eruption.Config", "WriteFile", (filename, data))
.and_then(|r: (bool,)| Ok(r.0))
self.method_call("org.eruption.Config", "WriteFile", (filename, data)).map(|r: (bool,)| r.0)
}

fn brightness(&self) -> Result<i64, dbus::Error> {
Expand Down Expand Up @@ -146,8 +139,7 @@ impl<'a, T: blocking::BlockingSender, C: ::std::ops::Deref<Target = T>>
OrgFreedesktopDBusIntrospectable for blocking::Proxy<'a, C>
{
fn introspect(&self) -> Result<String, dbus::Error> {
self.method_call("org.freedesktop.DBus.Introspectable", "Introspect", ())
.and_then(|r: (String,)| Ok(r.0))
self.method_call("org.freedesktop.DBus.Introspectable", "Introspect", ()).map(|r: (String,)| r.0)
}
}

Expand Down Expand Up @@ -210,17 +202,15 @@ impl<'a, T: blocking::BlockingSender, C: ::std::ops::Deref<Target = T>> OrgFreed
"org.freedesktop.DBus.Properties",
"Get",
(interface_name, property_name),
)
.and_then(|r: (arg::Variant<Box<dyn arg::RefArg + 'static>>,)| Ok(r.0))
).map(|r: (arg::Variant<Box<dyn arg::RefArg + 'static>>,)| r.0)
}

fn get_all(&self, interface_name: &str) -> Result<arg::PropMap, dbus::Error> {
self.method_call(
"org.freedesktop.DBus.Properties",
"GetAll",
(interface_name,),
)
.and_then(|r: (arg::PropMap,)| Ok(r.0))
).map(|r: (arg::PropMap,)| r.0)
}

fn set(
Expand Down
27 changes: 9 additions & 18 deletions support/dbus/interfaces/rust/org.eruption/devices.rs
Original file line number Diff line number Diff line change
Expand Up @@ -84,25 +84,21 @@ impl<'a, T: blocking::BlockingSender, C: ::std::ops::Deref<Target = T>> OrgErupt
for blocking::Proxy<'a, C>
{
fn get_device_config(&self, device: u64, param: &str) -> Result<String, dbus::Error> {
self.method_call("org.eruption.Device", "GetDeviceConfig", (device, param))
.and_then(|r: (String,)| Ok(r.0))
self.method_call("org.eruption.Device", "GetDeviceConfig", (device, param)).map(|r: (String,)| r.0)
}

fn get_device_status(&self, device: u64) -> Result<String, dbus::Error> {
self.method_call("org.eruption.Device", "GetDeviceStatus", (device,))
.and_then(|r: (String,)| Ok(r.0))
self.method_call("org.eruption.Device", "GetDeviceStatus", (device,)).map(|r: (String,)| r.0)
}

fn get_managed_devices(
&self,
) -> Result<(Vec<(u16, u16)>, Vec<(u16, u16)>, Vec<(u16, u16)>), dbus::Error> {
self.method_call("org.eruption.Device", "GetManagedDevices", ())
.and_then(|r: ((Vec<(u16, u16)>, Vec<(u16, u16)>, Vec<(u16, u16)>),)| Ok(r.0))
self.method_call("org.eruption.Device", "GetManagedDevices", ()).map(|r: ((Vec<(u16, u16)>, Vec<(u16, u16)>, Vec<(u16, u16)>),)| r.0)
}

fn is_device_enabled(&self, device: u64) -> Result<bool, dbus::Error> {
self.method_call("org.eruption.Device", "IsDeviceEnabled", (device,))
.and_then(|r: (bool,)| Ok(r.0))
self.method_call("org.eruption.Device", "IsDeviceEnabled", (device,)).map(|r: (bool,)| r.0)
}

fn set_device_config(
Expand All @@ -115,13 +111,11 @@ impl<'a, T: blocking::BlockingSender, C: ::std::ops::Deref<Target = T>> OrgErupt
"org.eruption.Device",
"SetDeviceConfig",
(device, param, value),
)
.and_then(|r: (bool,)| Ok(r.0))
).map(|r: (bool,)| r.0)
}

fn set_device_enabled(&self, device: u64, enabled: bool) -> Result<bool, dbus::Error> {
self.method_call("org.eruption.Device", "SetDeviceEnabled", (device, enabled))
.and_then(|r: (bool,)| Ok(r.0))
self.method_call("org.eruption.Device", "SetDeviceEnabled", (device, enabled)).map(|r: (bool,)| r.0)
}

fn device_status(&self) -> Result<String, dbus::Error> {
Expand All @@ -143,8 +137,7 @@ impl<'a, T: blocking::BlockingSender, C: ::std::ops::Deref<Target = T>>
OrgFreedesktopDBusIntrospectable for blocking::Proxy<'a, C>
{
fn introspect(&self) -> Result<String, dbus::Error> {
self.method_call("org.freedesktop.DBus.Introspectable", "Introspect", ())
.and_then(|r: (String,)| Ok(r.0))
self.method_call("org.freedesktop.DBus.Introspectable", "Introspect", ()).map(|r: (String,)| r.0)
}
}

Expand Down Expand Up @@ -207,17 +200,15 @@ impl<'a, T: blocking::BlockingSender, C: ::std::ops::Deref<Target = T>> OrgFreed
"org.freedesktop.DBus.Properties",
"Get",
(interface_name, property_name),
)
.and_then(|r: (arg::Variant<Box<dyn arg::RefArg + 'static>>,)| Ok(r.0))
).map(|r: (arg::Variant<Box<dyn arg::RefArg + 'static>>,)| r.0)
}

fn get_all(&self, interface_name: &str) -> Result<arg::PropMap, dbus::Error> {
self.method_call(
"org.freedesktop.DBus.Properties",
"GetAll",
(interface_name,),
)
.and_then(|r: (arg::PropMap,)| Ok(r.0))
).map(|r: (arg::PropMap,)| r.0)
}

fn set(
Expand Down
18 changes: 6 additions & 12 deletions support/dbus/interfaces/rust/org.eruption/profile.rs
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,7 @@ impl<'a, T: blocking::BlockingSender, C: ::std::ops::Deref<Target = T>> OrgErupt
for blocking::Proxy<'a, C>
{
fn enum_profiles(&self) -> Result<Vec<(String, String)>, dbus::Error> {
self.method_call("org.eruption.Profile", "EnumProfiles", ())
.and_then(|r: (Vec<(String, String)>,)| Ok(r.0))
self.method_call("org.eruption.Profile", "EnumProfiles", ()).map(|r: (Vec<(String, String)>,)| r.0)
}

fn set_parameter(
Expand All @@ -95,13 +94,11 @@ impl<'a, T: blocking::BlockingSender, C: ::std::ops::Deref<Target = T>> OrgErupt
"org.eruption.Profile",
"SetParameter",
(profile_file, script_file, param_name, value),
)
.and_then(|r: (bool,)| Ok(r.0))
).map(|r: (bool,)| r.0)
}

fn switch_profile(&self, filename: &str) -> Result<bool, dbus::Error> {
self.method_call("org.eruption.Profile", "SwitchProfile", (filename,))
.and_then(|r: (bool,)| Ok(r.0))
self.method_call("org.eruption.Profile", "SwitchProfile", (filename,)).map(|r: (bool,)| r.0)
}

fn active_profile(&self) -> Result<String, dbus::Error> {
Expand All @@ -123,8 +120,7 @@ impl<'a, T: blocking::BlockingSender, C: ::std::ops::Deref<Target = T>>
OrgFreedesktopDBusIntrospectable for blocking::Proxy<'a, C>
{
fn introspect(&self) -> Result<String, dbus::Error> {
self.method_call("org.freedesktop.DBus.Introspectable", "Introspect", ())
.and_then(|r: (String,)| Ok(r.0))
self.method_call("org.freedesktop.DBus.Introspectable", "Introspect", ()).map(|r: (String,)| r.0)
}
}

Expand Down Expand Up @@ -187,17 +183,15 @@ impl<'a, T: blocking::BlockingSender, C: ::std::ops::Deref<Target = T>> OrgFreed
"org.freedesktop.DBus.Properties",
"Get",
(interface_name, property_name),
)
.and_then(|r: (arg::Variant<Box<dyn arg::RefArg + 'static>>,)| Ok(r.0))
).map(|r: (arg::Variant<Box<dyn arg::RefArg + 'static>>,)| r.0)
}

fn get_all(&self, interface_name: &str) -> Result<arg::PropMap, dbus::Error> {
self.method_call(
"org.freedesktop.DBus.Properties",
"GetAll",
(interface_name,),
)
.and_then(|r: (arg::PropMap,)| Ok(r.0))
).map(|r: (arg::PropMap,)| r.0)
}

fn set(
Expand Down
Loading

0 comments on commit b7ee203

Please sign in to comment.