Skip to main content

dope_uring/driver/
tuning.rs

1use std::ops::ControlFlow;
2
3use dope_sys::table::token::{self, Codec, Tuning as _};
4use o3::base::num::bounded;
5
6use crate::{driver::Key, reactor::sq};
7
8/// Native option completions retain their host flight until every submitted
9/// scalar has completed and, when requested, the separate connect has finished.
10pub trait Progress<T: Codec> {
11    fn next(&mut self, queue: sq::raw::Queue<'_, T>) -> Option<Option<T::Tuning>>;
12    fn has_pending(&self) -> bool;
13    fn cancel_all(&mut self);
14    fn cancel_at(&mut self, slot: sq::Fixed, target: Option<Key<T>>) -> ControlFlow<()>;
15}
16
17pub(crate) fn token<T: Codec>(slot: sq::Fixed) -> T::Tuning {
18    let index: <T::Context as token::Context>::Slot =
19        bounded::raw::U32::clamp(slot.index() as usize).into();
20    T::Tuning::new(index)
21}