dfir_rs/compiled/push/
demux_enum.rs1use std::pin::Pin;
3use std::task::{Context, Poll};
4
5use futures::sink::Sink;
6use pin_project_lite::pin_project;
7
8use crate::util::demux_enum::DemuxEnumSink;
9
10pin_project! {
11 #[must_use = "sinks do nothing unless polled"]
13 pub struct DemuxEnum<Outputs> {
14 outputs: Outputs,
15 }
16}
17
18impl<Outputs> DemuxEnum<Outputs> {
19 pub fn new<Item>(outputs: Outputs) -> Self
21 where
22 Self: Sink<Item>,
23 {
24 Self { outputs }
25 }
26}
27
28impl<Outputs, Item> Sink<Item> for DemuxEnum<Outputs>
29where
30 Item: DemuxEnumSink<Outputs>,
31{
32 type Error = Item::Error;
33
34 fn poll_ready(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Result<(), Self::Error>> {
35 Item::poll_ready(self.project().outputs, cx)
36 }
37
38 fn start_send(self: Pin<&mut Self>, item: Item) -> Result<(), Self::Error> {
39 Item::start_send(item, self.project().outputs)
40 }
41
42 fn poll_flush(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Result<(), Self::Error>> {
43 Item::poll_flush(self.project().outputs, cx)
44 }
45
46 fn poll_close(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Result<(), Self::Error>> {
47 Item::poll_close(self.project().outputs, cx)
48 }
49}