-
Notifications
You must be signed in to change notification settings - Fork 38
/
Copy pathpoll_state.rs
39 lines (36 loc) · 1.03 KB
/
poll_state.rs
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
/// Enumerate the current poll state.
#[derive(Debug, Clone, Copy, Default)]
pub(crate) enum PollState {
/// Polling the underlying future.
#[default]
Pending,
/// Data has been written to the output structure
/// and the future should no longer be polled.
Done,
/// Data has been consumed from the output structure,
/// and we should no longer reason about it.
Consumed,
}
impl PollState {
/// Returns `true` if the metadata is [`Pending`].
///
/// [`Pending`]: Metadata::Pending
#[must_use]
pub(crate) fn is_pending(&self) -> bool {
matches!(self, Self::Pending)
}
/// Returns `true` if the poll state is [`Done`].
///
/// [`Done`]: PollState::Done
#[must_use]
pub(crate) fn is_done(&self) -> bool {
matches!(self, Self::Done)
}
/// Returns `true` if the poll state is [`Consumed`].
///
/// [`Consumed`]: PollState::Consumed
#[must_use]
pub(crate) fn is_consumed(&self) -> bool {
matches!(self, Self::Consumed)
}
}