wireshift-core 0.1.1

Core typed operations, buffers, and backend traits for wireshift
Documentation
//! A First-In-First-Out (FIFO) queue for simple job strategy processing.
use crate::completion::CompletionEvent;
use crate::error::Result;
use crate::{BackendFactory, Ring};

/// Drains one completion at a time in submission order.
///
/// ```no_run
/// use wireshift::{Ring, RingConfig, strategy::FifoDrain};
///
/// let ring = Ring::new(RingConfig::default())?;
/// let drain = FifoDrain::new(ring);
/// let _ = drain;
/// # Ok::<(), Box<dyn std::error::Error>>(())
/// ```
#[derive(Clone)]
pub struct FifoDrain<F: BackendFactory> {
    ring: Ring<F>,
}

impl<F: BackendFactory> FifoDrain<F> {
    /// Creates a FIFO drain adapter.
    #[must_use]
    pub fn new(ring: Ring<F>) -> Self {
        Self { ring }
    }

    /// Waits for one completion.
    pub fn next(&self) -> Result<CompletionEvent> {
        self.ring.complete(None)
    }
}