pub struct IoSource { /* private fields */ }Expand description
RAII I/O source registered with the thread-local reactor.
The token field is used as the unique identifier when submitting kevent /
epoll_ctl calls. Tokens must be unique within a single reactor instance —
this type uses an atomic counter to guarantee uniqueness without caller
coordination.
Implementations§
Source§impl IoSource
impl IoSource
Sourcepub fn new(raw: RawSource, token: usize, interest: Interest) -> Result<Self>
pub fn new(raw: RawSource, token: usize, interest: Interest) -> Result<Self>
Register raw with the thread-local reactor under token, monitoring
the given interest set.
§Errors
Propagates any OS error from the underlying register syscall.
Sourcepub fn reregister(&self, interest: Interest) -> Result<()>
pub fn reregister(&self, interest: Interest) -> Result<()>
Update the interest mask for an already-registered source.
§Errors
Returns io::ErrorKind::NotConnected if the source was never registered
(e.g. after a failed new), or propagates OS errors from reregister.
Sourcepub fn readable(&self) -> ReadableFuture<'_> ⓘ
pub fn readable(&self) -> ReadableFuture<'_> ⓘ
Returns a future that resolves once the source is readable.
On each poll the current waker is stored in the reactor’s waker registry.
When the reactor fires a READABLE event for this token, the waker fires
and the next poll returns Ready(Ok(())).
Sourcepub fn writable(&self) -> WritableFuture<'_> ⓘ
pub fn writable(&self) -> WritableFuture<'_> ⓘ
Returns a future that resolves once the source is writable.
Same waker integration as readable() but for WRITABLE events.