pub trait IoBackend<Handle: Pollable = DefaultHandle> {
type Backend: Future<Output = ()> + Send + ?Sized;
// Required methods
fn polling_handle(&self) -> Option<PollingHandle<'_>>;
fn get_backend(&self) -> BackendHandle<'_, Self::Backend>;
}
Expand description
Primary trait describing I/O backends.
This trait is implemented at the outer-most stateful object of the I/O context. A IoBackend
has the opportunity to expose efficient ways of driving said backend to completion.
Users may want to call methods available on IoBackendExt
, instead of the ones on this
trait.
Required Associated Types§
Required Methods§
sourcefn polling_handle(&self) -> Option<PollingHandle<'_>>
fn polling_handle(&self) -> Option<PollingHandle<'_>>
Gets handle to the backing event system.
This function returns a handle and a waker. The handle is a RawFd
on Unix systems, and a
RawHandle
on Windows. This handle is meant to be polled/waited on by the system.
The waker is opaque, but should unblock the handle once signaled.
If the function returns None
, then it can be assumed that the backend will wake any waker
up with other mechanism (such as auxiliary thread), and that the polling implementation can
simply park the thread.
sourcefn get_backend(&self) -> BackendHandle<'_, Self::Backend>
fn get_backend(&self) -> BackendHandle<'_, Self::Backend>
Acquires exclusive handle to IO backend.
Panics
This function panics when multiple backend handles are attempted to be acquired. This
function does not return an Option
, because such case usually indicates a bug in the
code.