Skip to main content

IoRingErrorExt

Trait IoRingErrorExt 

Source
pub trait IoRingErrorExt: Sealed {
    // Required methods
    fn as_ioring_error(&self) -> Option<&IoRingError>;
    fn ring_condition(&self) -> Option<RingCondition>;
    fn is_submission_queue_full(&self) -> bool;
    fn is_completion_queue_too_full(&self) -> bool;
    fn is_submit_in_progress(&self) -> bool;
}
Expand description

Ask an io::Error this crate produced about the ring condition inside it (M10.5, D-30).

Exists because io::Error::kind cannot answer: every kernel-reported failure is io::ErrorKind::Other, since there is no faithful ErrorKind for most IORING_E_* conditions and inventing one would trade an honest Other for a lossy guess. The HRESULT survives behind a downcast, and this trait is that downcast plus the comparison, named once here instead of hand-rolled at each call site.

use windows_ioring_sys::{Batch, IoRing, IoRingErrorExt, PushOptions, SharedHandle};

let mut batch = Batch::new(ring);
match batch.read_owned(file, vec![0_u8; 4096], (), 0, PushOptions::new()) {
    Ok(_id) => {}
    // Backpressure, not a failure: submit and drain, then retry.
    Err(refused) if refused.error.is_submission_queue_full() => {
        batch.submit()?;
        return Ok(());
    }
    Err(refused) => return Err(refused.into()),
}

Sealed: implemented for io::Error and nothing else.

Required Methods§

Source

fn as_ioring_error(&self) -> Option<&IoRingError>

The IoRingError this error wraps, if it came from this crate’s report of a native HRESULT.

None for this crate’s own rejections (Unsupported, InvalidInput, AlreadyExists), which carry a meaningful io::Error::kind instead and never wrap an HRESULT.

Source

fn ring_condition(&self) -> Option<RingCondition>

The named condition this error reports, if any.

Source

fn is_submission_queue_full(&self) -> bool

Source

fn is_completion_queue_too_full(&self) -> bool

Source

fn is_submit_in_progress(&self) -> bool

Dyn Compatibility§

This trait is dyn compatible.

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

Implementations on Foreign Types§

Source§

impl IoRingErrorExt for Error

Implementors§