From e1f0525e4e1dcf674aa7489042a06b7c7d671a2a Mon Sep 17 00:00:00 2001 From: Andreas Grois Date: Sun, 2 May 2021 16:10:34 +0200 Subject: Make runnable's run() method take a mutable self-reference. Because there is no real reason speaking against it, and it makes plugin development a lot easier. --- clock/src/lib.rs | 2 +- pulse/src/runnable/mod.rs | 2 +- swaystatus-plugin/src/lib.rs | 2 +- swaystatus/src/main.rs | 2 +- swaystatus/src/test_plugin.rs | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/clock/src/lib.rs b/clock/src/lib.rs index 76f5ea7..8055449 100644 --- a/clock/src/lib.rs +++ b/clock/src/lib.rs @@ -76,7 +76,7 @@ impl<'c> ClockRunnable<'c> { } impl<'c> SwayStatusModuleRunnable for ClockRunnable<'c> { - fn run(&self) { + fn run(&mut self) { match self.config.refresh_rate { ClockRefreshRate::NotSynchronized { seconds } => { self.simple_loop(std::time::Duration::from_secs_f32(seconds.abs())); diff --git a/pulse/src/runnable/mod.rs b/pulse/src/runnable/mod.rs index 612bca9..ca63f24 100644 --- a/pulse/src/runnable/mod.rs +++ b/pulse/src/runnable/mod.rs @@ -28,7 +28,7 @@ impl<'p : 's, 's> PulseVolumeRunnable<'p> { } impl<'p> SwayStatusModuleRunnable for PulseVolumeRunnable<'p> { - fn run(&self) { + fn run(&mut self) { //TODO } } diff --git a/swaystatus-plugin/src/lib.rs b/swaystatus-plugin/src/lib.rs index 8a632cf..a9859c8 100644 --- a/swaystatus-plugin/src/lib.rs +++ b/swaystatus-plugin/src/lib.rs @@ -156,7 +156,7 @@ pub trait SwayStatusModule { ///Will be called in a worker thread. pub trait SwayStatusModuleRunnable : Send { ///Starts executing this module. - fn run(&self); + fn run(&mut self); } ///Implement this trait on a struct that holds the configuration for a single instance of your diff --git a/swaystatus/src/main.rs b/swaystatus/src/main.rs index e4847d9..c1c1b73 100644 --- a/swaystatus/src/main.rs +++ b/swaystatus/src/main.rs @@ -89,7 +89,7 @@ fn core_loop(plugin_path : &std::path::Path, config_path : &std::path::Path) -> // Main everything is ready for the big main loop. Let's spawn the threads! if let Err(_e) = thread::scope(|s| { signalhandler::handle_signals(s, sender_from_plugins); - for runnable in runnables { + for mut runnable in runnables { s.spawn(move |_| { runnable.run(); }); diff --git a/swaystatus/src/test_plugin.rs b/swaystatus/src/test_plugin.rs index 4e265e2..c82366d 100644 --- a/swaystatus/src/test_plugin.rs +++ b/swaystatus/src/test_plugin.rs @@ -28,7 +28,7 @@ pub struct TestConfig { } impl SwayStatusModuleRunnable for TestRunnable { - fn run(&self) { + fn run(&mut self) { println!("Running!"); } } -- cgit v1.2.3