Skip to main content

Driver

Trait Driver 

Source
pub trait Driver: 'static {
    // Required methods
    fn handle(&self) -> Box<dyn Notify>;
    fn run(&self, rt: &Runtime) -> Result<()>;

    // Provided method
    fn clear(&self) { ... }
}
Expand description

Drives I/O events and scheduled tasks for the native Runtime.

Unlike Runner, a driver belongs to a single runtime thread.

Required Methods§

Source

fn handle(&self) -> Box<dyn Notify>

Returns a thread-safe notifier for this driver’s event loop.

Source

fn run(&self, rt: &Runtime) -> Result<()>

Drives the runtime until Runtime::poll returns PollResult::Ready.

Called by Runtime::block_on with rt active on the current thread. Process external events between polls, without blocking when the result is PollResult::PollAgain. Call Runtime::awake after waiting for events, before dispatching events that may wake tasks.

Returns an error if the event loop cannot continue.

Provided Methods§

Source

fn clear(&self)

Releases driver-owned state when requested by its owner.

The default implementation does nothing. Runtime::block_on does not call this hook.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§