pub struct IoCompletion { /* private fields */ }Expand description
One operation completion delivered to a ThreadpoolIo callback.
The completion borrows the operation’s storage for the duration of the
callback. Recover the owned operation with IoCompletion::claim when the
payload type is known; otherwise the storage is reclaimed generically when
the callback returns, which is what lets one object carry operations of mixed
payload types.
Implementations§
Source§impl IoCompletion
impl IoCompletion
Sourcepub fn bytes_transferred(&self) -> usize
pub fn bytes_transferred(&self) -> usize
The number of bytes transferred by the operation.
Sourcepub fn error(&self) -> Option<Error>
pub fn error(&self) -> Option<Error>
The failure of the completed operation, if it did not succeed.
A cancelled operation completes here as ERROR_OPERATION_ABORTED.
Sourcepub fn id(&self) -> Option<OperationId>
pub fn id(&self) -> Option<OperationId>
The identity of the completed operation, as returned by
ThreadpoolIo::submit.
It compares equal to the OperationId that submission returned, so a
caller holding submission-time identities can match a completion against
them directly.
Sourcepub fn overlapped_ptr(&self) -> *mut OVERLAPPED
pub fn overlapped_ptr(&self) -> *mut OVERLAPPED
The OVERLAPPED pointer identifying the completed operation.
Sourcepub unsafe fn claim<P>(&self) -> Operation<P>
pub unsafe fn claim<P>(&self) -> Operation<P>
Recover the owned operation whose completion this is.
The operation is returned in OperationState::Completed whether or not
it succeeded, matching the raw IOCP backend; read IoCompletion::error
for the outcome.
§Safety
This completion must be for an Operation<P> of this exact type
submitted through ThreadpoolIo::submit, and it must be claimed at
most once.