iridis_api/io/
raw_input.rs

1use crate::prelude::*;
2
3/// Not typed Input to receive data from the dataflow
4#[derive(Debug)]
5pub struct RawInput {
6    /// The receiver part of the MPSC channel
7    pub rx: MessageReceiver,
8
9    /// The source node layout, useful for debugging
10    pub source: NodeLayout,
11    /// The layout of the input, useful for debugging
12    pub layout: InputLayout,
13}
14
15impl RawInput {
16    /// Create a new RawInput instance
17    pub fn new(rx: MessageReceiver, source: NodeLayout, layout: InputLayout) -> Self {
18        Self { rx, source, layout }
19    }
20
21    /// Receive a message from the channel, asynchronously
22    pub async fn recv(&mut self) -> Result<DataflowMessage> {
23        let message = self
24            .rx
25            .recv()
26            .await
27            .ok_or_eyre(report_error_receiving(&self.source, &self.layout))?;
28
29        Ok(message)
30    }
31}