use std::ops::ControlFlow;
use dope_sys::table::token::{self, Codec, Tuning as _};
use o3::base::num::bounded;
use crate::{driver::Key, reactor::sq};
pub trait Progress<T: Codec> {
fn next(&mut self, queue: sq::raw::Queue<'_, T>) -> Option<Option<T::Tuning>>;
fn has_pending(&self) -> bool;
fn cancel_all(&mut self);
fn cancel_at(&mut self, slot: sq::Fixed, target: Option<Key<T>>) -> ControlFlow<()>;
}
pub(crate) fn token<T: Codec>(slot: sq::Fixed) -> T::Tuning {
let index: <T::Context as token::Context>::Slot =
bounded::raw::U32::clamp(slot.index() as usize).into();
T::Tuning::new(index)
}