aboutsummaryrefslogtreecommitdiff
path: root/pulse/src/runnable/mod.rs
diff options
context:
space:
mode:
authorAndreas Grois <andi@grois.info>2021-05-08 21:37:48 +0200
committerAndreas Grois <andi@grois.info>2021-05-08 21:37:48 +0200
commit13573941cca891bcf7fa5b61b5816178658bc339 (patch)
tree1e537ecaa5afd43a8fda0c224d4f2fe563d534d0 /pulse/src/runnable/mod.rs
parent0b6a4634675f27b88bb61b54f2b3711d0cd2f1a0 (diff)
Make (most) pulse nullptr checks unnecessary.
This change makes respective functions return either a result or an option instead. The goal here is readability.
Diffstat (limited to 'pulse/src/runnable/mod.rs')
-rw-r--r--pulse/src/runnable/mod.rs8
1 files changed, 4 insertions, 4 deletions
diff --git a/pulse/src/runnable/mod.rs b/pulse/src/runnable/mod.rs
index 612bca9..149e994 100644
--- a/pulse/src/runnable/mod.rs
+++ b/pulse/src/runnable/mod.rs
@@ -4,13 +4,13 @@ use swaystatus_plugin::*;
use crate::communication::*;
pub mod pulse;
-use pulse::Pulse;
+use pulse::{Pulse,MainLoopCreationError};
pub struct PulseVolumeRunnable<'p> {
config : &'p PulseVolumeConfig,
to_main : Box<dyn MsgModuleToMain + 'p>,
from_main : Receiver<MessagesFromMain>,
- pulse : Pulse
+ pulse : Result<Pulse,MainLoopCreationError>
}
impl<'p : 's, 's> PulseVolumeRunnable<'p> {
@@ -20,9 +20,9 @@ impl<'p : 's, 's> PulseVolumeRunnable<'p> {
config,
to_main,
from_main : r,
- pulse: Pulse::init(&config.sink),
+ pulse: Pulse::create()
};
- let sender = SenderForMain::new(s, result.pulse.get_wake_up());
+ let sender = SenderForMain::new(s, result.pulse.as_ref().map_or(None,|x| Some(x.get_wake_up())));
(result, sender)
}
}