iridis_api/io/
raw_input.rs

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