aboutsummaryrefslogtreecommitdiff
path: root/pulse/src/communication.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/communication.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/communication.rs')
-rw-r--r--pulse/src/communication.rs6
1 files changed, 3 insertions, 3 deletions
diff --git a/pulse/src/communication.rs b/pulse/src/communication.rs
index cfb800e..918d6c9 100644
--- a/pulse/src/communication.rs
+++ b/pulse/src/communication.rs
@@ -9,11 +9,11 @@ pub enum MessagesFromMain {
pub struct SenderForMain {
sender : Sender<MessagesFromMain>,
- pulse_waker : PulseWakeUp
+ pulse_waker : Option<PulseWakeUp>
}
impl<'p> SenderForMain {
- pub fn new(sender : Sender<MessagesFromMain>, pulse_waker : PulseWakeUp) -> Self {
+ pub fn new(sender : Sender<MessagesFromMain>, pulse_waker : Option<PulseWakeUp>) -> Self {
SenderForMain{
sender,
pulse_waker
@@ -24,7 +24,7 @@ impl<'p> SenderForMain {
if let Ok(_) = self.sender.send(message) {
//The cool thing about pulse using poll() is that poll() also wakes up if started after
//the actual wake up call. So no need to worry about races, this is inherently sane!
- self.pulse_waker.wake_up()?;
+ self.pulse_waker.as_ref().ok_or(PluginCommunicationError {})?.wake_up()?;
Ok(())
}
else {