aboutsummaryrefslogtreecommitdiff
path: root/alsa/src/communication.rs
diff options
context:
space:
mode:
authorAndreas Grois <andi@grois.info>2024-01-24 21:40:48 +0100
committerAndreas Grois <andi@grois.info>2024-01-24 21:40:48 +0100
commit57fd648407a233ae62b2c561d902783597274f83 (patch)
tree6c4149d45eebfd3374d18c61ff766c8e0814f322 /alsa/src/communication.rs
parent3f362de1ab94b994ef4ccdc403cab4cb8d0d1bcb (diff)
Start work on ALSA volume display
Diffstat (limited to 'alsa/src/communication.rs')
-rw-r--r--alsa/src/communication.rs30
1 files changed, 30 insertions, 0 deletions
diff --git a/alsa/src/communication.rs b/alsa/src/communication.rs
new file mode 100644
index 0000000..be11dd8
--- /dev/null
+++ b/alsa/src/communication.rs
@@ -0,0 +1,30 @@
+use std::sync::mpsc::*;
+use swaystatus_plugin::*;
+
+pub enum MessagesFromMain {
+ Quit,
+ Refresh
+}
+
+pub struct SenderForMain {
+ sender : Sender<MessagesFromMain>,
+}
+
+impl<'p> SenderForMain {
+ pub fn new(sender : Sender<MessagesFromMain>) -> Self {
+ Self { sender }
+ }
+
+ fn send(&self, message : MessagesFromMain) -> Result<(), PluginCommunicationError> {
+ self.sender.send(message).map_err(|_| PluginCommunicationError)
+ }
+}
+
+impl MsgMainToModule for SenderForMain {
+ fn send_quit(&self) -> Result<(),PluginCommunicationError> {
+ self.send(MessagesFromMain::Quit)
+ }
+ fn send_refresh(&self) -> Result<(),PluginCommunicationError> {
+ self.send(MessagesFromMain::Refresh)
+ }
+}