use std::task::{Context, Poll};
pub use dfir_macro::DemuxEnum;
use dfir_pipes::Toggle;
use dfir_pipes::push::PushStep;
#[diagnostic::on_unimplemented(
note = "ensure there is exactly one output for each enum variant.",
note = "ensure that the type for each output is a tuple of the field for the variant: `()`, `(a,)`, or `(a, b, ...)`."
)]
pub trait DemuxEnumSink<Outputs>: DemuxEnumBase {
type Error;
fn poll_ready(outputs: &mut Outputs, cx: &mut Context<'_>) -> Poll<Result<(), Self::Error>>;
fn start_send(self, outputs: &mut Outputs) -> Result<(), Self::Error>;
fn poll_flush(outputs: &mut Outputs, cx: &mut Context<'_>) -> Poll<Result<(), Self::Error>>;
fn poll_close(outputs: &mut Outputs, cx: &mut Context<'_>) -> Poll<Result<(), Self::Error>>;
}
#[diagnostic::on_unimplemented(
note = "ensure there is exactly one output for each enum variant.",
note = "ensure that the type for each output is a tuple of the field for the variant: `()`, `(a,)`, or `(a, b, ...)`."
)]
pub trait DemuxEnumPush<Outputs, Meta: Copy>: DemuxEnumBase {
type Ctx<'ctx>: dfir_pipes::Context<'ctx>;
type CanPend: Toggle;
fn poll_ready(outputs: &mut Outputs, ctx: &mut Self::Ctx<'_>) -> PushStep<Self::CanPend>;
fn start_send(self, meta: Meta, outputs: &mut Outputs);
fn poll_flush(outputs: &mut Outputs, ctx: &mut Self::Ctx<'_>) -> PushStep<Self::CanPend>;
fn size_hint(outputs: &mut Outputs, hint: (usize, Option<usize>));
}
#[diagnostic::on_unimplemented(
note = "requires that the enum have only one variant.",
note = "ensure there are no missing outputs; there must be exactly one output for each enum variant."
)]
pub trait SingleVariant: DemuxEnumBase {
type Output;
fn single_variant(self) -> Self::Output;
}
#[diagnostic::on_unimplemented(note = "use `#[derive(dfir_rs::DemuxEnum)]`")]
pub trait DemuxEnumBase {}