arcium-primitives 0.7.0

Arcium primitives
Documentation
use tokio::sync::oneshot::Sender as OneshotSender;

use crate::correlated_randomness::{stream::futures::CompletionHandle, CorrelatedBatch};

/// A handle for a prefetch operation. Fire-and-forget by default; await for completion
/// confirmation. The prefetch proceeds in the background whether or not this is awaited.
/// See [`CompletionHandle`].
pub type PrefetchHandle<E> = CompletionHandle<E>;

/// Commands sent from `PreprocessingStream` to the dispatcher task.
pub enum Command<PB: CorrelatedBatch, E> {
    /// Request N items as a single batch; the dispatcher assembles the Vec before sending.
    RequestN {
        n_elements: usize,
        completion: OneshotSender<Result<Vec<PB::Item>, E>>,
    },
    /// Proactively generate N items into the buffer.
    Prefetch {
        n_elements: usize,
        completion: OneshotSender<Result<(), E>>,
    },
    /// Advance the logical position to the absolute `target`, discarding intervening elements.
    Resync {
        target: u64,
        completion: OneshotSender<Result<(), E>>,
    },
}