dfir_rs/util/
demux_enum.rs1use std::task::{Context, Poll};
4
5pub use dfir_macro::DemuxEnum;
6
7#[diagnostic::on_unimplemented(
14 note = "ensure there is exactly one output for each enum variant.",
15 note = "ensure that the type for each output is a tuple of the field for the variant: `()`, `(a,)`, or `(a, b, ...)`."
16)]
17pub trait DemuxEnumSink<Outputs>: DemuxEnumBase {
18 type Error;
20
21 fn poll_ready(outputs: &mut Outputs, cx: &mut Context<'_>) -> Poll<Result<(), Self::Error>>;
23
24 fn start_send(self, outputs: &mut Outputs) -> Result<(), Self::Error>;
26
27 fn poll_flush(outputs: &mut Outputs, cx: &mut Context<'_>) -> Poll<Result<(), Self::Error>>;
29
30 fn poll_close(outputs: &mut Outputs, cx: &mut Context<'_>) -> Poll<Result<(), Self::Error>>;
32}
33
34#[diagnostic::on_unimplemented(
36 note = "requires that the enum have only one variant.",
37 note = "ensure there are no missing outputs; there must be exactly one output for each enum variant."
38)]
39pub trait SingleVariant: DemuxEnumBase {
40 type Output;
42 fn single_variant(self) -> Self::Output;
44}
45
46#[diagnostic::on_unimplemented(note = "use `#[derive(dfir_rs::DemuxEnum)]`")]
48pub trait DemuxEnumBase {}