pub struct IoSource<T> {
state: IoSourceState,
inner: T,
selector_id: SelectorId,
}
Expand description
Adapter for a RawFd
or RawSocket
providing an event::Source
implementation.
IoSource
enables registering any FD or socket wrapper with Poll
.
While only implementations for TCP, UDP, and UDS (Unix only) are provided,
Mio supports registering any FD or socket that can be registered with the
underlying OS selector. IoSource
provides the necessary bridge.
§Notes
To handle the registrations and events properly all I/O operations (such
as read
, write
, etc.) must go through the do_io
method to ensure the
internal state is updated accordingly.
Fields§
§state: IoSourceState
§inner: T
§selector_id: SelectorId
Implementations§
source§impl<T> IoSource<T>
impl<T> IoSource<T>
sourcepub fn do_io<F, R>(&self, f: F) -> Result<R>
pub fn do_io<F, R>(&self, f: F) -> Result<R>
Execute an I/O operations ensuring that the socket receives more events
if it hits a WouldBlock
error.
§Notes
This method is required to be called for all I/O operations to
ensure the user will receive events once the socket is ready again after
returning a WouldBlock
error.
sourcepub fn into_inner(self) -> T
pub fn into_inner(self) -> T
Returns the I/O source, dropping the state.
§Notes
To ensure no more events are to be received for this I/O source first
deregister
it.
Trait Implementations§
source§impl<T> Deref for IoSource<T>
impl<T> Deref for IoSource<T>
Be careful when using this method. All I/O operations that may block must go
through the do_io
method.
source§impl<T> DerefMut for IoSource<T>
impl<T> DerefMut for IoSource<T>
Be careful when using this method. All I/O operations that may block must go
through the do_io
method.