pub struct MioDriver<S = Box<dyn Handler<Event>>> { /* private fields */ }Expand description
World resource wrapping mio::Poll and a handler slab.
S is the handler storage type. Defaults to
Box<dyn Handler<mio::event::Event>>.
Users interact with this through Res<MioDriver<S>> (for
registry()) or ResMut<MioDriver<S>> (for insert/remove).
Implementations§
Source§impl<S> MioDriver<S>
impl<S> MioDriver<S>
Sourcepub fn registry(&self) -> &Registry
pub fn registry(&self) -> &Registry
Access the mio registry for registering/reregistering sources.
Poll::registry() takes &self, so this works through
Res<MioDriver<S>> (shared access).
Sourcepub fn insert(&mut self, handler: S) -> Token
pub fn insert(&mut self, handler: S) -> Token
Insert a handler and return its token.
The token maps to a mio::Token for use with
Registry::register. Requires ResMut<MioDriver<S>>.
Sourcepub fn remove(&mut self, token: Token) -> S
pub fn remove(&mut self, token: Token) -> S
Remove a handler by token.
The caller is responsible for deregistering the mio source via
registry().deregister(&mut source) if no replacement handler
will be inserted. Failing to deregister is safe (stale events
are skipped) but wastes kernel resources.
§Panics
Panics if the token is not present in the slab.