Skip to main content

Driver

Trait Driver 

Source
pub trait Driver: Send {
    // Required methods
    fn kind(&self) -> DriverKind;
    fn register(
        &mut self,
        socket: BorrowedSocket<'_>,
        token: Token,
    ) -> Result<(), NetError>;
    fn submit(&mut self, operation: Operation) -> Result<(), Rejected>;
    fn wait(
        &mut self,
        out: &mut Completions,
        timeout: Option<Duration>,
    ) -> Result<usize, NetError>;
    fn cancel(
        &mut self,
        token: Token,
        which: OperationKind,
    ) -> Result<(), NetError>;
    fn deregister(&mut self, token: Token) -> Result<(), NetError>;
    fn waker(&self) -> DriverWaker;
}
Expand description

A driver: one per worker, used from one thread. See the module docs.

Unstable until 1.0.0. A socket must stay open from Driver::register until Driver::deregister returns.

Required Methods§

Source

fn kind(&self) -> DriverKind

Which driver this is.

Source

fn register( &mut self, socket: BorrowedSocket<'_>, token: Token, ) -> Result<(), NetError>

Adds a non-blocking socket under token.

§Errors

Os when the OS refuses.

Source

fn submit(&mut self, operation: Operation) -> Result<(), Rejected>

Starts an operation; its completion arrives through Driver::wait.

§Errors

Rejected gives the operation and its buffers back: the token is not registered, or the same kind of operation is already pending on it.

Source

fn wait( &mut self, out: &mut Completions, timeout: Option<Duration>, ) -> Result<usize, NetError>

Fills out with finished operations, waiting up to timeout for the first (None: until one finishes or the waker fires). Returns how many.

§Errors

Os when the wait itself fails.

Source

fn cancel(&mut self, token: Token, which: OperationKind) -> Result<(), NetError>

Cancels the pending operation of kind which; it still completes exactly once (with Aborted, or with its result if it already finished).

§Errors

Os when the OS refuses.

Source

fn deregister(&mut self, token: Token) -> Result<(), NetError>

Removes the socket; no completion arrives for it afterwards.

§Errors

Os when the OS refuses.

Source

fn waker(&self) -> DriverWaker

A waker for this driver.

Dyn Compatibility§

This trait is dyn compatible.

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

Implementors§