1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
use crate::element::*;
use crate::error::Error;
use common::{MsgReceiver, MsgType, Pipeline};

/// Null message sink.
pub struct NullSinkElement;

impl ElementBuildable for NullSinkElement {
    type Config = crate::base::EmptyElementConf;

    const NAME: &'static str = "null-sink";

    const RECV_PORTS: Port = 32;

    fn acceptable_msg_types() -> Vec<Vec<MsgType>> {
        vec![vec![MsgType::any(); Self::RECV_PORTS as usize]]
    }

    fn new(_conf: Self::Config) -> Result<Self, Error> {
        Ok(NullSinkElement)
    }

    fn next(&mut self, _pipeline: &mut Pipeline, receiver: &mut MsgReceiver) -> ElementResult {
        loop {
            let _msg = receiver.recv_any_port()?;
        }
    }
}