aboutsummaryrefslogtreecommitdiff
path: root/alsa/src/communication.rs
diff options
context:
space:
mode:
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)
+ }
+}