signal: change unix::Signal to return () instead of signum (#1330)

* This simplifies the API surface by returning () instead of the signal
number that was used during registration. This also more closely mirrors
the cross-platform `CtrlC` event stream API
* This is a **breaking change**
This commit is contained in:
Ivan Petkov
2019-07-20 15:12:53 -07:00
committed by GitHub
parent 320a5fdca7
commit d9688bc094
5 changed files with 12 additions and 14 deletions
+3 -4
View File
@@ -254,7 +254,6 @@ impl Driver {
#[derive(Debug)]
pub struct Signal {
driver: Driver,
signal: c_int,
rx: Receiver<()>,
}
@@ -321,7 +320,7 @@ impl Signal {
let (tx, rx) = channel(1);
globals().register_listener(signal as EventId, tx);
Ok(Signal { driver, rx, signal })
Ok(Signal { driver, rx })
})
.boxed()
}
@@ -332,12 +331,12 @@ impl Signal {
}
impl Stream for Signal {
type Item = c_int;
type Item = ();
fn poll_next(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Option<Self::Item>> {
let _ = Pin::new(&mut self.driver).poll(cx);
self.rx.poll_recv(cx).map(|item| item.map(|()| self.signal))
self.rx.poll_recv(cx)
}
}