1 use std::time::Duration;
2 
3 #[cfg(feature = "event-stream")]
4 use super::sys::Waker;
5 use super::InternalEvent;
6 
7 #[cfg(unix)]
8 pub(crate) mod unix;
9 #[cfg(windows)]
10 pub(crate) mod windows;
11 
12 /// An interface for trying to read an `InternalEvent` within an optional `Duration`.
13 pub(crate) trait EventSource: Sync + Send {
14     /// Tries to read an `InternalEvent` within the given duration.
15     ///
16     /// # Arguments
17     ///
18     /// * `timeout` - `None` block indefinitely until an event is available, `Some(duration)` blocks
19     ///               for the given timeout
20     ///
21     /// Returns `Ok(None)` if there's no event available and timeout expires.
try_read(&mut self, timeout: Option<Duration>) -> crate::Result<Option<InternalEvent>>22     fn try_read(&mut self, timeout: Option<Duration>) -> crate::Result<Option<InternalEvent>>;
23 
24     /// Returns a `Waker` allowing to wake/force the `try_read` method to return `Ok(None)`.
25     #[cfg(feature = "event-stream")]
waker(&self) -> Waker26     fn waker(&self) -> Waker;
27 }
28