use crate::probe::{Cause, Outcome, State, Stopped};
type Fault<W, S> = Cause<
<W as Wait<S>>::Probe,
<<W as Wait<S>>::Outcome as Outcome>::Observation,
<W as Wait<S>>::Error,
>;
type Progress<W, S> = State<S, W>;
type Transition<T, S, W> = Result<T, Stopped<S, Fault<W, S>>>;
type Advanced<W, S> =
Result<(Progress<W, S>, <W as Wait<S>>::Outcome), Stopped<Progress<W, S>, Fault<W, S>>>;
type Cancelled<W, S> = Result<S, Stopped<Progress<W, S>, Fault<W, S>>>;
pub trait Wait<S>: Sized {
type Ring;
type Owned;
type Target;
type Probe: Copy;
type Outcome: Outcome<Probe = Self::Probe>;
type Error;
fn submit(
state: S,
ring: impl for<'a> FnOnce(&'a mut S) -> &'a mut Self::Ring,
entry: &Self::Owned,
probe: Self::Probe,
) -> Result<Self, Stopped<S, Fault<Self, S>>>;
fn resume(
stopped: Stopped<Self, Fault<Self, S>>,
ring: impl for<'a> FnOnce(&'a mut S) -> &'a mut Self::Ring,
report: impl FnMut(Fault<Self, S>),
) -> Result<Self, Stopped<Self, Fault<Self, S>>>;
fn finish(
self,
ring: impl for<'a> Fn(&'a mut S) -> &'a mut Self::Ring,
) -> Transition<(S, Self::Outcome), S, Self>;
fn next(self, ring: impl for<'a> FnOnce(&'a mut S) -> &'a mut Self::Ring) -> Advanced<Self, S>;
fn cancel(self, ring: impl for<'a> Fn(&'a mut S) -> &'a mut Self::Ring) -> Cancelled<Self, S>;
unsafe fn option(
state: S,
access: impl for<'a> FnOnce(&'a mut S) -> (&'a mut Self::Ring, Self::Target, &'a libc::c_int),
probe: Self::Probe,
) -> Result<Self, Stopped<S, Fault<Self, S>>>;
unsafe fn inspect<E>(
self,
check: impl FnOnce(&mut S) -> Result<(), E>,
) -> Result<Self, Stopped<Self, E>>;
}