crossio_core/interest.rs
1//! Readiness interests that can be registered with a backend.
2use bitflags::bitflags;
3
4bitflags! {
5 /// Bitmask describing the types of readiness notifications a caller cares about.
6 #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
7 pub struct Interest: u8 {
8 /// Ready to read without blocking.
9 const READABLE = 0b0001;
10 /// Ready to write without blocking.
11 const WRITABLE = 0b0010;
12 /// Exceptional conditions (errors, priority data).
13 const PRIORITY = 0b0100;
14 /// Underlying stream has been closed for reads or writes.
15 const CLOSED = 0b1000;
16 }
17}
18
19impl Interest {
20 /// Convenience for `READABLE | WRITABLE`.
21 pub const fn readable_writable() -> Self {
22 Self::READABLE.union(Self::WRITABLE)
23 }
24}