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§
Sourcefn kind(&self) -> DriverKind
fn kind(&self) -> DriverKind
Which driver this is.
Sourcefn submit(&mut self, operation: Operation) -> Result<(), Rejected>
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.
Sourcefn wait(
&mut self,
out: &mut Completions,
timeout: Option<Duration>,
) -> Result<usize, NetError>
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.
Sourcefn cancel(&mut self, token: Token, which: OperationKind) -> Result<(), NetError>
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.
Sourcefn waker(&self) -> DriverWaker
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".