use std::marker::PhantomData;
pub(crate) mod sealed {
pub trait Sealed {}
}
pub struct Once;
pub struct Repeat;
pub struct Rate;
pub struct Open;
pub struct Set;
pub struct NoWait;
pub struct WaitFor<T>(PhantomData<fn(T)>);
pub struct ReceiveAll<H>(PhantomData<fn(H)>);
pub struct ReceiveAny<H>(PhantomData<fn(H)>);
impl sealed::Sealed for Once {}
impl sealed::Sealed for Repeat {}
impl sealed::Sealed for Rate {}
impl sealed::Sealed for Open {}
impl sealed::Sealed for Set {}
impl sealed::Sealed for NoWait {}
impl<T> sealed::Sealed for WaitFor<T> {}
impl<H> sealed::Sealed for ReceiveAll<H> {}
impl<H> sealed::Sealed for ReceiveAny<H> {}
#[allow(private_bounds)]
pub trait Repeatable: sealed::Sealed {}
impl Repeatable for Repeat {}
impl Repeatable for Rate {}
#[diagnostic::on_unimplemented(
message = "`count` is already set",
label = "set once, and before `after`",
note = "`after` closes the count, so chain `count` first"
)]
#[allow(private_bounds)]
pub trait Unset: sealed::Sealed {}
impl Unset for Open {}
#[allow(private_bounds)]
pub trait Wiring: sealed::Sealed {
#[doc(hidden)]
type Link;
#[doc(hidden)]
type AfterKind<C>;
}
impl Wiring for NoWait {
type Link = ();
type AfterKind<C> = C;
}
impl<T> Wiring for WaitFor<T> {
type Link = ();
type AfterKind<C> = Open;
}
impl<H> Wiring for ReceiveAll<H> {
type Link = H;
type AfterKind<C> = Open;
}
impl<H> Wiring for ReceiveAny<H> {
type Link = H;
type AfterKind<C> = Open;
}
#[allow(private_bounds)]
#[diagnostic::on_unimplemented(
message = "a task that runs once has nothing to count",
label = "not repeating or waiting",
note = "chain `repeat`, `at_rate`, `wait_for` or `receive` before `count`"
)]
pub trait Waits: Wiring {}
impl<T> Waits for WaitFor<T> {}
impl<H> Waits for ReceiveAll<H> {}
impl<H> Waits for ReceiveAny<H> {}