1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
#![deny(missing_docs)]
#![cfg_attr(docsrs, feature(doc_cfg))]
use std::task::{Context, Poll};
#[macro_use]
mod macros;
mod util;
cfg_unix! {
pub mod unix;
}
#[cfg(windows)]
mod windows;
#[derive(Debug)]
pub struct CtrlC {
_private: (),
}
impl CtrlC {
#[inline]
pub async fn recv(&mut self) -> Option<()> {
util::poll_fn(|cx| self.poll_recv(cx)).await
}
pub fn poll_recv(&mut self, _cx: &mut Context<'_>) -> Poll<Option<()>> {
unimplemented!()
}
}
cfg_stream! {
impl futures::stream::Stream for CtrlC {
type Item = ();
#[inline]
fn poll_next(
mut self: std::pin::Pin<&mut Self>,
cx: &mut Context<'_>
) -> Poll<Option<()>> {
self.poll_recv(cx)
}
}
}